From 3346f812a9c65a2c97acc0bd95cedcd219e410c1 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sun, 12 Jan 2020 17:18:08 +0000 Subject: [PATCH] Cleanup error handling in VRML export (from coverity scan) --- pcbnew/dialogs/dialog_export_vrml.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/pcbnew/dialogs/dialog_export_vrml.cpp b/pcbnew/dialogs/dialog_export_vrml.cpp index 0a665f6313..b260134632 100644 --- a/pcbnew/dialogs/dialog_export_vrml.cpp +++ b/pcbnew/dialogs/dialog_export_vrml.cpp @@ -28,12 +28,12 @@ */ #include -#include -#include -#include - -#include #include +#include +#include +#include +#include +#include /* the dialog to create VRML files, derived from DIALOG_EXPORT_3DFILE_BASE, @@ -239,15 +239,20 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event ) if( export3DFiles && !modelPath.DirExists() ) { - modelPath.Mkdir(); + if( !modelPath.Mkdir() ) + { + wxString msg = wxString::Format( + _( "Unable to create directory \"%s\"" ), modelPath.GetPath() ); + DisplayErrorMessage( this, msg ); + return; + } } if( !ExportVRML_File( path, scale, export3DFiles, useRelativePaths, usePlainPCB, modelPath.GetPath(), aXRef, aYRef ) ) { - wxString msg; - msg.Printf( _( "Unable to create file \"%s\"" ), path ); - wxMessageBox( msg ); + wxString msg = wxString::Format( _( "Unable to create file \"%s\"" ), path ); + DisplayErrorMessage( this, msg ); return; } }