comparison libgui/src/main-window.cc @ 20091:89d843d6de14

Add mutex lock to shutdown confirmation for proper thread timing (bug #44751). * main-window.cc (main_window::confirm_shutdown_octave): Lock Qt link mutex before confirming shutdown thereby ensuring link is in sleep state. Unlock mutex after confirming shutdown, then awake all threads waiting on the mutex. * dialog.cc (QUIWidgetCreator::dialog_button_clicked): Block threads by locking mutex before setting dialog_button and dialog_result. Unlock mutex afterward. (QUIWidgetCreator::list_select_finished): Lock mutex before setting list_index and dialog_result. Unlock mutex afterward. (QUIWidgetCreator::input_finished): Lock mutex before setting string_list and dialog_result. Unlock mutex afterward. (QUIWidgetCreator::filedialog_finished): Lock mutex before setting path_name, string_list and dialog_result. Unlock mutex afterward. * libgui/src/dialog.h (QUIWidgetCreator::wait): Remove function and make the QMutex (mutex) and QWaitCondition (waitcondition) available to public. * octave-qt-link.cc (octave_qt_link::octave_qt_link): Move the octave_qt_link object affinity to the main_thread. (octave_qt_link::do_confirm_shutdown): Lock mutex before emitting signal so that GUI thread waits until mutex is free. Unlock the mutex after coming out of sleep state. (octave_qt_link::do_prompt_new_edit_file): Lock the uiwidget_creator mutex before emitting signal and go to sleep after emitting signal. Unlock mutex after mutually shared data has been read. (octave_qt_link::do_message_dialog): Ditto. (octave_qt_link::do_question_dialog): Ditto. (octave_qt_link::do_list_dialog): Ditto. (octave_qt_link::do_input_dialog): Ditto. (octave_qt_link::do_file_dialog): Ditto. (octave_qt_link::do_debug_cd_or_addpath_error): Ditto.
author Daniel J Sebald <daniel.sebald@ieee.org>
date Fri, 17 Apr 2015 00:38:40 -0500
parents 3538c2824dd8
children c36f2b083613
comparison
equal deleted inserted replaced
20090:c6c5cb9c4743 20091:89d843d6de14
792 if (closenow) 792 if (closenow)
793 closenow = editor_window->check_closing (); 793 closenow = editor_window->check_closing ();
794 #endif 794 #endif
795 } 795 }
796 796
797 // Wait for link thread to go to sleep state.
798 _octave_qt_link->mutex.lock ();
799
797 _octave_qt_link->shutdown_confirmation (closenow); 800 _octave_qt_link->shutdown_confirmation (closenow);
801
802 _octave_qt_link->mutex.unlock ();
798 803
799 // Awake the worker thread so that it continues shutting down (or not). 804 // Awake the worker thread so that it continues shutting down (or not).
800 _octave_qt_link->waitcondition.wakeAll (); 805 _octave_qt_link->waitcondition.wakeAll ();
806
801 } 807 }
802 808
803 void 809 void
804 main_window::prepare_to_exit (void) 810 main_window::prepare_to_exit (void)
805 { 811 {