Miscellaneous bug fixes
authorAndy Spencer <andy753421@gmail.com>
Sat, 1 May 2010 07:17:04 +0000 (07:17 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sat, 1 May 2010 08:00:38 +0000 (08:00 +0000)
- Lots of plugged memory leaks
- Lots of small improvements

src/.vimrc
src/Makefile.am
src/data/gis-http.c
src/gis-opengl.c
src/gis-plugin.c
src/gis-prefs.c
src/gis-test.c
src/gtk.suppression
src/plugins/map.c
src/plugins/sat.c

index b071c55..01772fa 100644 (file)
@@ -1,4 +1,5 @@
 set makeprg=make\ test
 set tw=100
-au FileType valgrind syn match gisFile "\v<(gis-\w+|elev|env|map|sat|test)\.c>" containedin=valgrindSrc
+
+au FileType valgrind syn match gisFile "\v<(gis-\w+|roam|elev|env|map|sat|test|radar)\.c>" containedin=valgrindSrc
 au FileType valgrind hi link gisFile Error
index 17c04a6..1673dff 100644 (file)
@@ -45,22 +45,25 @@ libgis_la_LIBADD  = $(AM_LDADD) \
 
 # Demo program
 if NOTWIN32
-AM_LDFLAGS += -static
+BINLDFLAGS = -static
 endif
 
 bin_PROGRAMS = gis-demo
 
 gis_demo_SOURCES  = gis-demo.c
 gis_demo_LDADD    = $(AM_LDADD) libgis.la
+gis_demo_LDFLAGS  = $(BINLDFLAGS)
 
 # Test programs
 noinst_PROGRAMS = gis-test tile-test
 
 gis_test_SOURCES = gis-test.c
 gis_test_LDADD   = $(AM_LDADD) libgis.la
+gis_test_LDFLAGS  = $(BINLDFLAGS)
 
 tile_test_SOURCES = tile-test.c
 tile_test_LDADD   = $(AM_LDADD) libgis.la
+tile_test_LDFLAGS = $(BINLDFLAGS)
 
 
 MAINTAINERCLEANFILES = Makefile.in
index b5259e4..b610fa3 100644 (file)
@@ -123,8 +123,7 @@ static void _chunk_cb(SoupMessage *message, SoupBuffer *chunk, gpointer _info)
 gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
                GisCacheType mode, GisChunkCallback callback, gpointer user_data)
 {
-       g_debug("GisHttp: fetch - %s... >> %s/%s  mode=%d",
-                       uri, http->prefix, local, mode);
+       g_debug("GisHttp: fetch - %s mode=%d", local, mode);
        gchar *path = _get_cache_path(http, local);
 
        /* Unlink the file if we're refreshing it */
@@ -218,6 +217,7 @@ GList *gis_http_available(GisHttp *http,
                        if (g_regex_match(filter_re, file, 0, NULL))
                                files = g_list_prepend(files, g_strdup(file));
                g_free(path);
+               g_dir_close(dir);
        }
 
        /* Add online files if online */
@@ -243,11 +243,14 @@ GList *gis_http_available(GisHttp *http,
                        g_match_info_next(info, NULL);
                }
 
+               g_regex_unref(extract_re);
                g_match_info_free(info);
                g_unlink(path);
                g_free(path);
                g_free(html);
        }
 
+       g_regex_unref(filter_re);
+
        return files;
 }
index dc32fa8..fc0c55e 100644 (file)
@@ -187,7 +187,6 @@ static void _draw_tile(GisOpenGL *opengl, GisTile *tile, GList *triangles)
                glNormal3dv(tri->p.l->norm); glTexCoord2dv(xy[2]); glVertex3dv((double*)tri->p.l);
                glEnd();
        }
-       g_list_free(triangles);
 }
 
 static void _draw_tiles(GisOpenGL *opengl, GisTile *tile)
@@ -218,7 +217,8 @@ static void _draw_tiles(GisOpenGL *opengl, GisTile *tile)
                                const gdouble s = tile->edge.n-(lat_step*(row+1));
                                const gdouble e = tile->edge.w+(lon_step*(col+1));
                                const gdouble w = tile->edge.w+(lon_step*(col+0));
