1. trap abort signals - glibc likes to abort these days on memory free errors.
authorCarsten Haitzler <raster@rasterman.com>
Sun, 2 Apr 2006 04:18:18 +0000 (04:18 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Sun, 2 Apr 2006 04:18:18 +0000 (04:18 +0000)
2. fix bg selector to properly select the item to be selected (do it after
listing them all), and add segmenting headers (And free path properly)

SVN revision: 21705

src/bin/e_int_config_background.c
src/bin/e_int_config_theme.c
src/bin/e_main.c
src/bin/e_signals.c
src/bin/e_signals.h

index a316f33..b4023b1 100644 (file)
@@ -279,6 +279,8 @@ _load_bgs(E_Config_Dialog *cfd, Evas_Object *il)
    Evas *evasbuf;
    const char *f;
    char *c;
+   int selnum = -1;
+   int i = 0;
 
    if (!il) return;
    
@@ -289,6 +291,10 @@ _load_bgs(E_Config_Dialog *cfd, Evas_Object *il)
    eebuf = ecore_evas_buffer_new(1, 1);
    evasbuf = ecore_evas_get(eebuf);
    o = edje_object_add(evasbuf);
+   
+   e_widget_ilist_header_append(il, NULL, _("Theme"));
+   i++;
+   
    f = e_theme_edje_file_get("base/theme/backgrounds", "desktop/background");
    c = strdup(f);
    if (edje_object_file_set(o, f, "desktop/background"))
@@ -301,9 +307,9 @@ _load_bgs(E_Config_Dialog *cfd, Evas_Object *il)
          ic = e_thumb_evas_object_get(c, cfd->dia->win->evas, 48, 48, 1);
 
        e_widget_ilist_append(il, ic, "Theme Background", _ilist_cb_bg_selected, cfd, "");
+       if (!e_config->desktop_default_background) selnum = i;
+       i++;
      }
-   if (!e_config->desktop_default_background)
-     e_widget_ilist_selected_set(il, 0);
    
    im = e_widget_preview_add(cfd->dia->win->evas, 320, 240);
    e_widget_preview_edje_set(im, f, "desktop/background");
@@ -319,52 +325,79 @@ _load_bgs(E_Config_Dialog *cfd, Evas_Object *il)
    for (bg = bg_dirs; bg; bg = bg->next)
      {
        E_Path_Dir *d;
-
+        int detected;
+       char *bg_file;
+       Ecore_List *bgs;
+       char *homedir;
+       
        d = bg->data;
-       if (ecore_file_is_dir(d->dir))
+       if (!ecore_file_is_dir(d->dir)) continue;
+       bgs = ecore_file_ls(d->dir);
+       if (!bgs) continue;
+       
+       detected = 0;
+       homedir = e_user_homedir_get();
+       if (homedir)
          {
-            char *bg_file;
-            Ecore_List *bgs;
-            int i = 1;
-
-            bgs = ecore_file_ls(d->dir);
-            if (!bgs) continue;
-            while ((bg_file = ecore_list_next(bgs)))
+            if (!strncmp(d->dir, homedir, strlen(homedir)))
+              {
+                 e_widget_ilist_header_append(il, NULL, _("Personal"));
+                 i++;
+                 detected = 1;
+              }
+            free(homedir);
+         }
+       if (!detected)
+         {
+            if (!strncmp(d->dir, e_prefix_data_get(), strlen(e_prefix_data_get())))
               {
-                 char full_path[4096];
-
-                 snprintf(full_path, sizeof(full_path), "%s/%s", d->dir, bg_file);
-                 if (ecore_file_is_dir(full_path)) continue;
-                 if (!e_util_edje_collection_exists(full_path, "desktop/background")) continue;
-
-                 if (!e_thumb_exists(full_path))
-                   ic = e_thumb_generate_begin(full_path, 48, 48, evas, &ic, NULL, NULL);
-                 else
-                   ic = e_thumb_evas_object_get(full_path, evas, 48, 48, 1);
-
-                 e_widget_ilist_append(il, ic, ecore_file_strip_ext(bg_file), _ilist_cb_bg_selected, cfd, full_path);
-                 if ((e_config->desktop_default_background) &&
-                     (!strcmp(e_config->desktop_default_background, full_path)))
-                   {
-                      e_widget_ilist_selected_set(il, i);
-                      
-                      evas_object_del(im);
-                      im = e_widget_preview_add(cfd->dia->win->evas, 320, 240);
-                      e_widget_preview_edje_set(im, e_config->desktop_default_background, "desktop/background");
-//                    im = e_widget_preview_add_from_object(cfd->dia->win->evas, o, 320, 240);
-//                    e_widget_preview_object_set(im, e_thumb_evas_object_get(full_path, cfd->dia->win->evas, 320, 240, 1));
-                   }
+                 e_widget_ilist_header_append(il, NULL, _("System"));
                  i++;
+                 detected = 1;
+              }
+         }
+       if (!detected)
+         {
+            e_widget_ilist_header_append(il, NULL, _("Other"));
+            i++;
+            detected = 1;
+         }
+       while ((bg_file = ecore_list_next(bgs)))
+         {
+            char full_path[4096];
+            
+            snprintf(full_path, sizeof(full_path), "%s/%s", d->dir, bg_file);
+            if (ecore_file_is_dir(full_path)) continue;
+            if (!e_util_edje_collection_exists(full_path, "desktop/background")) continue;
+            
+            if (!e_thumb_exists(full_path))
+              ic = e_thumb_generate_begin(full_path, 48, 48, evas, &ic, NULL, NULL);
+            else
+              ic = e_thumb_evas_object_get(full_path, evas, 48, 48, 1);
+            
+            e_widget_ilist_append(il, ic, ecore_file_strip_ext(bg_file), _ilist_cb_bg_selected, cfd, full_path);
+            if ((e_config->desktop_default_background) &&
+                (!strcmp(e_config->desktop_default_background, full_path)))
+              {
+                 selnum = i;
+                 
+                 evas_object_del(im);
+                 im = e_widget_preview_add(cfd->dia->win->evas, 320, 240);
+                 e_widget_preview_edje_set(im, e_config->desktop_default_background, "desktop/background");
+                 // im = e_widget_preview_add_from_object(cfd->dia->win->evas, o, 320, 240);
+                 // e_widget_preview_object_set(im, e_thumb_evas_object_get(full_path, cfd->dia->win->evas, 320, 240, 1));
               }
-            free(bg_file);
-            ecore_list_destroy(bgs);
+            i++;
          }
-       free(d);
+       free(bg_file);
+       ecore_list_destroy(bgs);
      }
    evas_list_free(bg);
