[grits] Fix race conditions



commit fb8e4db7bd22e6723a6e22b8f5de52d5c8bcc334
Author: Andy Spencer <andy753421 gmail com>
Date:   Wed Dec 26 08:53:29 2012 +0000

    Fix race conditions

 src/plugins/elev.c |    4 ++++
 src/plugins/map.c  |    7 ++++++-
 src/plugins/sat.c  |    4 ++++
 3 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/elev.c b/src/plugins/elev.c
index d359d1d..7540a08 100644
--- a/src/plugins/elev.c
+++ b/src/plugins/elev.c
@@ -154,6 +154,10 @@ static gboolean _load_tile_cb(gpointer _data)
 	struct _LoadTileData *data  = _data;
 	struct _TileData     *tdata = data->tdata;
 	g_debug("GritsPluginElev: _load_tile_cb start");
+	if (data->elev->aborted) {
+		g_debug("GritsPluginElev: _load_tile - aborted");
+		return FALSE;
+	}
 
 	/* Load OpenGL texture (from main thread) */
 	if (data->pixels) {
diff --git a/src/plugins/map.c b/src/plugins/map.c
index c57bae8..bb585e1 100644
--- a/src/plugins/map.c
+++ b/src/plugins/map.c
@@ -57,6 +57,10 @@ static gboolean _load_tile_cb(gpointer _data)
 {
 	struct _LoadTileData *data = _data;
 	g_debug("GritsPluginMap: _load_tile_cb start");
+	if (data->map->aborted) {
+		g_debug("GritsPluginMap: _load_tile - aborted");
+		return FALSE;
+	}
 
 	guint *tex = g_new0(guint, 1);
 	glGenTextures(1, tex);
@@ -73,7 +77,8 @@ static gboolean _load_tile_cb(gpointer _data)
 	glFlush();
 
 	data->tile->data = tex;
-	gtk_widget_queue_draw(GTK_WIDGET(data->map->viewer));
+	if (data->map->viewer)
+		gtk_widget_queue_draw(GTK_WIDGET(data->map->viewer));
 	g_free(data->pixels);
 	g_free(data);
 	return FALSE;
diff --git a/src/plugins/sat.c b/src/plugins/sat.c
index 9b10a2d..d9d0891 100644
--- a/src/plugins/sat.c
+++ b/src/plugins/sat.c
@@ -46,6 +46,10 @@ static gboolean _load_tile_cb(gpointer _data)
 {
 	struct _LoadTileData *data = _data;
 	g_debug("GritsPluginSat: _load_tile_cb start");
+	if (data->sat->aborted) {
+		g_debug("GritsPluginSat: _load_tile - aborted");
+		return FALSE;
+	}
 
 	guint *tex = g_new0(guint, 1);
 	glGenTextures(1, tex);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]