-                               GList *these = roam_sphere_get_intersect(opengl->sphere, FALSE, n, s, e, w);
+                               GList *these = roam_sphere_get_intersect(opengl->sphere,
+                                               FALSE, n, s, e, w);
                                triangles = g_list_concat(triangles, these);
                        }
                }
@@ -228,6 +228,7 @@ static void _draw_tiles(GisOpenGL *opengl, GisTile *tile)
        }
        if (triangles)
                _draw_tile(opengl, tile, triangles);
+       g_list_free(triangles);
 }
 
 static void _draw_marker(GisOpenGL *opengl, GisMarker *marker)
@@ -321,7 +322,7 @@ static void _draw_object(GisOpenGL *opengl, GisObject *object)
 
 static void _load_object(GisOpenGL *opengl, GisObject *object)
 {
-       g_debug("GisOpenGL: load_object");
+       //g_debug("GisOpenGL: load_object");
        if (GIS_IS_MARKER(object)) {
                GisMarker *marker = GIS_MARKER(object);
                cairo_surface_t *surface = cairo_get_target(marker->cairo);
@@ -338,13 +339,13 @@ static void _load_object(GisOpenGL *opengl, GisObject *object)
                                cairo_image_surface_get_data(surface));
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-               g_debug("load_texture: %d", marker->tex);
+               //g_debug("load_texture: %d", marker->tex);
        }
 }
 
 static void _unload_object(GisOpenGL *opengl, GisObject *object)
 {
-       g_debug("GisOpenGL: unload_object");
+       //g_debug("GisOpenGL: unload_object");
        if (GIS_IS_MARKER(object)) {
                GisMarker *marker = GIS_MARKER(object);
                glDeleteTextures(1, &marker->tex);
index 2a592d6..537400e 100644 (file)
@@ -201,6 +201,13 @@ GList *gis_plugins_available(GisPlugins *plugins)
                }
                g_dir_close(dir);
        }
+       list = g_list_sort(list, (GCompareFunc)g_strcmp0);
+       for (GList *cur = list; cur; cur = cur->next)
+               while (cur->next && g_str_equal(cur->data,cur->next->data)) {
+                       GList *tmp = cur->next;
+                       list = g_list_remove_link(list, cur);
+                       cur = tmp;
+               }
        return list;
 }
 
