Re: main window not redrawing after dialog closes



Paul Davis wrote:
you need to get your mind wrapped around the idea that you've created a
thread that will finish what its doing at some point in the future, but
you do not know when. until it finishes, you want to return control to
the regular event loop. here is a hint at one way to do this, not
bombproof, but you will get the idea:

	bool xml_thread_running;  // global or object scope
....
	
	xml_thread_running = true;
	Glib::Thread * thread = Glib::Thread::create(
  	       sigc::mem_fun(*this,&MainWindow::thread_open), true);

while (xml_thread_running) { if (Gtk::Main::events_pending()) { Gtk::Main::iteration ();
             }
        }

        get_window()->set_cursor ();


void MainWindow::thread_open()
{
	_member_widget->read_from_xml(_filename);

          xml_thread_running = false;

}

Now my eyes are opened. Thanks Paul. I never thought to look at the Gtk::Main object. One more question though. In the case that I have, my member function reads from an xml file then updates a table of Gdk::Drawables on-screen. Is it ok to have that whole member function threaded or should I do the threading there just around the actual xml-reading part?






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]