Default project when cancelling project loading (#3941)

Default project when cancelling project loading

If a user isn't aware that the loading of a project has been
cancelled, it may be in an incomplete state. Saving such a project
will overwrite the original file and result in data loss. This is
solved by loading the default project on cancelling project loading.

Add Mixer::clearNewPlayHandles() to prevent crash when cancelling
loading of a single streamed instrument.
This commit is contained in:
Oskar Wallgren
2017-11-17 02:03:49 +01:00
committed by GitHub
parent 601046aa03
commit 01265ace66
5 changed files with 48 additions and 2 deletions

View File

@@ -501,6 +501,20 @@ void Mixer::clear()
void Mixer::clearNewPlayHandles()
{
requestChangeInModel();
for( LocklessListElement * e = m_newPlayHandles.popList(); e; )
{
LocklessListElement * next = e->next;
m_newPlayHandles.free( e );
e = next;
}
doneChangeInModel();
}
// removes all play-handles. this is necessary, when the song is stopped ->
// all remaining notes etc. would be played until their end
void Mixer::clearInternal()

View File

@@ -86,6 +86,7 @@ Song::Song() :
m_playing( false ),
m_paused( false ),
m_loadingProject( false ),
m_isCancelled( false ),
m_playMode( Mode_None ),
m_length( 0 ),
m_patternToPlay( NULL ),
@@ -1074,7 +1075,7 @@ void Song::loadProject( const QString & fileName )
}
}
while( !node.isNull() )
while( !node.isNull() && !isCancelled() )
{
if( node.isElement() )
{
@@ -1133,6 +1134,13 @@ void Song::loadProject( const QString & fileName )
emit projectLoaded();
if( isCancelled() )
{
m_isCancelled = false;
createNewProject();
return;
}
if ( hasErrors())
{
if ( gui )
@@ -1278,7 +1286,7 @@ void Song::saveControllerStates( QDomDocument & doc, QDomElement & element )
void Song::restoreControllerStates( const QDomElement & element )
{
QDomNode node = element.firstChild();
while( !node.isNull() )
while( !node.isNull() && !isCancelled() )
{
Controller * c = Controller::create( node.toElement(), this );
Q_ASSERT( c != NULL );

View File

@@ -33,12 +33,14 @@
#include "AutomationTrack.h"
#include "BBTrack.h"
#include "BBTrackContainer.h"
#include "embed.h"
#include "TrackContainer.h"
#include "InstrumentTrack.h"
#include "Song.h"
#include "GuiApplication.h"
#include "MainWindow.h"
#include "TextFloat.h"
TrackContainer::TrackContainer() :
Model( NULL ),
@@ -110,6 +112,14 @@ void TrackContainer::loadSettings( const QDomElement & _this )
QEventLoop::AllEvents, 100 );
if( pd->wasCanceled() )
{
if ( gui )
{
TextFloat::displayMessage( tr( "Loading cancelled" ),
tr( "Project loading was cancelled." ),
embed::getIconPixmap( "project_file", 24, 24 ),
2000 );
}
Engine::getSong()->loadingCancelled();
break;
}
}