[dia/dia-0-96] merged from: git diff {86776fa, 21ce772} > rev-4024-4025.diff



commit 2c5aff8127c6cd75eed45696e836c20f9efab235
Author: Hans Breuer <hans breuer org>
Date:   Mon Apr 13 14:20:16 2009 +0200

    merged from: git diff {86776fa,21ce772} > rev-4024-4025.diff
    
    git cherry-pick in the dia-0-96 branch did not work, probably
    I've misunderstood something there. The above pattern would
    have worked equally well with SVN ...
---
 ChangeLog                     |   13 +++++++++++++
 app/sheets.c                  |   19 ++++++++++++-------
 app/sheets_dialog_callbacks.c |   40 +++++++++++++++++++++++++++++-----------
 3 files changed, 54 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2820389..e0d8531 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+[merged from: git diff {86776fa,21ce772} > rev-4024-4025.diff]
+2008-05-12  Hans Breuer  <hans breuer org>
+  
+	* app/sheets.c : attempt to add some robustness
+	* app/sheets_dialog_callbacks.c : g_new0() to catch mis-initialization
+	(on_sheet_new_dialog_button_ok_clicked) : a newly created sheet was 
+	not selected after creation
+	(on_sheets_dialog_button_move_clicked) : a move was not considered a
+	modification of the source sheet
+	(on_sheets_dialog_button_apply_clicked) : when finally registering the
+	a new sheet the struct was not properly passed, same for new object
+	Together this should fix bug #393526
+
 2008-03-16  Hans Breuer  <hans breuer org>
 
 	* lib/libdia.def : added missing exports
diff --git a/app/sheets.c b/app/sheets.c
index df0eb9f..d7cbec7 100644
--- a/app/sheets.c
+++ b/app/sheets.c
@@ -45,7 +45,7 @@
 GtkWidget *sheets_dialog = NULL;
 GSList *sheets_mods_list = NULL;
 GtkTooltips *sheets_dialog_tooltips = NULL;
-static gpointer custom_type_symbol;
+static gpointer custom_type_symbol = NULL;
 
 /* Given a SheetObject and a SheetMod, create a new SheetObjectMod
    and hook it into the 'objects' list in the SheetMod->sheet
@@ -59,7 +59,10 @@ sheets_append_sheet_object_mod(SheetObject *so, SheetMod *sm)
   SheetObjectMod *sheet_object_mod;
   DiaObjectType *ot;
 
-  sheet_object_mod = g_new(SheetObjectMod, 1);
+  g_return_val_if_fail (so != NULL && sm != NULL, NULL);
+  g_return_val_if_fail (custom_type_symbol != NULL, NULL);
+
+  sheet_object_mod = g_new0(SheetObjectMod, 1);
   sheet_object_mod->sheet_object = *so;
   sheet_object_mod->mod = SHEET_OBJECT_MOD_NONE;
 
@@ -83,7 +86,9 @@ sheets_append_sheet_mods(Sheet *sheet)
   SheetMod *sheet_mod;
   GSList *sheet_objects_list;
 
-  sheet_mod = g_new(SheetMod, 1);
+  g_return_val_if_fail (sheet != NULL, NULL);
+
+  sheet_mod = g_new0(SheetMod, 1);
   sheet_mod->sheet = *sheet;
   sheet_mod->type = SHEETMOD_TYPE_NORMAL;
   sheet_mod->mod = SHEETMOD_MOD_NONE;
@@ -104,7 +109,7 @@ menu_item_compare_labels(gconstpointer a, gconstpointer b)
   GList *a_list;
   gchar *label;
 
-  a_list = gtk_container_children(GTK_CONTAINER(GTK_MENU_ITEM(a)));
+  a_list = gtk_container_get_children(GTK_CONTAINER(GTK_MENU_ITEM(a)));
   g_assert(g_list_length(a_list) == 1);
 
   gtk_label_get(GTK_LABEL(a_list->data), &label);
@@ -171,7 +176,7 @@ sheets_optionmenu_create(GtkWidget *option_menu, GtkWidget *wrapbox,
                        (gpointer)sheet_mod);
   }
  
-  menu_item_list = gtk_container_children(GTK_CONTAINER(optionmenu_menu));
+  menu_item_list = gtk_container_get_children(GTK_CONTAINER(optionmenu_menu));
 
   /* If we were passed a sheet_name, then make the optionmenu point to that
      name after creation */
