New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix export - double dialog windows on writing over existing file #3526

Merged
merged 2 commits into from May 30, 2017
Jump to file or symbol
Failed to load files and symbols.
+9 −9
Diff settings

Always

Just for now

Next

Fix export - double dialog windows on writing over existing file

  • Loading branch information...
zonkmachine committed Feb 7, 2017
commit efdbb34eab8131b4860af457c939bb54323d7f5d
Copy path View file
@@ -1398,13 +1398,14 @@ void Song::exportProject( bool multiExport )
efd.setWindowTitle( tr( "Select file for project-export..." ) );
}
QString suffix = "wav";
efd.setDefaultSuffix( suffix );
efd.setAcceptMode( FileDialog::AcceptSave );
if( efd.exec() == QDialog::Accepted && !efd.selectedFiles().isEmpty() &&
!efd.selectedFiles()[0].isEmpty() )
{
QString suffix = "";
QString exportFileName = efd.selectedFiles()[0];
if ( !multiExport )
{
@@ -1416,19 +1417,18 @@ void Song::exportProject( bool multiExport )
// Get first extension from selected dropdown.
// i.e. ".wav" from "WAV-File (*.wav), Dummy-File (*.dum)"
suffix = efd.selectedNameFilter().mid( stx + 2, etx - stx - 2 ).split( " " )[0].trimmed();
exportFileName.remove( "." + suffix );

This comment has been minimized.

@tresf

tresf May 2, 2017

Member

Two observations about remove(...)...

  1. By defaul it's case insensitive by default which can cause issues on Mac and Windows, since they're both case-insensitive (yes, Mac is too!)
  2. This will remove all instances of e.g. .wav, so there are some edge cases where my.wav.file.wav might get snagged, no?
if ( efd.selectedFiles()[0].endsWith( suffix ) )
{
suffix = "";
if( VersionedSaveDialog::fileExistsQuery( exportFileName + suffix,
tr( "Save project" ) ) )
{
exportFileName += suffix;
}
}
}
}
if( VersionedSaveDialog::fileExistsQuery( exportFileName + suffix,
tr( "Save project" ) ) )
{
exportFileName += suffix;
}
ExportProjectDialog epd( exportFileName, gui->mainWindow(), multiExport );
epd.exec();
}
ProTip! Use n and p to navigate between commits in a pull request.