-   evas_list_free(bg_dirs);
+   if (bg_dirs) e_path_dir_list_free(bg_dirs);
    free(c);
    cfd->data = im;
+   if (selnum >= 0)
+     e_widget_ilist_selected_set(il, selnum);
 }
 
 void
index 3ea39d8..6108eae 100644 (file)
@@ -151,20 +151,19 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
      {
        Ecore_List *themes;
        char *themefile;
-       E_Path_Dir *ep;
+       E_Path_Dir *d;
        int detected;
        
-       ep = l->data;
-
-       if (!ecore_file_is_dir(ep->dir)) continue;
-       themes = ecore_file_ls(ep->dir);
+       d = l->data;
+       if (!ecore_file_is_dir(d->dir)) continue;
+       themes = ecore_file_ls(d->dir);
        if (!themes) continue;
        
        detected = 0;
        homedir = e_user_homedir_get();
        if (homedir)
          {
-            if (!strncmp(ep->dir, homedir, strlen(homedir)))
+            if (!strncmp(d->dir, homedir, strlen(homedir)))
               {
                  e_widget_ilist_header_append(il, NULL, _("Personal"));
                  i++;
@@ -174,7 +173,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
          }
        if (!detected)
          {
-            if (!strncmp(ep->dir, e_prefix_data_get(), strlen(e_prefix_data_get())))
+            if (!strncmp(d->dir, e_prefix_data_get(), strlen(e_prefix_data_get())))
               {
                  e_widget_ilist_header_append(il, NULL, _("System"));
                  i++;
@@ -190,7 +189,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
        
        while ((themefile = ecore_list_next(themes)))
          {
-            snprintf(fulltheme, sizeof(fulltheme), "%s/%s", ep->dir, themefile);
+            snprintf(fulltheme, sizeof(fulltheme), "%s/%s", d->dir, themefile);
             if (ecore_file_is_dir(fulltheme)) continue;
             
             /* minimum theme requirements */
index 505e660..da894ed 100644 (file)
@@ -88,6 +88,11 @@ main(int argc, char **argv)
    sigemptyset(&action.sa_mask);
    sigaction(SIGBUS, &action, NULL);
 
+   action.sa_sigaction = e_sigabrt_act;
+   action.sa_flags = SA_ONSTACK | SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
+   sigemptyset(&action.sa_mask);
+   sigaction(SIGABRT, &action, NULL);
+
    /* FIXME: this is the init code for letting e be relocatable. right now
     * its not used - so i want to see if it can reliably determine its exe
     * prefix
index f0aef37..f69ed2c 100644 (file)
@@ -143,3 +143,28 @@ e_sigbus_act(int x, siginfo_t *info, void *data)
                "etc.");
    exit(-11);
 }
+
+EAPI void
+e_sigabrt_act(int x, siginfo_t *info, void *data)
+{
+   write(2, "**** ABORT ****\n", 21);
+   ecore_x_pointer_ungrab();
+   ecore_x_keyboard_ungrab();
+   ecore_x_ungrab();
+   ecore_x_sync();
+   e_alert_show("This is very bad. Enlightenment has recieved an abort.\n"
+               "This could be for many reasons - accessing memory not in\n"
+               "its available address space or unable to be paged in.\n"
+               "\n"
+               "You can gdb attach to this process now to try debug it\n"
+               "or you could exit, or just hit restart to try and get\n"
+               "your desktop back the way it was. This may not always\n"
+               "work perfectly, but it is the best we can do for now.\n"
+               "\n"
+               "Please help us debug this by compiling Enlightenment and\n"
+               "all its dependency libraries with gdb debugging enabled\n"
+               "and gdb attach to E when this happens and try figure out\n"
+               "what's going on and set us gdb backtraces, variable dumps\n"
+               "etc.");
+   exit(-11);
+}
index a34768d..e9ac10f 100644 (file)
@@ -11,6 +11,7 @@ EAPI void e_sigseg_act(int x, siginfo_t *info, void *data);
 EAPI void e_sigill_act(int x, siginfo_t *info, void *data);
 EAPI void e_sigfpe_act(int x, siginfo_t *info, void *data);
 EAPI void e_sigbus_act(int x, siginfo_t *info, void *data);
+EAPI void e_sigabrt_act(int x, siginfo_t *info, void *data);
 
 #endif
 #endif