@@ -211,8 +216,8 @@ sheets_dialog_create(void)
 
   if (sheets_mods_list)
     {
-      /* FIXME: not sure if I understood the data structure
-         but simply leaking isn't acceptable ... --hb
+      /* not sure if I understood the data structure
+       * but simply leaking isn't acceptable ... --hb
        */
       g_slist_foreach(sheets_mods_list, (GFunc)g_free, NULL);
       g_slist_free(sheets_mods_list);
diff --git a/app/sheets_dialog_callbacks.c b/app/sheets_dialog_callbacks.c
index 0954075..3d06700 100644
--- a/app/sheets_dialog_callbacks.c
+++ b/app/sheets_dialog_callbacks.c
@@ -836,7 +836,7 @@ on_sheets_new_dialog_button_ok_clicked (GtkButton       *button,
     object_register_type(ot);
 
     entry = lookup_widget(sheets_new_dialog, "entry_svg_description");
-    sheet_obj = g_new(SheetObject, 1);
+    sheet_obj = g_new0(SheetObject, 1);
     sheet_obj->object_type = g_strdup(ot->name);
     {
       sheet_obj->description =
@@ -905,7 +905,7 @@ on_sheets_new_dialog_button_ok_clicked (GtkButton       *button,
       entry = lookup_widget(sheets_new_dialog, "entry_sheet_description");
       sheet_descrip = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
 
-      sheet = g_new(Sheet, 1);
+      sheet = g_new0(Sheet, 1);
       sheet->name = sheet_name;
       sheet->filename = "";
       sheet->description = sheet_descrip;
@@ -920,7 +920,7 @@ on_sheets_new_dialog_button_ok_clicked (GtkButton       *button,
       optionmenu = gtk_object_get_data(GTK_OBJECT(table_sheets),
                                        "active_optionmenu");
       g_assert(optionmenu);
-      sheets_optionmenu_create(optionmenu, wrapbox, NULL);
+      sheets_optionmenu_create(optionmenu, wrapbox, sheet_name);
     }
     break;
 
@@ -1461,7 +1461,7 @@ sheets_dialog_copy_object(GtkWidget *active_button, GtkWidget *target_wrapbox)
   if (!som)
     return;
 
-  so = g_new(SheetObject, 1);
+  so = g_new0(SheetObject, 1);
   so->object_type = g_strdup(som->sheet_object.object_type);
   so->description = g_strdup(som->sheet_object.description);
   so->pixmap = som->sheet_object.pixmap;
@@ -1471,7 +1471,7 @@ sheets_dialog_copy_object(GtkWidget *active_button, GtkWidget *target_wrapbox)
   so->pixmap_file = g_strdup(som->sheet_object.pixmap_file);
   so->has_icon_on_sheet = som->sheet_object.has_icon_on_sheet;
 
-  som_new = g_new(SheetObjectMod, 1);
+  som_new = g_new0(SheetObjectMod, 1);
   som_new->sheet_object = *so;
   som_new->type = som->type;
   som_new->mod = SHEET_OBJECT_MOD_NONE;
@@ -1540,8 +1540,14 @@ on_sheets_dialog_button_move_clicked   (GtkButton       *button,
   sheets_dialog_copy_object(active_button, target_wrapbox);
 
   som = gtk_object_get_data(GTK_OBJECT(active_button), "sheet_object_mod");
-  if (som)
+  if (som) {
+    SheetMod *sm;
+
     som->mod = SHEET_OBJECT_MOD_DELETED;
+    /* also mark the source sheet as changed */
+    sm = gtk_object_get_data(GTK_OBJECT(active_button), "sheet_mod");
+    sm->mod = SHEETMOD_MOD_CHANGED;
+  }
 
   new_active_button = sheets_dialog_set_new_active_button();
 
@@ -1810,25 +1816,32 @@ on_sheets_dialog_button_apply_clicked  (GtkButton       *button,
     {
       GSList *sheet_object_mods_list;
       GSList *list;
+      Sheet *new_sheet = NULL;
 
     case SHEETMOD_MOD_NEW:
       write_user_sheet(&sm->sheet);
 
       sheet_object_mods_list = sm->sheet.objects;
       sm->sheet.objects = NULL;
-      register_sheet(&sm->sheet);
+      /* we have to transfer 'permanent' memory */
+      new_sheet = g_new0 (Sheet, 1);
+      *new_sheet = sm->sheet;
+      register_sheet(new_sheet);
 
       for (list = sheet_object_mods_list; list; list = g_slist_next(list))
       {
         SheetObjectMod *som;
+	SheetObject *new_object;
 
         som = list->data;
         if (som->mod == SHEET_OBJECT_MOD_DELETED)
           continue;
 
-        sheet_append_sheet_obj(&sm->sheet, &som->sheet_object);
+	new_object = g_new0(SheetObject, 1);
+	*new_object = som->sheet_object;
+        sheet_append_sheet_obj(new_sheet, new_object);
       }
-      
+
       dia_sort_sheets();      
       fill_sheet_menu();
       break;
@@ -1847,12 +1860,15 @@ on_sheets_dialog_button_apply_clicked  (GtkButton       *button,
       for (list = sheet_object_mods_list; list; list = g_slist_next(list))
       {
         SheetObjectMod *som;
+	SheetObject *new_object;
 
         som = list->data;
         if (som->mod == SHEET_OBJECT_MOD_DELETED)
           continue;
 
-        sheet_append_sheet_obj(sheets_list->data, &som->sheet_object);
+	new_object = g_new0(SheetObject, 1);
+	*new_object = som->sheet_object;
+        sheet_append_sheet_obj(sheets_list->data, new_object);
       }
       fill_sheet_menu();
       break;
@@ -1867,7 +1883,9 @@ on_sheets_dialog_button_apply_clicked  (GtkButton       *button,
       find_list = g_slist_find_custom(sheets_list, &sm->sheet,
                                         sheets_find_sheet);
       g_assert(sheets_list);
-      g_slist_remove_link(sheets_list, find_list);
+      if (!g_slist_remove_link(sheets_list, find_list))
+	g_warning ("No sheets left?");
+
       dia_sort_sheets();
       fill_sheet_menu();
       break;



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