summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2014-01-03 18:40:46 +0100
committerTannin <devnull@localhost>2014-01-03 18:40:46 +0100
commitd029e97724711ee7974f6ddb2460c215ad39f561 (patch)
tree2a9cf43f430e8e4ff502b3dc33cd8f6b551ade03 /src/mainwindow.cpp
parenta9435f637e8c83d189ee467cdc640b263f27d206 (diff)
- hook dll now monitors all mod directories, not only overwrite
- dialog for changing executables now warns if changes will be lost - main window is now locked before activating pre-start hooks - better responsiveness while main window is locked (or should be)
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index b9300d00..77e4cb3b 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -100,6 +100,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QNetworkProxy>
#include <QtConcurrentRun>
#include <QCoreApplication>
+#include <scopeguard.h>
#ifdef TEST_MODELS
@@ -1287,10 +1288,11 @@ HANDLE MainWindow::spawnBinaryDirect(const QFileInfo &binary, const QString &arg
}
while (m_RefreshProgress->isVisible()) {
- ::Sleep(1000);
+ ::Sleep(100);
QCoreApplication::processEvents();
}
+ // TODO: should also pass arguments
if (m_AboutToRun(binary.absoluteFilePath())) {
return startBinary(binary, arguments, profileName, m_Settings.logLevel(), currentDirectory, true);
} else {
@@ -1321,10 +1323,15 @@ void MainWindow::spawnProgram(const QString &fileName, const QString &argumentsA
}
*/
+
void MainWindow::spawnBinary(const QFileInfo &binary, const QString &arguments, const QDir &currentDirectory, bool closeAfterStart, const QString &steamAppID)
{
storeSettings();
+ LockedDialog *dialog = new LockedDialog(this);
+ dialog->show();
+ ON_BLOCK_EXIT([&] () { dialog->hide(); dialog->deleteLater(); });
+
HANDLE processHandle = spawnBinaryDirect(binary, arguments, m_CurrentProfile->getName(), currentDirectory, steamAppID);
if (processHandle != INVALID_HANDLE_VALUE) {
if (closeAfterStart) {
@@ -1332,12 +1339,9 @@ void MainWindow::spawnBinary(const QFileInfo &binary, const QString &arguments,
} else {
this->setEnabled(false);
- LockedDialog *dialog = new LockedDialog(this);
- dialog->show();
-
QCoreApplication::processEvents();
- while ((::WaitForSingleObject(processHandle, 1000) == WAIT_TIMEOUT) &&
+ while ((::WaitForSingleObject(processHandle, 100) == WAIT_TIMEOUT) &&
!dialog->unlockClicked()) {
// keep processing events so the app doesn't appear dead
QCoreApplication::processEvents();
@@ -1348,8 +1352,6 @@ void MainWindow::spawnBinary(const QFileInfo &binary, const QString &arguments,
if (GameInfo::instance().getLoadOrderMechanism() == GameInfo::TYPE_FILETIME) {
QFile::remove(m_CurrentProfile->getLoadOrderFileName());
}
- dialog->hide();
- dialog->deleteLater();
}
}
}