From 3f8cfbd7a82319ce3210590a8df1d815caaf402e Mon Sep 17 00:00:00 2001 From: "Christopher L. Simons" Date: Tue, 10 Mar 2015 06:47:05 -0400 Subject: [PATCH 1/3] No longer halting playback when 'Open project' dialog is summoned; fixes #1384 --- src/gui/MainWindow.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 63b90179b..de12baaa8 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -620,8 +620,6 @@ void MainWindow::resetWindowTitle() bool MainWindow::mayChangeProject() { - Engine::getSong()->stop(); - if( !Engine::getSong()->isModified() ) { return( true ); From 393eacad7dc6d56eb2dd2565c3aa56fba84c50b8 Mon Sep 17 00:00:00 2001 From: "Christopher L. Simons" Date: Tue, 10 Mar 2015 07:05:10 -0400 Subject: [PATCH 2/3] Ensuring playback is halted once file selection is confirmed in 'Open project' dialog; fixes #1384 --- src/gui/MainWindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index de12baaa8..6c052593a 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -767,6 +767,8 @@ void MainWindow::openProject() if( ofd.exec () == QDialog::Accepted && !ofd.selectedFiles().isEmpty() ) { + Engine::getSong()->stop(); + setCursor( Qt::WaitCursor ); Engine::getSong()->loadProject( ofd.selectedFiles()[0] ); From 95c7d72a90858616c63014c49cbe9623931d5966 Mon Sep 17 00:00:00 2001 From: "Christopher L. Simons" Date: Tue, 10 Mar 2015 07:41:13 -0400 Subject: [PATCH 3/3] Added 'bool stopPlayback' parameter to MainWindow::mayChangeProject() to preserve old behavior outside of 'Open project dialog' case; fixes #1384 --- include/MainWindow.h | 4 +++- src/gui/FileBrowser.cpp | 4 ++-- src/gui/MainWindow.cpp | 15 +++++++++------ src/gui/TrackContainerView.cpp | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/include/MainWindow.h b/include/MainWindow.h index 86ab8adc6..5e1f294ae 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h @@ -69,10 +69,12 @@ public: /// opens another file...) must call this before and may only proceed if /// this function returns true. /// + /// \param stopPlayback whether playback should be stopped upon prompting. If set to false, the caller should ensure that Engine::getSong()->stop() is called before unloading/loading a song. + /// /// \return true if the user allows the software to proceed, false if they /// cancel the action. /// - bool mayChangeProject(); + bool mayChangeProject(bool stopPlayback); void clearKeyModifiers(); diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index 942e1f360..6ea9d5134 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -583,7 +583,7 @@ void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it ) switch( f->handling() ) { case FileItem::LoadAsProject: - if( gui->mainWindow()->mayChangeProject() ) + if( gui->mainWindow()->mayChangeProject(true) ) { Engine::getSong()->loadProject( f->fullName() ); } @@ -614,7 +614,7 @@ void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it ) case FileItem::ImportAsProject: if( f->type() == FileItem::FlpFile && - !gui->mainWindow()->mayChangeProject() ) + !gui->mainWindow()->mayChangeProject(true) ) { break; } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 6c052593a..8250163af 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -618,8 +618,11 @@ void MainWindow::resetWindowTitle() -bool MainWindow::mayChangeProject() +bool MainWindow::mayChangeProject(bool stopPlayback) { + if( stopPlayback ) + Engine::getSong()->stop(); + if( !Engine::getSong()->isModified() ) { return( true ); @@ -731,7 +734,7 @@ void MainWindow::enterWhatsThisMode() void MainWindow::createNewProject() { - if( mayChangeProject() ) + if( mayChangeProject(true) ) { Engine::getSong()->createNewProject(); } @@ -742,7 +745,7 @@ void MainWindow::createNewProject() void MainWindow::createNewProjectFromTemplate( QAction * _idx ) { - if( m_templatesMenu != NULL && mayChangeProject() ) + if( m_templatesMenu != NULL && mayChangeProject(true) ) { QString dir_base = m_templatesMenu->actions().indexOf( _idx ) >= m_custom_templates_count ? @@ -758,7 +761,7 @@ void MainWindow::createNewProjectFromTemplate( QAction * _idx ) void MainWindow::openProject() { - if( mayChangeProject() ) + if( mayChangeProject(false) ) { FileDialog ofd( this, tr( "Open Project" ), "", tr( "LMMS (*.mmp *.mmpz)" ) ); @@ -796,7 +799,7 @@ void MainWindow::updateRecentlyOpenedProjectsMenu() void MainWindow::openRecentlyOpenedProject( QAction * _action ) { - if ( mayChangeProject() ) + if ( mayChangeProject(true) ) { const QString & f = _action->text(); setCursor( Qt::WaitCursor ); @@ -1185,7 +1188,7 @@ void MainWindow::redo() void MainWindow::closeEvent( QCloseEvent * _ce ) { - if( mayChangeProject() ) + if( mayChangeProject(true) ) { // delete recovery file QFile::remove(ConfigManager::inst()->recoveryFile()); diff --git a/src/gui/TrackContainerView.cpp b/src/gui/TrackContainerView.cpp index 4513e9edf..f49f75bba 100644 --- a/src/gui/TrackContainerView.cpp +++ b/src/gui/TrackContainerView.cpp @@ -377,7 +377,7 @@ void TrackContainerView::dropEvent( QDropEvent * _de ) else if( type == "projectfile") { - if( gui->mainWindow()->mayChangeProject() ) + if( gui->mainWindow()->mayChangeProject(true) ) { Engine::getSong()->loadProject( value ); }