From efc0e6793461e1ac99ef7fcdd0b374209f75f9d9 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 30 May 2016 16:30:39 -0400 Subject: [PATCH] Theme Preferences, Save Files overwrites all components after asking --- src/Theme.cpp | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/Theme.cpp b/src/Theme.cpp index 40c8947c3..41d187ade 100644 --- a/src/Theme.cpp +++ b/src/Theme.cpp @@ -960,27 +960,41 @@ void ThemeBase::SaveComponents() if( (mBitmapFlags[i] & resFlagInternal)==0) { FileName = FileNames::ThemeComponent( mBitmapNames[i] ); - if( !wxFileExists( FileName )) + if( wxFileExists( FileName )) { - if( !mImages[i].SaveFile( FileName, wxBITMAP_TYPE_PNG )) - { - wxMessageBox( - wxString::Format( - _("Audacity could not save file:\n %s"), - FileName.c_str() )); - return; - } - n++; + ++n; + break; } } } - if( n==0 ) + + if (n > 0) { - wxMessageBox( - wxString::Format( - _("All required files in:\n %s\nwere already present."), - FileNames::ThemeComponentsDir().c_str() )); - return; + auto result = + wxMessageBox( + wxString::Format( + _("Some required files in:\n %s\nwere already present. Overwrite?"), + FileNames::ThemeComponentsDir().c_str()), + wxMessageBoxCaptionStr, + wxYES_NO | wxNO_DEFAULT); + if(result == wxNO) + return; + } + + for(i=0;i<(int)mImages.GetCount();i++) + { + if( (mBitmapFlags[i] & resFlagInternal)==0) + { + FileName = FileNames::ThemeComponent( mBitmapNames[i] ); + if( !mImages[i].SaveFile( FileName, wxBITMAP_TYPE_PNG )) + { + wxMessageBox( + wxString::Format( + _("Audacity could not save file:\n %s"), + FileName.c_str() )); + return; + } + } } wxMessageBox( wxString::Format(