Move more code inside the 'try' block in an attempt to have studio not crash when...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sun, 24 Feb 2008 20:50:18 +0000 (20:50 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sun, 24 Feb 2008 20:50:18 +0000 (20:50 +0000)
git-svn-id: http://svn.voria.com/code@1812 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/synfig/savecanvas.cpp

index eb2bf75..5f18473 100644 (file)
@@ -768,29 +768,28 @@ synfig::save_canvas(const String &filename, Canvas::ConstHandle canvas)
                encode_canvas_toplevel(document.create_root_node("canvas"),canvas);
 
                document.write_to_file_formatted(tmp_filename);
-       }
-       catch(...) { synfig::error("synfig::save_canvas(): Caught unknown exception"); return false; }
-
 
 #ifdef _WIN32
-       // On Win32 platforms, rename() has bad behavior. work around it.
-       char old_file[80]="sif.XXXXXXXX";
-       mktemp(old_file);
-       rename(filename.c_str(),old_file);
-       if(rename(tmp_filename.c_str(),filename.c_str())!=0)
-       {
-               rename(old_file,tmp_filename.c_str());
-               synfig::error("synfig::save_canvas(): Unable to rename file to correct filename, errno=%d",errno);
-               return false;
-       }
-       remove(old_file);
+               // On Win32 platforms, rename() has bad behavior. work around it.
+               char old_file[80]="sif.XXXXXXXX";
+               mktemp(old_file);
+               rename(filename.c_str(),old_file);
+               if(rename(tmp_filename.c_str(),filename.c_str())!=0)
+               {
+                       rename(old_file,tmp_filename.c_str());
+                       synfig::error("synfig::save_canvas(): Unable to rename file to correct filename, errno=%d",errno);
+                       return false;
+               }
+               remove(old_file);
 #else
-       if(rename(tmp_filename.c_str(),filename.c_str())!=0)
-       {
-               synfig::error("synfig::save_canvas(): Unable to rename file to correct filename, errno=%d",errno);
-               return false;
-       }
+               if(rename(tmp_filename.c_str(),filename.c_str())!=0)
+               {
+                       synfig::error("synfig::save_canvas(): Unable to rename file to correct filename, errno=%d",errno);
+                       return false;
+               }
 #endif
+       }
+       catch(...) { synfig::error("synfig::save_canvas(): Caught unknown exception"); return false; }
 
        return true;
 }