diff libgui/src/dialog.h @ 20126: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 4197fc428c7d
children dd327c0909b0
line wrap: on
line diff
--- a/libgui/src/dialog.h	Fri Apr 17 18:16:51 2015 -0700
+++ b/libgui/src/dialog.h	Fri Apr 17 00:38:40 2015 -0500
@@ -114,11 +114,11 @@
 
   const QString *get_dialog_path (void) { return path_name; }
 
-  void wait (void)
-  {
-    // Wait while the user is responding to message box.
-    waitcondition.wait (&mutex);
-  }
+  // GUI objects cannot be accessed in the non-GUI thread.  However,
+  // signals can be sent to slots across threads with proper
+  // synchronization.  Hence, the use of QWaitCondition.
+  QMutex mutex;
+  QWaitCondition waitcondition;
 
 signals:
 
@@ -159,13 +159,6 @@
 
   QString *path_name;
 
-  // GUI objects cannot be accessed in the non-GUI thread.  However,
-  // signals can be sent to slots across threads with proper
-  // synchronization.  Hence, the use of QWaitCondition.
-
-  QMutex mutex;
-
-  QWaitCondition waitcondition;
 };
 
 extern QUIWidgetCreator uiwidget_creator;