fix import-thread SNAFU
authorRobin Gareus <robin@gareus.org>
Sat, 21 May 2016 21:30:11 +0000 (23:30 +0200)
committerRobin Gareus <robin@gareus.org>
Sat, 21 May 2016 21:30:11 +0000 (23:30 +0200)
 * pressing Esc or WM close button did not cancel import thread
 * proper Abort does not wait for import thread either

It was possible to launch a 2nd (and Nth) import thread, all sharing
the Editor's ImportStatus data-structure, all having the same
registered thread-name and same thread-pool name.  Plenty of room for
crashes.

gtk2_ardour/editor_audio_import.cc
gtk2_ardour/interthread_progress_window.cc
gtk2_ardour/interthread_progress_window.h

index ced2e7cb3d7826436dcd45195f0cc579939955ce..e35e566dee96c9f2cadc639fc42f8d808970b32b 100644 (file)
@@ -507,7 +507,10 @@ Editor::import_sndfiles (vector<string>            paths,
                gtk_main_iteration ();
        }
 
-       import_status.done = true;
+       // wait for thread to terminate
+       while (!import_status.done) {
+               gtk_main_iteration ();
+       }
 
        int result = -1;
 
index e63bf629a9e4d012b27ab41dbe0c28503f948d11..2f64644d5d195d819ca6145192e30f7262a9c897 100644 (file)
@@ -55,6 +55,14 @@ InterthreadProgressWindow::InterthreadProgressWindow (ARDOUR::InterThreadInfo* i
        Glib::signal_timeout().connect (sigc::mem_fun (*this, &InterthreadProgressWindow::update), 100);
 }
 
+void
+InterthreadProgressWindow::on_hide ()
+{
+       if (!_interthread_info->done) {
+               _interthread_info->cancel = true;
+       }
+}
+
 void
 InterthreadProgressWindow::cancel_clicked ()
 {
index 653ec4642071b71c314f25668fcaa7a8f5e2bf71..ee7b58ee16cce61492c230bbb1260a60fb201b93 100644 (file)
@@ -42,6 +42,7 @@ public:
 protected:
 
        virtual bool update ();
+       virtual void on_hide ();
 
        Gtk::Button _cancel_button;
        Gtk::Label _cancel_label;