Re: Application hangs after thread execution



Matt,

The rule of thumb here is to either (a) make all GUI calls from the same thread or (b) explicitly synchronize each and every such
call with a lock.  In your case, on_search_button_clicked violates that principle.

If my understanding of the task at hand is correct, you are trying to initiate a thread with a button click.  That thread, in turn, would initiate a database access.  Once this completes, you want the string "Done" displayed in the GUI.  Is that correct?  If so, I suggest you take a look at Glib::Dispatcher

http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1Dispatcher.html

and use it to inform the GUI thread that the DB access is completed.

One more thing. Are you sure on_search_button_clicked() and search_db() are the right place for the show_all call?  Don't you want
it to be a part of your initialization logic, i.e. immediately after you are done setting up your widgets in the beginning?


Regards,

Nickolai


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