Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions include/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,4 @@ private slots:

} ;

class AutoSaveThread : public QThread
{
Q_OBJECT
public:
void run();
} ;

#endif
33 changes: 33 additions & 0 deletions include/RemotePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,11 @@ class EXPORT RemotePluginBase
fetchAndProcessNextMessage();
}
}

static bool isMainThreadWaiting()
{
return waitDepthCounter() > 0;
}
#endif

virtual bool processMessage( const message & _m ) = 0;
Expand Down Expand Up @@ -657,6 +662,14 @@ class EXPORT RemotePluginBase


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;
Expand Down Expand Up @@ -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() )
{
Expand Down
21 changes: 7 additions & 14 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -1554,11 +1555,3 @@ void MainWindow::autoSave()
}
}
}




void AutoSaveThread::run()
{
Engine::getSong()->saveProjectFile(ConfigManager::inst()->recoveryFile());
}