[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36326] trunk/blender/source/blender: workaround/fix [#27162] Running commands in python console crashes blender

Campbell Barton ideasman42 at gmail.com
Mon Apr 25 14:39:54 CEST 2011


Revision: 36326
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36326
Author:   campbellbarton
Date:     2011-04-25 12:39:53 +0000 (Mon, 25 Apr 2011)
Log Message:
-----------
workaround/fix [#27162] Running commands in python console crashes blender

Modified Paths:
--------------
    trunk/blender/source/blender/collada/collada.cpp
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: trunk/blender/source/blender/collada/collada.cpp
===================================================================
--- trunk/blender/source/blender/collada/collada.cpp	2011-04-25 12:26:33 UTC (rev 36325)
+++ trunk/blender/source/blender/collada/collada.cpp	2011-04-25 12:39:53 UTC (rev 36326)
@@ -38,6 +38,11 @@
 #include "BKE_scene.h"
 #include "BKE_context.h"
 
+/* make dummy file */
+#include "BLI_storage.h"
+#include "BLI_path_util.h"
+#include "BLI_fileops.h"
+
 	int collada_import(bContext *C, const char *filepath)
 	{
 		DocumentImporter imp (C, filepath);
@@ -48,8 +53,17 @@
 
 	int collada_export(Scene *sce, const char *filepath)
 	{
+		DocumentExporter exp;
 
-		DocumentExporter exp;
+		/* annoying, collada crashes if file cant be created! [#27162] */
+		if(!BLI_exist(filepath)) {
+			BLI_make_existing_file(filepath); /* makes the dir if its not there */
+			if(BLI_touch(filepath) == 0) {
+				return 0;
+			}
+		}
+		/* end! */
+
 		exp.exportCurrentScene(sce, filepath);
 
 		return 1;

Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2011-04-25 12:26:33 UTC (rev 36325)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2011-04-25 12:39:53 UTC (rev 36326)
@@ -1948,11 +1948,14 @@
 		BKE_report(op->reports, RPT_ERROR, "No filename given");
 		return OPERATOR_CANCELLED;
 	}
-	
+
 	RNA_string_get(op->ptr, "filepath", filename);
-	collada_export(CTX_data_scene(C), filename);
-	
-	return OPERATOR_FINISHED;
+	if(collada_export(CTX_data_scene(C), filename)) {
+		return OPERATOR_FINISHED;
+	}
+	else {
+		return OPERATOR_CANCELLED;
+	}
 }
 
 static void WM_OT_collada_export(wmOperatorType *ot)




More information about the Bf-blender-cvs mailing list