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

Re: [E-devel] [PATCH] System Actions Dialog SEGV



Hmmm...this patch is screwed. Don't know how that happened. Here tis
again.

metrics

On Wed, Oct 25, 2006 at 03:27:43PM +1000, Metrics wrote:
> Patch attached to fix a segv lurking in the system actions dialog box
> that shows up during suspend/resume/reboot etc.
> 
> Problem was that the callback that triggers to delete the window would
> still try and perform the delete on the window with an invalid pointer
> if the window was closed via some other means.  To work around this, a
> delete callback was implemented for e_obj_dialog, and it is used to NULL
> the pointer.
> 
> metrics
Index: e_obj_dialog.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_obj_dialog.c,v
retrieving revision 1.2
diff -u -r1.2 e_obj_dialog.c
--- e_obj_dialog.c	21 Sep 2006 20:07:02 -0000	1.2
+++ e_obj_dialog.c	25 Oct 2006 06:39:42 -0000
@@ -45,11 +45,18 @@
    od->bg_object = o;
    
    e_win_centered_set(od->win, 1);
+   od->cb_delete = NULL;
    
    return od;
 }
 
 EAPI void
+e_obj_dialog_cb_delete_set(E_Obj_Dialog *od, void (*func)(E_Obj_Dialog *od))
+{
+   od->cb_delete = func;
+}
+
+EAPI void
 e_obj_dialog_icon_set(E_Obj_Dialog *od, char *icon)
 {
    E_OBJECT_CHECK(od);
@@ -116,6 +123,8 @@
    E_Obj_Dialog *od;
    
    od = win->data;
+   if (od->cb_delete)
+     od->cb_delete(od);
    e_object_del(E_OBJECT(od));
 }
 
@@ -125,5 +134,7 @@
    E_Obj_Dialog *od;
    
    od = data;
+   if (od->cb_delete)
+     od->cb_delete(od);
    e_object_del(E_OBJECT(od));
 }
Index: e_obj_dialog.h
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_obj_dialog.h,v
retrieving revision 1.1
diff -u -r1.1 e_obj_dialog.h
--- e_obj_dialog.h	10 Sep 2006 04:51:07 -0000	1.1
+++ e_obj_dialog.h	25 Oct 2006 06:39:42 -0000
@@ -18,6 +18,7 @@
    E_Win               *win;
    Evas_Object         *bg_object;
    void                *data;
+   void		       (*cb_delete)(E_Obj_Dialog *od);
 };
 
 EAPI E_Obj_Dialog   *e_obj_dialog_new(E_Container *con, char *title, char *class_name, char *class_class);
@@ -25,6 +26,7 @@
 EAPI void            e_obj_dialog_show(E_Obj_Dialog *od);
 EAPI void            e_obj_dialog_obj_part_text_set(E_Obj_Dialog *od, char *part, char *text);
 EAPI void            e_obj_dialog_obj_theme_set(E_Obj_Dialog *od, char *theme_cat, char *theme_obj);
+EAPI void	     e_obj_dialog_cb_delete_set(E_Obj_Dialog *od, void (*func)(E_Obj_Dialog *od));
     
 #endif
 #endif
Index: e_sys.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_sys.c,v
retrieving revision 1.6
diff -u -r1.6 e_sys.c
--- e_sys.c	21 Oct 2006 11:19:40 -0000	1.6
+++ e_sys.c	25 Oct 2006 06:40:02 -0000
@@ -15,6 +15,7 @@
 static void _e_sys_current_action(void);
 static void _e_sys_action_failed(void);
 static int _e_sys_action_do(E_Sys_Action a, char *param);
+static void _e_sys_dialog_cb_delete(E_Obj_Dialog * od);
 
 static Ecore_Event_Handler *_e_sys_exe_exit_handler = NULL;
 static Ecore_Exe *_e_sys_halt_check_exe = NULL;
@@ -482,6 +483,7 @@
 	     e_obj_dialog_show(od);
 	     e_obj_dialog_icon_set(od, "enlightenment/halt");
 	     if (_e_sys_dialog) e_object_del(E_OBJECT(_e_sys_dialog));
+	     e_obj_dialog_cb_delete_set(od, _e_sys_dialog_cb_delete);
 	     _e_sys_dialog = od;
 	     /* FIXME: display halt status */
 	  }
@@ -508,6 +510,7 @@
 	     e_obj_dialog_show(od);
 	     e_obj_dialog_icon_set(od, "enlightenment/reboot");
 	     if (_e_sys_dialog) e_object_del(E_OBJECT(_e_sys_dialog));
+	     e_obj_dialog_cb_delete_set(od, _e_sys_dialog_cb_delete);
 	     _e_sys_dialog = od;
 	     /* FIXME: display reboot status */
 	  }
@@ -533,6 +536,7 @@
 	     e_obj_dialog_show(od);
 	     e_obj_dialog_icon_set(od, "enlightenment/suspend");
 	     if (_e_sys_dialog) e_object_del(E_OBJECT(_e_sys_dialog));
+	     e_obj_dialog_cb_delete_set(od, _e_sys_dialog_cb_delete);
 	     _e_sys_dialog = od;
 	     /* FIXME: display suspend status */
 	  }
@@ -559,6 +563,7 @@
 	     e_obj_dialog_icon_set(od, "enlightenment/hibernate");
 	     if (_e_sys_dialog) e_object_del(E_OBJECT(_e_sys_dialog));
 	     _e_sys_dialog = od;
+	     e_obj_dialog_cb_delete_set(od, _e_sys_dialog_cb_delete);
 	     /* FIXME: display hibernate status */
 	  }
 	break;
@@ -567,3 +572,11 @@
      }
    return 1;
 }
+
+static void _e_sys_dialog_cb_delete(E_Obj_Dialog * od)
+{
+   /* If we don't NULL out the _e_sys_dialog, then the
+    * ECORE_EXE_EVENT_DEL callback will trigger and segv if the window
+    * is deleted in some other way. */
+   _e_sys_dialog = NULL;
+}