index 2eb5b4d..fb111e6 100644 (file)
@@ -95,8 +95,9 @@ c_type gis_prefs_get_##name##_v(GisPrefs *prefs,
 {                                                                                    \
        GError *error = NULL;                                                        \
        c_type value = g_key_file_get_##name(prefs->key_file, group, key, &error);   \
-       if (error && error->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND)                \
-               g_warning("GisPrefs: get_value_##name - error getting key %s: %s\n", \
+       if (error && error->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND &&              \
+                    error->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND)                  \
+               g_warning("GisPrefs: get_"#name" - error getting key %s: %s\n",      \
                                key, error->message);                                \
        if (error && _error)                                                         \
                *_error = error;                                                     \
index 53df1ea..6366ade 100644 (file)
@@ -52,6 +52,13 @@ static gboolean on_key_press(GtkWidget *widget, GdkEventKey *event,
                return gis_shutdown(widget);
        return FALSE;
 }
+static void load_plugin(GisPlugins *plugins, gchar *name,
+               GisViewer *viewer, GisPrefs *prefs, GtkNotebook *notebook)
+{
+       GisPlugin *plugin = gis_plugins_load(plugins, name, viewer, prefs);
+       GtkWidget *config = gis_plugin_get_config(plugin);
+       gtk_notebook_append_page(notebook, config, gtk_label_new(name));
+}
 
 /***********
  * Methods *
@@ -69,21 +76,29 @@ int main(int argc, char **argv)
 
        gdk_threads_enter();
        GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       GtkWidget *vbox   = gtk_vbox_new(FALSE, 0);
+       GtkWidget *config = gtk_notebook_new();
        g_signal_connect(window, "delete-event",    G_CALLBACK(on_delete),    NULL);
        g_signal_connect(window, "key-press-event", G_CALLBACK(on_key_press), NULL);
-       gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(viewer));
+       gtk_notebook_set_tab_pos(GTK_NOTEBOOK(config), GTK_POS_BOTTOM);
+       gtk_container_add(GTK_CONTAINER(window), vbox);
+       gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(viewer), TRUE,  TRUE,  0);
+       gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(config), FALSE, FALSE, 0);
        gtk_widget_show_all(window);
 
+       /* Configurable stuff */
+       gis_viewer_set_offline(viewer, TRUE);
+       //load_plugin(plugins, "elev",  viewer, prefs, GTK_NOTEBOOK(config));
+       //load_plugin(plugins, "env",   viewer, prefs, GTK_NOTEBOOK(config));
+       //load_plugin(plugins, "map",   viewer, prefs, GTK_NOTEBOOK(config));
+       load_plugin(plugins, "sat",   viewer, prefs, GTK_NOTEBOOK(config));
+       //load_plugin(plugins, "test",  viewer, prefs, GTK_NOTEBOOK(config));
+       load_plugin(plugins, "radar", viewer, prefs, GTK_NOTEBOOK(config));
 
-       /* elev env map sat test */
-       gis_plugins_load(plugins, "elev",  viewer, prefs);
-       gis_plugins_load(plugins, "env",   viewer, prefs);
-       gis_plugins_load(plugins, "map",   viewer, prefs);
-       gis_plugins_load(plugins, "sat",   viewer, prefs);
-       gis_plugins_load(plugins, "test",  viewer, prefs);
-
+       gtk_widget_show_all(config);
        gtk_main();
-
        gdk_threads_leave();
+
+       gdk_display_close(gdk_display_get_default());
        return 0;
 }
index 1b53be4..b7d9a31 100644 (file)
        ...
        fun:gtk_icon_theme_has_icon
 }
-#{
-#      gtk_icon_theme_get
-#      Memcheck:Leak
-#      ...
-#      fun:gtk_icon_theme_get*
-#}
-#{
-#      gtk_icon_factory_lookup
-#      Memcheck:Leak
-#      ...
-#      fun:gtk_icon_factory_lookup*
-#}
+{
+       gtk_icon_source_copy
+       Memcheck:Leak
+       ...
+       fun:gtk_icon_source_copy
+}
+{
+       gtk_icon_theme_get
+       Memcheck:Leak
+       ...
+       fun:gtk_icon_theme_get*
+}
+{
+       gtk_icon_factory_lookup
+       Memcheck:Leak
+       ...
+       fun:gtk_icon_factory_lookup*
+}
 {
        gxk__for_display
        Memcheck:Leak
index a0f28dc..4be4607 100644 (file)
@@ -127,7 +127,8 @@ static void _free_tile(GisTile *tile, gpointer _map)
 {
        GisPluginMap *map = _map;
        g_debug("GisPluginMap: _free_tile: %p", tile->data);
-       g_idle_add_full(G_PRIORITY_LOW, _free_tile_cb, tile->data, NULL);
+       if (tile->data)
+               g_idle_add_full(G_PRIORITY_LOW, _free_tile_cb, tile->data, NULL);
 }
 
 static gpointer _update_tiles(gpointer _map)
index 9e1af30..5dc3c85 100644 (file)
@@ -117,8 +117,9 @@ static gboolean _free_tile_cb(gpointer data)
 static void _free_tile(GisTile *tile, gpointer _sat)
 {
        GisPluginSat *sat = _sat;
-       g_debug("GisPluginSat: _free_tile: %p=%d", tile->data, *(guint*)tile->data);
-       g_idle_add_full(G_PRIORITY_LOW, _free_tile_cb, tile->data, NULL);
+       g_debug("GisPluginSat: _free_tile: %p", tile->data);
+       if (tile->data)
+               g_idle_add_full(G_PRIORITY_LOW, _free_tile_cb, tile->data, NULL);
 }
 
 static gpointer _update_tiles(gpointer _sat)