I keep running into a situation where my program suddenly hangs after a 
particular thread is done doing its job.  Actually, it doesn't 
technically "hang", it will actually respond to clicks and things, its 
just that the application window itself freezes.  For example, if I 
click the in the vicinity of the "Quit" button, the program will exit 
normally despite the fact that the entire window is grayed out as if it 
has frozen.

Also, this behavior doesn't happen every time, but it does happen 
frequently.  I assume it has something to do with the thread updating 
certain widgets, but I can't figure out why the behavior is so 
inconsistent.  Additionally, when I do not use a thread everything works 
fine, but since the searching operation takes a while it isn't very 
practical.

Any ideas?

The relevant code is fairly straightforward:

void fs::on_search_button_clicked() {

//this is a Gtk::ScrolledWindow
  db_searcher::db_searcher *dbs = Gtk::manage(new db_searcher());

  Glib::ustring search_string = search_entry.get_text();

  notebook.append_page(*dbs, search_string);

  Glib::Thread::create(sigc::bind(sigc::mem_fun(*this, 
&fs::search_db),(dbs),(search_string)), false);
 
  notebook.show_all();

}

void fs::search_db(db_searcher::db_searcher *dbs, Glib::ustring 
search_string) {

  progress_bar.set_text("Searching...");

  sigc::slot<bool> timeout_slot = sigc::mem_fun(*this, &fs::on_timeout);
  sigc::connection timeout_connection = 
Glib::signal_timeout().connect(timeout_slot, 50);

//this is the reason I use a thread since the searching takes a while
  dbs->search_db(search_string);

  progress_bar.set_text("Done");

  timeout_connection.disconnect();

  notebook.show_all();
 
  show_all_children();

}

Thanks,
Matt
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to