gnome-scan r509 - in trunk: . lib src
- From: bersace svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-scan r509 - in trunk: . lib src
- Date: Tue, 26 Feb 2008 13:34:06 +0000 (GMT)
Author: bersace
Date: Tue Feb 26 13:34:06 2008
New Revision: 509
URL: http://svn.gnome.org/viewvc/gnome-scan?rev=509&view=rev
Log:
Fixed buffer leaks.
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/lib/gnome-scan-dialog.c
trunk/lib/gnome-scan-init.h
trunk/lib/gnome-scan-job.c
trunk/lib/gnome-scan-plugin.h
trunk/src/flegita-sink.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Tue Feb 26 13:34:06 2008
@@ -6,6 +6,13 @@
Gnome Scan aim to provide a sane scan infrastructure. Flegita provide
app and plugin on top of Gnome Scan for the desktop.
+Changes in version 0.5.93
+=========================
+
+ * Use a waiting cursor while probing.
+
+ * Fixed buffer leaks.
+
Changes in version 0.5.92
=========================
Modified: trunk/lib/gnome-scan-dialog.c
==============================================================================
--- trunk/lib/gnome-scan-dialog.c (original)
+++ trunk/lib/gnome-scan-dialog.c Tue Feb 26 13:34:06 2008
@@ -1288,7 +1288,7 @@
g_warning (G_STRLOC ": preview failed");
return FALSE;
}
-
+
gnome_scan_preview_area_set_pixbuf (GNOME_SCAN_PREVIEW_AREA (priv->preview_area),
pixbuf,
PREVIEW_RES);
@@ -1311,7 +1311,7 @@
}
static void
- gsd_preview_refresh (GtkButton *button, GnomeScanDialog *gsd)
+gsd_preview_refresh (GtkButton *button, GnomeScanDialog *gsd)
{
static GdkPoint origin = {0, 0};
GnomeScanDialogPrivate *priv = GET_PRIVATE (gsd);
@@ -1368,7 +1368,7 @@
static void
- gsd_preview_cancel_refresh (GtkButton *button, GnomeScanDialog *gsd)
+gsd_preview_cancel_refresh (GtkButton *button, GnomeScanDialog *gsd)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (gsd);
@@ -1379,7 +1379,7 @@
static void
- gsd_build_preview_ui (GnomeScanDialog *gsd)
+gsd_build_preview_ui (GnomeScanDialog *gsd)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (gsd);
GtkWidget *box, *hbox, *vbox, *alignment, *child, *scrolled;
Modified: trunk/lib/gnome-scan-init.h
==============================================================================
--- trunk/lib/gnome-scan-init.h (original)
+++ trunk/lib/gnome-scan-init.h Tue Feb 26 13:34:06 2008
@@ -22,7 +22,6 @@
#include <glib-object.h>
#define GS_STOCK_SCAN "scan"
-#define REFDBG(o) g_debug(G_STRLOC " %s ref count = %i", #o, G_OBJECT(o)->ref_count)
G_BEGIN_DECLS
Modified: trunk/lib/gnome-scan-job.c
==============================================================================
--- trunk/lib/gnome-scan-job.c (original)
+++ trunk/lib/gnome-scan-job.c Tue Feb 26 13:34:06 2008
@@ -51,9 +51,10 @@
GSList *processors;
GnomeScanSink *sink;
- GeglNode *gegl_root;
+ GeglNode *root;
GeglNode *gegl_convert;
GeglNode *gegl_sink;
+ GList *nodes;
GeglProcessor *gegl_processor;
gboolean ready;
};
@@ -64,15 +65,13 @@
PROP_SETTINGS,
PROP_SCANNER,
PROP_SINK
- };
+};
static GObjectClass* parent_class = NULL;
G_DEFINE_TYPE (GnomeScanJob, gnome_scan_job, G_TYPE_OBJECT);
-static void gsj_stop (GnomeScanJob *job);
-
static void
gnome_scan_job_init (GnomeScanJob *object)
{
@@ -350,24 +349,32 @@
gnome_scan_plugin_configure (GNOME_SCAN_PLUGIN (priv->sink),
priv->settings);
+ priv->ready = TRUE;
+}
+
+void
+gsj_build_pipeline(GnomeScanJob *job)
+{
+ GnomeScanJobPrivate *priv = GET_PRIVATE(job);
GList *node, *node0;
GSList *snode;
+ GeglNode *root;
gchar *op0, *op1;
- priv->gegl_root = gegl_node_new ();
+ priv->root = root = gegl_node_new();
/* scanner */
node0 = node = gnome_scan_plugin_get_child_nodes (GNOME_SCAN_PLUGIN (priv->scanner),
- priv->gegl_root);
+ root);
/* processing */
for (snode = priv->processors; snode; snode = snode->next) {
gnome_scan_plugin_configure(GNOME_SCAN_PLUGIN(snode->data), priv->settings);
node = g_list_concat (node,
gnome_scan_plugin_get_child_nodes (GNOME_SCAN_PLUGIN (snode->data),
- priv->gegl_root));
+ root));
}
/* convert */
- priv->gegl_convert = gegl_node_new_child(priv->gegl_root,
+ priv->gegl_convert = gegl_node_new_child(root,
"operation", "convert-format",
NULL);
node = g_list_append (node, priv->gegl_convert);
@@ -375,22 +382,34 @@
/* sink */
node = g_list_concat (node,
gnome_scan_plugin_get_child_nodes (GNOME_SCAN_PLUGIN (priv->sink),
- priv->gegl_root));
+ root));
for (node = node0; node->next ; node = node->next) {
gegl_node_get (node->data, "operation", &op0, NULL);
gegl_node_get (node->next->data, "operation", &op1, NULL);
- g_debug (G_STRLOC ": linking %s to %s", op0, op1);
+ g_debug ("Connecting %s to %s", op0, op1);
g_free (op0);
g_free (op1);
gegl_node_connect_to (node->data, "output",
node->next->data, "input");
}
- priv->gegl_sink = node->data;
- g_list_free (node0);
- priv->ready = TRUE;
+ priv->gegl_sink = g_object_ref(node->data);
+ priv->nodes = node0;
+}
+
+void
+gsj_destroy_pipeline(GnomeScanJob *job)
+{
+ GnomeScanJobPrivate *priv = GET_PRIVATE(job);
+
+ if (!priv->root)
+ return;
+ g_object_unref(priv->root);
+ priv->root = NULL;
+ g_list_free(priv->nodes);
+ priv->nodes = NULL;
}
/**
@@ -416,28 +435,31 @@
while (gnome_scan_job_run_once (job))
count++;
+ /* unconfigure */
gnome_scan_plugin_end_scan (GNOME_SCAN_PLUGIN (priv->sink));
/* finish */
job->progress = 1.;
job->stage = _("Job completed");
job->done = TRUE;
-
}
-#define NOP g_usleep(2 * 1000000)
gboolean
gnome_scan_job_run_once (GnomeScanJob *job)
{
GnomeScanJobPrivate *priv = GET_PRIVATE (job);
gdouble progress = 0.;
-#define stop(job) if(job->stop){gsj_stop(job);return FALSE;}
+#define stop(job) if(job->stop){gsj_destroy_pipeline(job);return FALSE;}
job->stage = _("Waiting for device");
- if (!gnome_scan_plugin_start_frame (GNOME_SCAN_PLUGIN (priv->scanner)))
+ gsj_build_pipeline(job);
+
+ if (!gnome_scan_plugin_start_frame (GNOME_SCAN_PLUGIN (priv->scanner))) {
+ gsj_destroy_pipeline(job);
return FALSE;
+ }
gegl_node_set (priv->gegl_convert,
"format", gnome_scanner_get_output_format (priv->scanner),
@@ -473,8 +495,10 @@
job->stage = _("Outputting page");
progress = 0.;
- if (!gnome_scan_plugin_start_frame (GNOME_SCAN_PLUGIN (priv->sink)))
+ if (!gnome_scan_plugin_start_frame (GNOME_SCAN_PLUGIN (priv->sink))) {
+ gsj_destroy_pipeline(job);
return FALSE;
+ }
while (!job->stop && gnome_scan_plugin_work (GNOME_SCAN_PLUGIN (priv->sink), &progress)) {
job->progress = .66 + progress / 3;
@@ -486,10 +510,12 @@
job->progress = 1.;
+ gsj_destroy_pipeline(job);
+
#undef stop
+
return TRUE;
}
-#undef NOP
/**
* gnome_scan_job_cancel:
@@ -503,13 +529,3 @@
job->stop = TRUE;
}
-
-static void
-gsj_stop (GnomeScanJob *job)
-{
- GnomeScanJobPrivate *priv = GET_PRIVATE (job);
- gegl_processor_destroy (priv->gegl_processor);
- g_object_unref (priv->gegl_sink);
- g_object_unref (priv->gegl_root);
- priv->ready = FALSE;
-}
Modified: trunk/lib/gnome-scan-plugin.h
==============================================================================
--- trunk/lib/gnome-scan-plugin.h (original)
+++ trunk/lib/gnome-scan-plugin.h Tue Feb 26 13:34:06 2008
@@ -30,6 +30,8 @@
#include "gnome-scan-plugin.h"
#include "gnome-scan-settings.h"
+#define REFDBG(o) g_debug(G_STRLOC " %s ref count = %i", #o, G_OBJECT(o)->ref_count)
+
G_BEGIN_DECLS
#define GNOME_TYPE_SCAN_PLUGIN (gnome_scan_plugin_get_type ())
Modified: trunk/src/flegita-sink.c
==============================================================================
--- trunk/src/flegita-sink.c (original)
+++ trunk/src/flegita-sink.c Tue Feb 26 13:34:06 2008
@@ -447,11 +447,8 @@
sink->count+1,
sink->suffix);
-#define dbg_ref(t,o) g_debug("%s:%i %s %s:%i",__FUNCTION__,__LINE__,t,G_OBJECT_TYPE_NAME(o),G_OBJECT(o)->ref_count);
-#define destroy(t,o) dbg_ref(t,o); g_object_unref(o); o = NULL;
- destroy ("output", priv->output);
+ g_object_unref(priv->output);
/* needs to unref one more time. Maybe a bug in GeglOp buffer ? */
-#undef destroy
break;
#ifdef PRINT
case FLEGITA_PRINT:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]