workaround/fix [#27162] Running commands in python console crashes blender

This commit is contained in:
Campbell Barton
2011-04-25 12:39:53 +00:00
parent 739359faab
commit 70d059161b
2 changed files with 22 additions and 5 deletions

View 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;

View 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)