summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-02-05 23:38:19 +0000
committerDavid Robillard <d@drobilla.net>2015-02-05 23:38:19 +0000
commit3d7cca74006eee42c9f8b6dfd23cb61d74a91945 (patch)
tree431b2c9ca3e96ad5864d6d418a8d1d5d7d271d5a
parentc0a1feeefee2e6d64b61d400656cb4aafdd594bd (diff)
downloadganv-3d7cca74006eee42c9f8b6dfd23cb61d74a91945.tar.gz
ganv-3d7cca74006eee42c9f8b6dfd23cb61d74a91945.tar.bz2
ganv-3d7cca74006eee42c9f8b6dfd23cb61d74a91945.zip
Fix crash when destroying canvas.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5532 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--NEWS3
-rw-r--r--src/Canvas.cpp10
2 files changed, 11 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index bfa3ab2..e6ea402 100644
--- a/NEWS
+++ b/NEWS
@@ -3,8 +3,9 @@ ganv (1.4.3) unstable;
* Fix positioning of embedded widgets when changing layout.
* Fix unexpected node jumping when dragging new connections.
* Fix compilation with --no-fdgl (patch from Vlad Glagolev).
+ * Fix crash when destroying canvas.
- -- David Robillard <d@drobilla.net> Fri, 07 Nov 2014 13:12:49 -0500
+ -- David Robillard <d@drobilla.net> Thu, 05 Feb 2015 18:32:13 -0500
ganv (1.4.2) stable;
diff --git a/src/Canvas.cpp b/src/Canvas.cpp
index 6b16230..02bf4f6 100644
--- a/src/Canvas.cpp
+++ b/src/Canvas.cpp
@@ -252,7 +252,7 @@ struct GanvCanvasImpl {
this->sprung_layout = FALSE;
#endif
- _animate_idle_id = g_timeout_add(120, on_animate_timeout, this);
+ _animate_idle_id = 0;
gtk_layout_set_hadjustment(GTK_LAYOUT(canvas), NULL);
gtk_layout_set_vadjustment(GTK_LAYOUT(canvas), NULL);
@@ -1627,6 +1627,9 @@ gboolean
GanvCanvasImpl::on_animate_timeout(gpointer data)
{
GanvCanvasImpl* impl = (GanvCanvasImpl*)data;
+ if (!impl->pixmap_gc) {
+ return FALSE; // Unrealized
+ }
const double seconds = get_monotonic_time() / 1000000.0;
@@ -2781,6 +2784,9 @@ ganv_canvas_realize(GtkWidget* widget)
canvas->impl->pixmap_gc = gdk_gc_new(canvas->layout.bin_window);
(*GANV_ITEM_GET_CLASS(canvas->impl->root)->realize)(canvas->impl->root);
+
+ canvas->impl->_animate_idle_id = g_timeout_add(
+ 120, GanvCanvasImpl::on_animate_timeout, canvas->impl);
}
/* Unrealize handler for the canvas */
@@ -2791,6 +2797,8 @@ ganv_canvas_unrealize(GtkWidget* widget)
GanvCanvas* canvas = GANV_CANVAS(widget);
+ while (g_idle_remove_by_data(canvas->impl)) {}
+
shutdown_transients(canvas);
/* Unrealize items and parent widget */