chiark / gitweb /
Attempt to work around occasional crash in MainWindow where plot became NULL
authorRoss Younger <onyx-commits@impropriety.org.uk>
Mon, 4 Feb 2013 07:42:46 +0000 (20:42 +1300)
committerRoss Younger <onyx-commits@impropriety.org.uk>
Mon, 4 Feb 2013 07:42:46 +0000 (20:42 +1300)
gtkui/MainWindow.cpp
gtkui/MainWindow.h

index 2417dc5..a9ffb4b 100644 (file)
@@ -258,11 +258,12 @@ void MainWindow::do_resize(unsigned width, unsigned height)
 
                {
                        // It doesn't make sense to allow undo through a size change.
-                       gdk_threads_leave();
-                       delete plot_prev;
+                       Plot3Plot *del1 = plot_prev, *del2 = plot;
                        plot_prev = 0;
-                       delete plot;
                        plot = 0;
+                       gdk_threads_leave();
+                       delete del1;
+                       delete del2;
                        gdk_threads_enter();
                }
 
@@ -386,9 +387,17 @@ void MainWindow::pass_complete(std::string& commentary)
 
 void MainWindow::plot_complete()
 {
+       gdk_threads_enter();
+       real_plot_complete();
+       gdk_threads_leave();
+}
+
+void MainWindow::real_plot_complete()
+{
        struct timeval tv_after, tv_diff;
 
-       gdk_threads_enter();
+       if (!plot) return;
+
        progbar->pulse();
        gettimeofday(&tv_after,0);
 
@@ -416,7 +425,6 @@ void MainWindow::plot_complete()
 
        queue_draw();
        gdk_flush();
-       gdk_threads_leave();
 }
 
 void MainWindow::recolour()
index deb3fab..68d69b7 100644 (file)
@@ -171,6 +171,7 @@ private:
        bool on_timer();
        void png_save_completion();
        void destroy_image();
+       void real_plot_complete();
 
        ThreadPool _threadpool;
 public: