From c682830dd53f7e1fff8f97db62ad268089aacd13 Mon Sep 17 00:00:00 2001 From: chaigler Date: Thu, 2 Jul 2020 16:20:52 -0400 Subject: [PATCH] Fix crash in GuiEditCanvas::save() Fixes crash in GuiEditCanvas::save() if file location can't be written to. --- .../game/tools/guiEditor/scripts/guiEditorCanvas.ed.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorCanvas.ed.cs b/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorCanvas.ed.cs index b4025a14d..403c9996e 100644 --- a/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorCanvas.ed.cs +++ b/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorCanvas.ed.cs @@ -436,7 +436,13 @@ function GuiEditCanvas::save( %this, %selectedOnly, %noPrompt ) %fileObject.delete(); %fo = new FileObject(); - %fo.openForWrite(%filename); + if(!%fo.openForWrite(%filename)) + { + error("GuiEditCanvas::save() - Unable to save, file location not open for writing."); + %fo.close(); + + return false; + } // Write out the captured TorqueScript that was before the object before the object for( %i = 0; %i <= %beforeLines; %i++)