[Summary]: safe behaviour of ProgressDialog::show_pd(), ProgressDialog::hide_pd() in case of calling these methods NOT from gui thread

This commit is contained in:
YPozdnyakov 2015-02-10 14:23:21 +02:00
parent 29fc52a095
commit 68c5be2ef5
2 changed files with 21 additions and 3 deletions

View file

@ -129,20 +129,36 @@ ProgressDialog::add_progress_step ()
void
ProgressDialog::show_pd ()
{
WavesDialog::show ();
Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&ProgressDialog::show_pd_in_gui_thread , this));
}
void
ProgressDialog::show_pd_in_gui_thread ()
{
WavesDialog::show ();
/* Make sure the progress dialog is drawn */
Glib::MainContext::get_default()->iteration (false);
while (Glib::MainContext::get_default()->iteration (false)) {
/* do nothing */
}
}
void
ProgressDialog::hide_pd ()
{
Glib::MainContext::get_default()->iteration (false);
Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&ProgressDialog::hide_pd_in_gui_thread , this));
}
void
ProgressDialog::hide_pd_in_gui_thread ()
{
while (Glib::MainContext::get_default()->iteration (false)) {
/* do nothing */
}
set_progress (0);
WavesDialog::hide ();
}
void
ProgressDialog::show_cancel_button ()
{

View file

@ -58,6 +58,8 @@ private:
const std::string& top_message,
const std::string& progress_message,
const std::string& bottom_message);
void show_pd_in_gui_thread ();
void hide_pd_in_gui_thread ();
void set_progress_in_gui_thread (float);
Gtk::Label& _top_label;
Gtk::Label& _bottom_label;