workaround/fix [#27162] Running commands in python console crashes blender
authorCampbell Barton <ideasman42@gmail.com>
Mon, 25 Apr 2011 12:39:53 +0000 (12:39 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 25 Apr 2011 12:39:53 +0000 (12:39 +0000)
source/blender/collada/collada.cpp
source/blender/windowmanager/intern/wm_operators.c

index 0d822c63094be23ba7bb775648e6bc68efeb35ef..51caf62f6e7b97b45aa8536e169e6e726075f0ef 100644 (file)
@@ -38,6 +38,11 @@ extern "C"
 #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 @@ extern "C"
 
        int collada_export(Scene *sce, const char *filepath)
        {
-
                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;
index 3f3a117f38960861d67f05c198644c934f720939..100dd914026de5dcceb95f81e7e6972b46ee14f7 100644 (file)
@@ -1948,11 +1948,14 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
                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)