Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src


Modified Files:
        ewl_notebook.c ewl_notebook.h 


Log Message:
Fix for ewl_notebook_remove_visible causing a segv.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_notebook.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -3 -r1.37 -r1.38
--- ewl_notebook.c      14 Nov 2003 21:25:26 -0000      1.37
+++ ewl_notebook.c      16 Nov 2003 07:44:45 -0000      1.38
@@ -320,9 +320,9 @@
  * ewl_notebook_remove_visible - remove the visible page from the notebook
  * @n: the notebook to remove the visible page
  *
- * Returns a pointer to the removed page on success, NULL on failure.
+ * Returns no value.
  */
-Ewl_Widget *ewl_notebook_remove_visible(Ewl_Notebook * n)
+void ewl_notebook_remove_visible(Ewl_Notebook * n)
 {
        Ewl_Widget     *w;
        Ewl_Widget     *tab = NULL;
@@ -331,28 +331,58 @@
        Ewl_Container  *tc;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR_RET("n", n, NULL);
+       DCHECK_PARAM_PTR("n", n);
 
        w = EWL_WIDGET(n);
        c = EWL_CONTAINER(n);
        tc = EWL_CONTAINER(n->tab_box);
 
+       /*
+        * No visible page? What the hell are we doing here then?!?
+        */
+       if (!n->visible_page)
+               DRETURN(DLEVEL_STABLE);
+
+       /*
+        * Search out the page in the notebook, and the tab that goes with it.
+        */
        ewd_list_goto_first(c->children);
        ewd_list_goto_first(tc->children);
-       while ((page = ewd_list_next(c->children)) && page != n->visible_page) {
+       while ((page = ewd_list_next(c->children))) {
                if (page != n->tab_box)
                        tab = ewd_list_next(tc->children);
+               if (page == n->visible_page)
+                       break;
        }
 
+       /*
+        * We found a page, sweet, kick it to the curb!
+        */
        if (page) {
+
+               /*
+                * Remove from the list of pages in this notebook, and set it
+                * to be freed.
+                */
                ewl_container_remove_child(c, page);
+               ewl_widget_destroy(page);
+
+               /*
+                * If a tab is found remove it and free it.
+                */
                if (tab) {
                        ewl_container_remove_child(tc, tab);
                        ewl_widget_destroy(tab);
                }
+
+               /*
+                * Set a usable visible page.
+                */
+               n->visible_page = NULL;
+               ewl_notebook_set_visible_page(n, 0);
        }
 
-       DRETURN_PTR(page, DLEVEL_STABLE);
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
 /**
@@ -564,7 +594,8 @@
        if (!child || child == n->visible_page)
                DRETURN(DLEVEL_STABLE);
 
-       ewl_widget_hide(n->visible_page);
+       if (n->visible_page)
+               ewl_widget_hide(n->visible_page);
        n->visible_page = child;
        ewl_widget_show(child);
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_notebook.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- ewl_notebook.h      13 Nov 2003 23:38:01 -0000      1.14
+++ ewl_notebook.h      16 Nov 2003 07:44:45 -0000      1.15
@@ -27,7 +27,7 @@
 Ewl_Widget *ewl_notebook_remove_first_page(Ewl_Notebook * n);
 Ewl_Widget *ewl_notebook_remove_last_page(Ewl_Notebook * n);
 Ewl_Widget *ewl_notebook_remove_page(Ewl_Notebook * n, int i);
-Ewl_Widget *ewl_notebook_remove_visible(Ewl_Notebook * n);
+void ewl_notebook_remove_visible(Ewl_Notebook * n);
 
 void            ewl_notebook_set_tabs_alignment(Ewl_Notebook * n,
                                                unsigned int a);




-------------------------------------------------------
This SF. Net email is sponsored by: GoToMyPC
GoToMyPC is the fast, easy and secure way to access your computer from
any Web browser or wireless device. Click here to Try it Free!
https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to