gimp r27362 - in trunk: . app/widgets



Author: neo
Date: Wed Oct 22 11:01:15 2008
New Revision: 27362
URL: http://svn.gnome.org/viewvc/gimp?rev=27362&view=rev

Log:
2008-10-22  Sven Neumann  <sven gimp org>

	* app/widgets/gimpprogressbox.c: set box->progress to NULL in
	destroy() and check for progress being NULL in various places so
	we don't crash on API calls after the widget is destroyed.



Modified:
   trunk/ChangeLog
   trunk/app/widgets/gimpprogressbox.c

Modified: trunk/app/widgets/gimpprogressbox.c
==============================================================================
--- trunk/app/widgets/gimpprogressbox.c	(original)
+++ trunk/app/widgets/gimpprogressbox.c	Wed Oct 22 11:01:15 2008
@@ -37,6 +37,8 @@
 
 static void     gimp_progress_box_progress_iface_init (GimpProgressInterface *iface);
 
+static void     gimp_progress_box_destroy            (GtkObject    *object);
+
 static GimpProgress *
                 gimp_progress_box_progress_start     (GimpProgress *progress,
                                                       const gchar  *message,
@@ -55,10 +57,15 @@
                          G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS,
                                                 gimp_progress_box_progress_iface_init))
 
+#define parent_class gimp_progress_box_parent_class
+
 
 static void
 gimp_progress_box_class_init (GimpProgressBoxClass *klass)
 {
+  GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
+
+  object_class->destroy = gimp_progress_box_destroy;
 }
 
 static void
@@ -93,6 +100,16 @@
   iface->pulse     = gimp_progress_box_progress_pulse;
 }
 
+static void
+gimp_progress_box_destroy (GtkObject *object)
+{
+  GimpProgressBox *box = GIMP_PROGRESS_BOX (object);
+
+  GTK_OBJECT_CLASS (parent_class)->destroy (object);
+
+  box->progress = NULL;
+}
+
 static GimpProgress *
 gimp_progress_box_progress_start (GimpProgress *progress,
                                   const gchar  *message,
@@ -100,6 +117,9 @@
 {
   GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
 
+  if (! box->progress)
+    return NULL;
+
   if (! box->active)
     {
       GtkProgressBar *bar = GTK_PROGRESS_BAR (box->progress);
@@ -123,11 +143,10 @@
 static void
 gimp_progress_box_progress_end (GimpProgress *progress)
 {
-  GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
-
-  if (box->active)
+  if (gimp_progress_box_progress_is_active (progress))
     {
-      GtkProgressBar *bar = GTK_PROGRESS_BAR (box->progress);
+      GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
+      GtkProgressBar  *bar = GTK_PROGRESS_BAR (box->progress);
 
       gtk_label_set_text (GTK_LABEL (box->label), "");
       gtk_progress_bar_set_fraction (bar, 0.0);
@@ -143,17 +162,17 @@
 {
   GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
 
-  return box->active;
+  return (box->progress && box->active);
 }
 
 static void
 gimp_progress_box_progress_set_text (GimpProgress *progress,
                                      const gchar  *message)
 {
-  GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
-
-  if (box->active)
+  if (gimp_progress_box_progress_is_active (progress))
     {
+      GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
+
       gtk_label_set_text (GTK_LABEL (box->label), message);
 
       if (GTK_WIDGET_DRAWABLE (box->progress))
@@ -165,11 +184,10 @@
 gimp_progress_box_progress_set_value (GimpProgress *progress,
                                       gdouble       percentage)
 {
-  GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
-
-  if (box->active)
+  if (gimp_progress_box_progress_is_active (progress))
     {
-      GtkProgressBar *bar = GTK_PROGRESS_BAR (box->progress);
+      GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
+      GtkProgressBar  *bar = GTK_PROGRESS_BAR (box->progress);
 
       box->value = percentage;
 
@@ -188,10 +206,10 @@
 static gdouble
 gimp_progress_box_progress_get_value (GimpProgress *progress)
 {
-  GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
-
-  if (box->active)
-    return box->value;
+  if (gimp_progress_box_progress_is_active (progress))
+    {
+      return GIMP_PROGRESS_BOX (progress)->value;
+    }
 
   return 0.0;
 }
@@ -199,11 +217,10 @@
 static void
 gimp_progress_box_progress_pulse (GimpProgress *progress)
 {
-  GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
-
-  if (box->active)
+  if (gimp_progress_box_progress_is_active (progress))
     {
-      GtkProgressBar *bar = GTK_PROGRESS_BAR (box->progress);
+      GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
+      GtkProgressBar  *bar = GTK_PROGRESS_BAR (box->progress);
 
       gtk_progress_bar_pulse (bar);
 



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