From c7101be7d8a077eba563a6fd6f15ec8169eeca51 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 25 Jun 2016 11:47:15 +0100 Subject: Some refactoring of the spawn code and to make waitForApplication get the right error code (usually) A note: It is possible for the executed program to completely exit before MO attempts to get hold of the pid from the job handle, in which case strangeness will happen (this has always been an issue) --- src/mainwindow.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 096ce94b..702e661d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1608,18 +1608,31 @@ void MainWindow::storeSettings(QSettings &settings) void MainWindow::lock() { + if (m_LockDialog != nullptr) { + ++m_LockCount; + return; + } m_LockDialog = new LockedDialog(qApp->activeWindow()); m_LockDialog->show(); setEnabled(false); + m_LockDialog->setEnabled(true); //What's the point otherwise? + ++m_LockCount; } void MainWindow::unlock() { - if (m_LockDialog != nullptr) { + //If you come through here with a null lock pointer, it's a bug! + if (m_LockDialog == nullptr) { + qDebug("Unlocking main window when already unlocked"); + return; + } + --m_LockCount; + if (m_LockCount == 0) { m_LockDialog->hide(); m_LockDialog->deleteLater(); + m_LockDialog = nullptr; + setEnabled(true); } - setEnabled(true); } bool MainWindow::unlockClicked() @@ -1631,6 +1644,13 @@ bool MainWindow::unlockClicked() } } +void MainWindow::setProcessName(QString const &name) +{ + if (m_LockDialog != nullptr) { + m_LockDialog->setProcessName(name); + } +} + void MainWindow::on_btnRefreshData_clicked() { m_OrganizerCore.refreshDirectoryStructure(); -- cgit v1.3.1