Code

functional noop: extension/system.cpp: g_strdup handles NULL fine, so don't bother...
authorpjrm <pjrm@users.sourceforge.net>
Sun, 5 Apr 2009 22:36:39 +0000 (22:36 +0000)
committerpjrm <pjrm@users.sourceforge.net>
Sun, 5 Apr 2009 22:36:39 +0000 (22:36 +0000)
src/extension/system.cpp

index 31cf877a857927f361d239656ebe7f6fd5634c0e..edbe42dac48f1d157314e5d868ab971323d64348 100644 (file)
@@ -253,20 +253,15 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
     gchar *saved_uri = NULL;
     if (!official) {
         saved_modified = doc->isModifiedSinceSave();
-        if (repr->attribute("inkscape:output_extension")) {
-            saved_output_extension = g_strdup(repr->attribute("inkscape:output_extension"));
-        }
-        if (repr->attribute("inkscape:dataloss")) {
-            saved_dataloss = g_strdup(repr->attribute("inkscape:dataloss"));
-        }
-        if (doc->uri) {
-            saved_uri = g_strdup(doc->uri);    
-        }
+        saved_output_extension = g_strdup(repr->attribute("inkscape:output_extension"));
+        saved_dataloss = g_strdup(repr->attribute("inkscape:dataloss"));
+        saved_uri = g_strdup(doc->uri);    
     }    
 
     // update attributes:
     bool saved = sp_document_get_undo_sensitive(doc);
     sp_document_set_undo_sensitive (doc, false); 
+    {
         // save the filename for next use
         sp_document_set_uri(doc, fileName);
         // also save the extension for next use
@@ -276,6 +271,7 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
         if ( omod->causes_dataloss() ) {
             repr->setAttribute("inkscape:dataloss", "true");
         }
+    }
     sp_document_set_undo_sensitive (doc, saved);
     doc->setModifiedSinceSave(false);
 
@@ -285,17 +281,19 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
     if ( !official) {
         saved = sp_document_get_undo_sensitive(doc);
         sp_document_set_undo_sensitive (doc, false);
+        {
             repr->setAttribute("inkscape:output_extension", saved_output_extension);
             repr->setAttribute("inkscape:dataloss", saved_dataloss);
             sp_document_set_uri(doc, saved_uri);
+        }
         sp_document_set_undo_sensitive (doc, saved);
         doc->setModifiedSinceSave(saved_modified);
+
+        g_free(saved_output_extension);
+        g_free(saved_dataloss);
+        g_free(saved_uri);
     }
     
-    if (saved_output_extension)  g_free(saved_output_extension);
-    if (saved_dataloss)          g_free(saved_dataloss);
-    if (saved_uri)               g_free(saved_uri);    
-    
     g_free(fileName);
     return;
 }