]> Pileus Git - grits/blobdiff - src/grits-opengl.c
Move threading out of tile update/gc functions
[grits] / src / grits-opengl.c
index 49a9c533015d9413c5f9d28fb67aae432beafb71..90e830b1e30f3c1923f9a1a52758f34834f60b0b 100644 (file)
@@ -371,8 +371,10 @@ static gboolean on_expose(GritsOpenGL *opengl, GdkEventExpose *event, gpointer _
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
 #ifndef ROAM_DEBUG
+       g_mutex_lock(&opengl->sphere_lock);
        roam_sphere_update_errors(opengl->sphere);
        roam_sphere_split_merge(opengl->sphere);
+       g_mutex_unlock(&opengl->sphere_lock);
 #endif
 
 #ifdef ROAM_DEBUG
@@ -618,6 +620,7 @@ static void grits_opengl_add(GritsViewer *_opengl, GritsObject *object,
                list->next->prev = link;
        list->next = link;
        object->ref = link;
+       g_object_ref(object);
        g_mutex_unlock(&opengl->objects_lock);
 }
 
@@ -625,6 +628,8 @@ void grits_opengl_remove(GritsViewer *_opengl, GritsObject *object)
 {
        g_assert(GRITS_IS_OPENGL(_opengl));
        GritsOpenGL *opengl = GRITS_OPENGL(_opengl);
+       if (!object->ref)
+               return;
        g_mutex_lock(&opengl->objects_lock);
        GList *link = object->ref;
        /* Just unlink and free it, link->prev is assured */
@@ -632,6 +637,8 @@ void grits_opengl_remove(GritsViewer *_opengl, GritsObject *object)
        if (link->next)
                link->next->prev = link->prev;
        g_free(link);
+       object->ref = NULL;
+       g_object_unref(object);
        g_mutex_unlock(&opengl->objects_lock);
 }