Stop some autosave crashes (#3841)
This commit is contained in:
@@ -249,11 +249,4 @@ signals:
|
||||
|
||||
} ;
|
||||
|
||||
class AutoSaveThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
void run();
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -621,6 +621,11 @@ public:
|
||||
fetchAndProcessNextMessage();
|
||||
}
|
||||
}
|
||||
|
||||
static bool isMainThreadWaiting()
|
||||
{
|
||||
return waitDepthCounter() > 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual bool processMessage( const message & _m ) = 0;
|
||||
@@ -657,6 +662,14 @@ protected:
|
||||
|
||||
|
||||
private:
|
||||
#ifndef BUILD_REMOTE_PLUGIN_CLIENT
|
||||
static int & waitDepthCounter()
|
||||
{
|
||||
static int waitDepth = 0;
|
||||
return waitDepth;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SYNC_WITH_SHM_FIFO
|
||||
shmFifo * m_in;
|
||||
shmFifo * m_out;
|
||||
@@ -1089,6 +1102,26 @@ RemotePluginBase::message RemotePluginBase::waitForMessage(
|
||||
_busy_waiting = QThread::currentThread() ==
|
||||
QCoreApplication::instance()->thread();
|
||||
}
|
||||
|
||||
struct WaitDepthCounter
|
||||
{
|
||||
WaitDepthCounter( int & depth, bool busy ) :
|
||||
m_depth( depth ),
|
||||
m_busy( busy )
|
||||
{
|
||||
if( m_busy ) { ++m_depth; }
|
||||
}
|
||||
|
||||
~WaitDepthCounter()
|
||||
{
|
||||
if( m_busy ) { --m_depth; }
|
||||
}
|
||||
|
||||
int & m_depth;
|
||||
bool m_busy;
|
||||
};
|
||||
|
||||
WaitDepthCounter wdc( waitDepthCounter(), _busy_waiting );
|
||||
#endif
|
||||
while( !isInvalid() )
|
||||
{
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "PluginView.h"
|
||||
#include "ProjectJournal.h"
|
||||
#include "ProjectNotes.h"
|
||||
#include "RemotePlugin.h"
|
||||
#include "SetupDialog.h"
|
||||
#include "SideBar.h"
|
||||
#include "SongEditor.h"
|
||||
@@ -1535,14 +1536,14 @@ void MainWindow::browseHelp()
|
||||
void MainWindow::autoSave()
|
||||
{
|
||||
if( !Engine::getSong()->isExporting() &&
|
||||
!Engine::getSong()->isLoadingProject() &&
|
||||
!RemotePluginBase::isMainThreadWaiting() &&
|
||||
!QApplication::mouseButtons() &&
|
||||
( ConfigManager::inst()->value( "ui",
|
||||
"enablerunningautosave" ).toInt() ||
|
||||
! Engine::getSong()->isPlaying() ) )
|
||||
( ConfigManager::inst()->value( "ui",
|
||||
"enablerunningautosave" ).toInt() ||
|
||||
! Engine::getSong()->isPlaying() ) )
|
||||
{
|
||||
AutoSaveThread * ast = new AutoSaveThread();
|
||||
connect( ast, SIGNAL( finished() ), ast, SLOT( deleteLater() ) );
|
||||
ast->start();
|
||||
Engine::getSong()->saveProjectFile(ConfigManager::inst()->recoveryFile());
|
||||
autoSaveTimerReset(); // Reset timer
|
||||
}
|
||||
else
|
||||
@@ -1554,11 +1555,3 @@ void MainWindow::autoSave()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AutoSaveThread::run()
|
||||
{
|
||||
Engine::getSong()->saveProjectFile(ConfigManager::inst()->recoveryFile());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user