Fix #95411: Collada export crashes if temporary file is not accessible #118958

Merged
Philipp Oeser merged 4 commits from lichtwerk/blender:95411_b into blender-v4.1-release 2024-03-05 13:14:57 +01:00
1 changed files with 10 additions and 1 deletions

View File

@ -19,6 +19,7 @@
#include "COLLADASWColorOrTexture.h"
#include "COLLADASWConstants.h"
#include "COLLADASWEffectProfile.h"
#include "COLLADASWException.h"
#include "COLLADASWImage.h"
#include "COLLADASWInputList.h"
#include "COLLADASWInstanceCamera.h"
@ -171,7 +172,15 @@ int DocumentExporter::exportCurrentScene()
clear_global_id_map();
COLLADABU::NativeString native_filename = make_temp_filepath(nullptr, ".dae");
COLLADASW::StreamWriter *writer = new COLLADASW::StreamWriter(native_filename);
COLLADASW::StreamWriter *writer;
try {
writer = new COLLADASW::StreamWriter(native_filename);
}
catch (COLLADASW::StreamWriterException &e) {
e.printMessage();
lichtwerk marked this conversation as resolved Outdated

Files can fail to be created for many reasons, this only addresses not having permissions.

It would be better to catch the COLLADASW::StreamWriterException.

Files can fail to be created for many reasons, this only addresses not having permissions. It would be better to catch the `COLLADASW::StreamWriterException`.
fprintf(stderr, "Collada: No Objects will be exported.\n");
return 1;
}
/* open <collada> */
writer->startDocument();