Re: main window not redrawing after dialog closes
- From: Paul Davis <paul linuxaudiosystems com>
- To: Rob Benton <rob benton conwaycorp net>
- Cc: gtkmm-list gnome org
- Subject: Re: main window not redrawing after dialog closes
- Date: Sat, 28 Jan 2006 07:13:14 -0500
On Fri, 2006-01-27 at 17:41 -0600, Rob Benton wrote:
> Well I gave it a shot and got the exact same results. Do I have this in
> the right? Now my code looks like this:
>
> void MainWindow::menu_open()
> {
> // change cursor while working
> get_window()->set_cursor(Gdk::Cursor(Gdk::WATCH));
> _filename = Glib::filename_to_utf8(dialog.get_filename());
> Glib::Thread * thread = Glib::Thread::create(
> sigc::mem_fun(*this,&MainWindow::thread_open), true);
> thread->join();
no good. thread->join() blocks waiting for your other thread to finish
running, so this is no different than just calling read_from_xml()
inline.
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;
> }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]