[patch] Memleaks and other stuff for gnome-build
- From: Gustavo Giráldez <gustavo giraldez gmx net>
- To: JP Rosevear <jpr ximian com>
- Cc: Gnome Devtools list <gnome-devtools gnome org>
- Subject: [patch] Memleaks and other stuff for gnome-build
- Date: 28 Aug 2002 10:33:28 -0300
Hi JP,
The attached patch plugs some memory leaks in the new gnome-build code
and fixes some other older stuff.
May I commit?
Thanks,
Gustavo
? .tm_project.cache
? autom4te.cache
? stamp-h1
? idl/Makefile
? idl/Makefile.in
? src/backends/libgbf_am/gbf-am-parse
? src/backends/libgbf_am/GBF/Makefile
? src/backends/libgbf_am/GBF/Makefile.in
? src/controls/gbf-project-model.c
? src/controls/gbf-project-model.h
? src/controls/gbf-project-tree.c.sort
? src/controls/gbf-project-view.c
? src/controls/gbf-project-view.h
? src/controls/test-project-view
? src/controls/test-project-view.c
? src/lib/gnome-build-common.c
? src/lib/gnome-build-skels.c
? src/lib/gnome-build-stubs.c
? src/lib/gnome-build.h
? src/lib/test
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-build/ChangeLog,v
retrieving revision 1.103
diff -u -r1.103 ChangeLog
--- ChangeLog 28 Aug 2002 10:15:15 -0000 1.103
+++ ChangeLog 28 Aug 2002 13:31:21 -0000
@@ -1,3 +1,22 @@
+2002-08-28 Gustavo Giráldez <gustavo giraldez gmx net>
+
+ * configure.in: Add BACKEND_DIR define instead of hardcoding it in
+ the source.
+
+ * src/backends/libgbf_am/gbf-am-parse.in
+ (remove_files_from_built_files): Escape substituted variable in
+ regular expression match.
+
+ * src/backends/libgbf_am/gbf-am-project.c (project_unload): Always
+ destroy project data.
+ (gbf_am_project_dispose): Free the private structure too.
+
+ * src/controls/test-controls.c:
+ * src/controls/test-controls.xml: Implement project close.
+
+ * src/lib/gbf-backend.c:
+ * src/lib/glue-factory.c: Plug some memleaks.
+
2002-08-28 Jeroen Zwartepoorte <jeroen xs4all nl>
* configure.in: Removed orbit, libbonobo dependencies and IDL configure
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gnome-build/configure.in,v
retrieving revision 1.28
diff -u -r1.28 configure.in
--- configure.in 28 Aug 2002 10:15:15 -0000 1.28
+++ configure.in 28 Aug 2002 13:31:22 -0000
@@ -121,6 +121,7 @@
# Set the path to the backends directory so we don't litter $(prefix)/lib :-)
gbf_backends_dir="${packageprefix}/lib/gnome-build/backends"
AC_SUBST(gbf_backends_dir)
+AC_DEFINE_UNQUOTED(BACKEND_DIR, "${packageprefix}/lib/gnome-build/backends", [Where to install backend modules])
AC_OUTPUT([
Makefile
Index: src/backends/libgbf_am/gbf-am-parse.in
===================================================================
RCS file: /cvs/gnome/gnome-build/src/backends/libgbf_am/gbf-am-parse.in,v
retrieving revision 1.1
diff -u -r1.1 gbf-am-parse.in
--- src/backends/libgbf_am/gbf-am-parse.in 12 Jul 2002 04:38:46 -0000 1.1
+++ src/backends/libgbf_am/gbf-am-parse.in 28 Aug 2002 13:31:27 -0000
@@ -1869,8 +1869,8 @@
$var = " $var ";
foreach my $target (keys %targets) {
foreach my $built_file (@{$targets{$target}{built_files}}) {
- if ($var =~ /\s$built_file\s/) {
- $var =~ s/\s$built_file\s/ /g;
+ if ($var =~ /\s\Q$built_file\E\s/) {
+ $var =~ s/\s\Q$built_file\E\s/ /g;
push @targets_found, "$target;$built_file";
};
};
Index: src/backends/libgbf_am/gbf-am-project.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/backends/libgbf_am/gbf-am-project.c,v
retrieving revision 1.26
diff -u -r1.26 gbf-am-project.c
--- src/backends/libgbf_am/gbf-am-project.c 27 Aug 2002 21:46:02 -0000 1.26
+++ src/backends/libgbf_am/gbf-am-project.c 28 Aug 2002 13:31:32 -0000
@@ -1601,9 +1601,6 @@
g_return_if_fail (prj != NULL);
priv = prj->priv;
- if (priv->project_dir == NULL)
- /* FIXME: any better way to determine if the project has data? */
- return;
priv->parent_group = NULL;
g_free (priv->project_dir);
@@ -2103,9 +2100,13 @@
project_unload (prj);
priv = prj->priv;
- if (priv->buffer) {
- g_free (priv->buffer);
- priv->buffer = NULL;
+ if (priv) {
+ if (priv->buffer) {
+ g_free (priv->buffer);
+ priv->buffer = NULL;
+ }
+ g_free (priv);
+ prj->priv = NULL;
}
GNOME_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
Index: src/backends/libgbf_am/test.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/backends/libgbf_am/test.c,v
retrieving revision 1.5
diff -u -r1.5 test.c
--- src/backends/libgbf_am/test.c 27 Aug 2002 21:46:02 -0000 1.5
+++ src/backends/libgbf_am/test.c 28 Aug 2002 13:31:32 -0000
@@ -13,12 +13,10 @@
gnome_program_init ("libgbf-am-test", VERSION, LIBGNOME_MODULE,
argc, argv, NULL);
-#if 0
- if (argc == 1) {
+ if (argc < 2) {
g_print ("you need to specify a project path\n");
return 0;
}
-#endif
g_print ("initializing gbf backend...\n");
gbf_backend_init ();
@@ -42,8 +40,8 @@
return 0;
}
- g_print ("loading project %s\n\n", ""/*argv[1]*/);
- GBF_PROJECT_GET_CLASS (project)->load (project, "/home/jeroen/Projects/gtksourceview", NULL);
+ g_print ("loading project %s\n\n", argv[1]);
+ GBF_PROJECT_GET_CLASS (project)->load (project, argv[1], NULL);
g_print ("*** Sources\n\n");
sources = GBF_PROJECT_GET_CLASS (project)->get_all_sources (project, NULL);
Index: src/controls/test-controls.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/controls/test-controls.c,v
retrieving revision 1.5
diff -u -r1.5 test-controls.c
--- src/controls/test-controls.c 27 Aug 2002 21:46:03 -0000 1.5
+++ src/controls/test-controls.c 28 Aug 2002 13:31:32 -0000
@@ -21,12 +21,16 @@
char *cname);
static void open_project (GtkWidget *widget,
gpointer user_data);
+static void close_cb (GtkWidget *widget,
+ gpointer user_data,
+ char *cname);
static void exit_cb (GtkWidget *widget,
gpointer user_data,
char *cname);
static BonoboUIVerb verbs[] = {
BONOBO_UI_UNSAFE_VERB ("FileOpen", open_cb),
+ BONOBO_UI_UNSAFE_VERB ("FileClose", close_cb),
BONOBO_UI_UNSAFE_VERB ("FileExit", exit_cb),
BONOBO_UI_VERB_END
};
@@ -102,11 +106,25 @@
}
g_print ("loading project %s\n\n", dirname);
+ /* FIXME: use the error parameter to determine if the project
+ * was loaded successfully */
GBF_PROJECT_GET_CLASS (proj)->load (proj, dirname, NULL);
g_object_set (G_OBJECT (project_tree), "project", proj, NULL);
/*g_object_set (G_OBJECT (target_tree), "project", proj, NULL);
g_object_set (G_OBJECT (build_info), "project", proj, NULL);*/
+}
+
+static void
+close_cb (GtkWidget *widget,
+ gpointer user_data,
+ char *cname)
+{
+ if (proj) {
+ g_object_unref (proj);
+ proj = NULL;
+ g_object_set (G_OBJECT (project_tree), "project", NULL, NULL);
+ }
}
static void
Index: src/controls/test-controls.xml
===================================================================
RCS file: /cvs/gnome/gnome-build/src/controls/test-controls.xml,v
retrieving revision 1.1
diff -u -r1.1 test-controls.xml
--- src/controls/test-controls.xml 3 Jan 2002 14:54:38 -0000 1.1
+++ src/controls/test-controls.xml 28 Aug 2002 13:31:32 -0000
@@ -1,6 +1,7 @@
<Root>
<commands>
<cmd name="FileOpen" stockid="gtk-open" priority="1"/>
+ <cmd name="FileClose" stockid="gtk-close" priority="0"/>
<cmd name="FileExit" stockid="gtk-quit"/>
<cmd name="HelpAbout" _label="_About..."
@@ -11,6 +12,7 @@
<menu>
<submenu name="File" _label="_File">
<menuitem name="FileOpen" verb=""/>
+ <menuitem name="FileClose" verb=""/>
<menuitem name="FileExit" verb=""/>
</submenu>
@@ -22,6 +24,7 @@
<dockitem name="Toolbar" relief="none" homogeneous="1"
behavior="exclusive" look="text">
<toolitem name="FileOpen" verb=""/>
+ <toolitem name="FileClose" verb=""/>
<toolitem name="FileExit" verb=""/>
<placeholder/>
</dockitem>
Index: src/lib/gbf-backend.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/lib/gbf-backend.c,v
retrieving revision 1.1
diff -u -r1.1 gbf-backend.c
--- src/lib/gbf-backend.c 27 Aug 2002 21:46:04 -0000 1.1
+++ src/lib/gbf-backend.c 28 Aug 2002 13:31:33 -0000
@@ -22,11 +22,9 @@
#include <dirent.h>
#include <string.h>
#include <libxml/tree.h>
-#include "glue-factory.h"
+#include "glue-factory.h"
#include "gbf-backend.h"
-#define BACKEND_DIR PREFIX "/lib/gnome-build/backends"
-
static GList *plugin_dirs = NULL;
static GSList *available_backends = NULL;
static GHashTable *backends_by_name = NULL;
@@ -101,7 +99,7 @@
xmlNodePtr attr;
GHashTable *attributes;
- attributes = g_hash_table_new (g_str_hash, g_str_equal);
+ attributes = g_hash_table_new_full (g_str_hash, g_str_equal, xmlFree, xmlFree);
for (attr = backend->children; attr != NULL; attr = attr->next) {
char *type = xmlGetProp (attr, "type");
@@ -122,6 +120,7 @@
} else {
g_warning ("Missing name or value in attribute");
}
+ xmlFree (type);
}
}
@@ -145,6 +144,7 @@
str = xmlGetProp (plugin, "location");
if (str) {
backend->id = g_strdup (str);
+ xmlFree (str);
} else {
g_warning ("Couldn't find 'location'");
success = FALSE;
@@ -207,15 +207,17 @@
if ((root = xmlDocGetRootElement (doc)) == NULL) {
g_warning ("%s is not a valid backend description file", path);
- xmlFreeDoc (doc);
- return;
- }
-
- for (backend = root->children; backend != NULL; backend = backend->next) {
- if (xmlGetProp (backend, "location")) {
- load_backend (backend);
+ } else {
+ for (backend = root->children; backend != NULL; backend = backend->next) {
+ xmlChar *location = xmlGetProp (backend, "location");
+ if (location) {
+ load_backend (backend);
+ xmlFree (location);
+ }
}
}
+
+ xmlFreeDoc (doc);
}
static void
@@ -242,6 +244,8 @@
g_free (pathname);
}
}
+
+ closedir (dir);
}
static void
Index: src/lib/glue-factory.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/lib/glue-factory.c,v
retrieving revision 1.1
diff -u -r1.1 glue-factory.c
--- src/lib/glue-factory.c 27 Aug 2002 21:46:04 -0000 1.1
+++ src/lib/glue-factory.c 28 Aug 2002 13:31:33 -0000
@@ -170,6 +170,7 @@
/* We have found a matching module */
plugin_path = g_module_build_path (entry->path, plugin_name);
module = g_module_open (plugin_path, 0);
+ g_free (plugin_path);
if (module == NULL)
{
g_print ("couldn't open module: %s\n", g_module_error ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]