Stop libsyncthing when stopping the application

This commit is contained in:
Martchus 2019-07-29 16:00:41 +02:00
parent f9eba2d012
commit 972f7b2776
3 changed files with 20 additions and 6 deletions

View File

@ -128,9 +128,8 @@ void SyncthingLauncher::terminate()
if (m_process.isRunning()) {
m_manuallyStopped = true;
m_process.stopSyncthing();
} else if (m_future.isRunning()) {
m_manuallyStopped = true;
QtConcurrent::run(this, &SyncthingLauncher::stopLibSyncthing);
} else {
tearDownLibSyncthing();
}
}
@ -139,12 +138,22 @@ void SyncthingLauncher::kill()
if (m_process.isRunning()) {
m_manuallyStopped = true;
m_process.killSyncthing();
} else if (m_future.isRunning()) {
m_manuallyStopped = true;
QtConcurrent::run(this, &SyncthingLauncher::stopLibSyncthing);
} else {
tearDownLibSyncthing();
}
}
void SyncthingLauncher::tearDownLibSyncthing()
{
#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING
if (!m_future.isRunning()) {
return;
}
m_manuallyStopped = true;
QtConcurrent::run(this, &SyncthingLauncher::stopLibSyncthing);
#endif
}
void SyncthingLauncher::handleProcessReadyRead()
{
emit outputAvailable(m_process.readAll());

View File

@ -49,6 +49,7 @@ public Q_SLOTS:
void launch(const LibSyncthing::RuntimeOptions &runtimeOptions);
void terminate();
void kill();
void tearDownLibSyncthing();
private Q_SLOTS:
void handleProcessReadyRead();

View File

@ -107,6 +107,10 @@ void Launcher::autostart() const
*/
void Launcher::terminate()
{
auto *const launcher = SyncthingLauncher::mainInstance();
if (launcher) {
launcher->tearDownLibSyncthing();
}
QtGui::SyncthingKiller(allProcesses()).waitForFinished();
}