[dia/neduard/meson_fixes] #31 bugfix: s/struct stat/GStatBuf/



commit 1d62d95bf86247dfcc45a10d477d1b0a7fc85bce
Author: Eduard <eddnicodei gmail com>
Date:   Fri Feb 1 00:41:18 2019 +0000

    #31 bugfix: s/struct stat/GStatBuf/
    
      - This caused segfaults because g_stat requires GStatBuf and the two
        structs are not identical:
        https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions?view=vs-2017
      - Curiously the segfault only happened in the optimised build and
        only on Windows.

 app/commands.c                          | 2 +-
 app/filedlg.c                           | 4 ++--
 app/load_save.c                         | 2 +-
 app/sheets_dialog_callbacks.c           | 4 ++--
 lib/plug-ins.c                          | 2 +-
 lib/sheet.c                             | 2 +-
 objects/Misc/diagram_as_object.c        | 2 +-
 objects/custom/custom_object.c          | 2 +-
 objects/custom_lines/custom_linetypes.c | 2 +-
 objects/standard/image.c                | 4 ++--
 plug-ins/postscript/paginate_psprint.c  | 2 +-
 11 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/app/commands.c b/app/commands.c
index 32ac0efe..36607524 100644
--- a/app/commands.c
+++ b/app/commands.c
@@ -484,7 +484,7 @@ _clipboard_get_data_callback (GtkClipboard     *clipboard,
        g_object_unref (pixbuf);
       }
     } else {
-      struct stat st;
+      GStatBuf st;
       FILE *f;
       
       if (   g_stat (outfname, &st) == 0 
diff --git a/app/filedlg.c b/app/filedlg.c
index e4219412..f3faaac8 100644
--- a/app/filedlg.c
+++ b/app/filedlg.c
@@ -371,7 +371,7 @@ file_save_as_response_callback(GtkWidget *fs,
 {
   char *filename;
   Diagram *dia;
-  struct stat stat_struct;
+  GStatBuf stat_struct;
 
   if (response == GTK_RESPONSE_ACCEPT) {
     dia = g_object_get_data (G_OBJECT(fs), "user_data");
@@ -700,7 +700,7 @@ file_export_response_callback(GtkWidget *fs,
   char *filename;
   Diagram *dia;
   DiaExportFilter *ef;
-  struct stat statbuf;
+  GStatBuf statbuf;
 
   dia = g_object_get_data (G_OBJECT (fs), "user_data");
   g_assert (dia);
diff --git a/app/load_save.c b/app/load_save.c
index a41e0280..e699ab7e 100644
--- a/app/load_save.c
+++ b/app/load_save.c
@@ -1169,7 +1169,7 @@ void
 diagram_cleanup_autosave(Diagram *dia)
 {
   gchar *savefile;
-  struct stat statbuf;
+  GStatBuf statbuf;
 
   savefile = dia->autosavefilename;
   if (savefile == NULL) return;
diff --git a/app/sheets_dialog_callbacks.c b/app/sheets_dialog_callbacks.c
index b21042ae..6a23e5af 100644
--- a/app/sheets_dialog_callbacks.c
+++ b/app/sheets_dialog_callbacks.c
@@ -745,7 +745,7 @@ on_sheets_new_dialog_button_ok_clicked (GtkButton       *button,
     GtkWidget *entry;
     gchar *file_name;
     gchar *p;
-    struct stat stat_buf;
+    GStatBuf stat_buf;
     GList *plugin_list;
     DiaObjectType *ot;
     typedef gboolean (*CustomObjectLoadFunc) (gchar*, DiaObjectType **);
@@ -1777,7 +1777,7 @@ write_user_sheet(Sheet *sheet)
 static void
 touch_file(gchar *filename)
 {
-  struct stat stat_buf;
+  GStatBuf stat_buf;
   struct utimbuf utim_buf;
 
   g_stat(filename, &stat_buf);
diff --git a/lib/plug-ins.c b/lib/plug-ins.c
index 478e845a..c07cd359 100644
--- a/lib/plug-ins.c
+++ b/lib/plug-ins.c
@@ -289,7 +289,7 @@ static void
 for_each_in_dir(const gchar *directory, ForEachInDirDoFunc dofunc,
                 ForEachInDirFilterFunc filter)
 {
-  struct stat statbuf;
+  GStatBuf statbuf;
   const char *dentry;
   GDir *dp;
   GError *error = NULL;
diff --git a/lib/sheet.c b/lib/sheet.c
index 698b750f..e55cf944 100644
--- a/lib/sheet.c
+++ b/lib/sheet.c
@@ -304,7 +304,7 @@ load_register_sheet(const gchar *dirname, const gchar *filename,
   {
     if (sheetp->data && !strcmp(((Sheet *)(sheetp->data))->name, name)) 
     {
-      struct stat first_file, this_file;
+      GStatBuf first_file, this_file;
       int stat_ret;
       
       stat_ret = g_stat(((Sheet *)(sheetp->data))->filename, &first_file);
diff --git a/objects/Misc/diagram_as_object.c b/objects/Misc/diagram_as_object.c
index 0a030ff1..307dda67 100644
--- a/objects/Misc/diagram_as_object.c
+++ b/objects/Misc/diagram_as_object.c
@@ -235,7 +235,7 @@ _dae_draw(DiagramAsElement *dae, DiaRenderer *renderer)
 static void
 _dae_update_data(DiagramAsElement *dae)
 {
-  struct stat statbuf;
+  GStatBuf statbuf;
   Element *elem = &dae->element;
   DiaObject *obj = &elem->object;
   static int working = 0;
diff --git a/objects/custom/custom_object.c b/objects/custom/custom_object.c
index d22a195d..2f547000 100644
--- a/objects/custom/custom_object.c
+++ b/objects/custom/custom_object.c
@@ -1799,7 +1799,7 @@ custom_object_new(ShapeInfo *info, DiaObjectType **otype)
   obj->default_user_data = info;
 
   if (info->icon) {
-    struct stat buf;
+    GStatBuf buf;
     if (0==g_stat(info->icon,&buf)) {
       obj->pixmap = NULL;
       obj->pixmap_file = info->icon;
diff --git a/objects/custom_lines/custom_linetypes.c b/objects/custom_lines/custom_linetypes.c
index f780c976..de9e51ef 100644
--- a/objects/custom_lines/custom_linetypes.c
+++ b/objects/custom_lines/custom_linetypes.c
@@ -302,7 +302,7 @@ custom_linetype_new(LineInfo *info, DiaObjectType **otype)
   }
 
   if (info->icon_filename) {
-    struct stat buf;
+    GStatBuf buf;
     if (0==g_stat(info->icon_filename,&buf)) {
       obj->pixmap = NULL;
       obj->pixmap_file = info->icon_filename;
diff --git a/objects/standard/image.c b/objects/standard/image.c
index a2d556f7..111c5855 100644
--- a/objects/standard/image.c
+++ b/objects/standard/image.c
@@ -225,7 +225,7 @@ image_get_props(Image *image, GPtrArray *props)
 static void
 image_set_props(Image *image, GPtrArray *props)
 {
-  struct stat st;
+  GStatBuf st;
   time_t mtime = 0;
   char *old_file = image->file ? g_strdup(image->file) : NULL;
   const GdkPixbuf *old_pixbuf = dia_image_pixbuf (image->image);
@@ -863,7 +863,7 @@ image_load(ObjectNode obj_node, int version, DiaContext *ctx)
 
   /* update mtime */
   {
-    struct stat st;
+    GStatBuf st;
     if (g_stat (image->file, &st) != 0)
       st.st_mtime = 0;
 
diff --git a/plug-ins/postscript/paginate_psprint.c b/plug-ins/postscript/paginate_psprint.c
index f36db526..a8a24263 100644
--- a/plug-ins/postscript/paginate_psprint.c
+++ b/plug-ins/postscript/paginate_psprint.c
@@ -403,7 +403,7 @@ diagram_print_ps(DiagramData *dia, const gchar* original_filename)
       is_pipe = TRUE;
     } else {
       const gchar *filename = gtk_entry_get_text(GTK_ENTRY(ofile));
-      struct stat statbuf;
+      GStatBuf statbuf;
 
       if (g_stat(filename, &statbuf) == 0) {   /* Output file exists */
         GtkWidget *confirm_overwrite_dialog = NULL;


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