From 959595069db6034611dac9b8fc2a89e31eeda8f9 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Tue, 5 Mar 2024 13:14:45 +0100 Subject: [PATCH] Fix #95411: Collada export crashes if temporary file is not accessible This can happen e.g. when relative "//" is in Preferences > File Paths > Temporary Files is used. Now catch the corresponding COLLADASW::StreamWriterException and cancel export then. NOTE: 51126fab3314 might have prevented the most common case to run into this crash (but there might be other cases still so being safe here does not hurt) Pull Request: https://projects.blender.org/blender/blender/pulls/118958 --- source/blender/io/collada/DocumentExporter.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/blender/io/collada/DocumentExporter.cpp b/source/blender/io/collada/DocumentExporter.cpp index f2039a3d7aa..68f05180da3 100644 --- a/source/blender/io/collada/DocumentExporter.cpp +++ b/source/blender/io/collada/DocumentExporter.cpp @@ -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(); + fprintf(stderr, "Collada: No Objects will be exported.\n"); + return 1; + } /* open */ writer->startDocument();