From 568b2abc1244228670a0d0e1dea768d8a7d8727e Mon Sep 17 00:00:00 2001 From: Tannin Date: Fri, 18 Dec 2015 20:16:28 +0100 Subject: removed close-mo feature --- src/editexecutablesdialog.cpp | 13 ------ src/editexecutablesdialog.ui | 17 -------- src/executableslist.cpp | 7 +--- src/executableslist.h | 8 +--- src/mainwindow.cpp | 5 +-- src/mainwindow.h | 2 +- src/organizercore.cpp | 92 +++++++++++++++++++------------------------ src/usvfsconnector.cpp | 3 +- 8 files changed, 46 insertions(+), 101 deletions(-) (limited to 'src') diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index b9d548a6..1b2d5a48 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -85,7 +85,6 @@ void EditExecutablesDialog::resetInput() ui->argumentsEdit->setText(""); ui->appIDOverwriteEdit->clear(); ui->overwriteAppIDBox->setChecked(false); - ui->closeCheckBox->setChecked(false); ui->useAppIconCheckBox->setChecked(false); m_CurrentItem = nullptr; } @@ -97,9 +96,6 @@ void EditExecutablesDialog::saveExecutable() QDir::fromNativeSeparators(ui->binaryEdit->text()), ui->argumentsEdit->text(), QDir::fromNativeSeparators(ui->workingDirEdit->text()), - (ui->closeCheckBox->checkState() == Qt::Checked) ? - ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE - : ExecutableInfo::CloseMOStyle::DEFAULT_STAY, ui->overwriteAppIDBox->isChecked() ? ui->appIDOverwriteEdit->text() : "", Executable::UseApplicationIcon | Executable::CustomExecutable, @@ -218,7 +214,6 @@ bool EditExecutablesDialog::executableChanged() || selectedExecutable.m_SteamAppID != ui->appIDOverwriteEdit->text() || selectedExecutable.m_WorkingDirectory != QDir::fromNativeSeparators(ui->workingDirEdit->text()) || selectedExecutable.m_BinaryInfo.absoluteFilePath() != QDir::fromNativeSeparators(ui->binaryEdit->text()) - || (selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE) != ui->closeCheckBox->isChecked() || selectedExecutable.usesOwnIcon() != ui->useAppIconCheckBox->isChecked(); } else { QFileInfo fileInfo(ui->binaryEdit->text()); @@ -291,14 +286,6 @@ void EditExecutablesDialog::on_executablesListBox_clicked(const QModelIndex &cur ui->binaryEdit->setText(QDir::toNativeSeparators(selectedExecutable.m_BinaryInfo.absoluteFilePath())); ui->argumentsEdit->setText(selectedExecutable.m_Arguments); ui->workingDirEdit->setText(QDir::toNativeSeparators(selectedExecutable.m_WorkingDirectory)); - ui->closeCheckBox->setChecked(selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE); - if (selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::NEVER_CLOSE) { - ui->closeCheckBox->setEnabled(false); - ui->closeCheckBox->setToolTip(tr("MO must be kept running or this application will not work correctly.")); - } else { - ui->closeCheckBox->setEnabled(true); - ui->closeCheckBox->setToolTip(tr("If checked, MO will be closed once the specified executable is run.")); - } ui->removeButton->setEnabled(selectedExecutable.isCustom()); ui->overwriteAppIDBox->setChecked(!selectedExecutable.m_SteamAppID.isEmpty()); if (!selectedExecutable.m_SteamAppID.isEmpty()) { diff --git a/src/editexecutablesdialog.ui b/src/editexecutablesdialog.ui index abb6fe68..a2aad19a 100644 --- a/src/editexecutablesdialog.ui +++ b/src/editexecutablesdialog.ui @@ -164,19 +164,6 @@ Right now the only case I know of where this needs to be overwritten is for the - - - - If checked, MO will be closed once the specified executable is run. - - - If checked, MO will be closed once the specified executable is run. - - - Close MO when started - - - @@ -247,10 +234,6 @@ Right now the only case I know of where this needs to be overwritten is for the - executablesListBox - closeButton - closeCheckBox - useAppIconCheckBox diff --git a/src/executableslist.cpp b/src/executableslist.cpp index a4511ade..9fe4596c 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -50,7 +50,6 @@ void ExecutablesList::init(IPluginGame const *game) info.binary().absoluteFilePath(), info.arguments().join(" "), info.workingDirectory().absolutePath(), - info.closeMO(), info.steamAppID()); } } @@ -135,7 +134,6 @@ void ExecutablesList::updateExecutable(const QString &title, const QString &executableName, const QString &arguments, const QString &workingDirectory, - ExecutableInfo::CloseMOStyle closeMO, const QString &steamAppID, Executable::Flags mask, Executable::Flags flags) @@ -146,7 +144,6 @@ void ExecutablesList::updateExecutable(const QString &title, if (existingExe != m_Executables.end()) { existingExe->m_Title = title; - existingExe->m_CloseMO = closeMO; existingExe->m_Flags &= ~mask; existingExe->m_Flags |= flags; // for pre-configured executables don't overwrite settings we didn't store @@ -162,7 +159,6 @@ void ExecutablesList::updateExecutable(const QString &title, } else { Executable newExe; newExe.m_Title = title; - newExe.m_CloseMO = closeMO; newExe.m_BinaryInfo = file; newExe.m_Arguments = arguments; newExe.m_WorkingDirectory = workingDirectory; @@ -186,12 +182,11 @@ void ExecutablesList::remove(const QString &title) void ExecutablesList::addExecutableInternal(const QString &title, const QString &executableName, const QString &arguments, const QString &workingDirectory, - ExecutableInfo::CloseMOStyle closeMO, const QString &steamAppID) + const QString &steamAppID) { QFileInfo file(executableName); if (file.exists()) { Executable newExe; - newExe.m_CloseMO = closeMO; newExe.m_BinaryInfo = file; newExe.m_Title = title; newExe.m_Arguments = arguments; diff --git a/src/executableslist.h b/src/executableslist.h index 3d5ba0ed..eb7d2d6f 100644 --- a/src/executableslist.h +++ b/src/executableslist.h @@ -36,7 +36,6 @@ struct Executable { QString m_Title; QFileInfo m_BinaryInfo; QString m_Arguments; - MOBase::ExecutableInfo::CloseMOStyle m_CloseMO; QString m_SteamAppID; QString m_WorkingDirectory; @@ -126,17 +125,15 @@ public: * @param title name displayed in the UI * @param executableName the actual filename to execute * @param arguments arguments to pass to the executable - * @param closeMO if true, MO will be closed when the binary is started **/ void addExecutable(const QString &title, const QString &executableName, const QString &arguments, const QString &workingDirectory, - MOBase::ExecutableInfo::CloseMOStyle closeMO, const QString &steamAppID, Executable::Flags flags) { - updateExecutable(title, executableName, arguments, workingDirectory, closeMO, steamAppID, Executable::AllFlags, flags); + updateExecutable(title, executableName, arguments, workingDirectory, steamAppID, Executable::AllFlags, flags); } /** @@ -151,7 +148,6 @@ public: const QString &executableName, const QString &arguments, const QString &workingDirectory, - MOBase::ExecutableInfo::CloseMOStyle closeMO, const QString &steamAppID, Executable::Flags mask, Executable::Flags flags); @@ -192,7 +188,7 @@ private: std::vector::iterator findExe(const QString &title); void addExecutableInternal(const QString &title, const QString &executableName, const QString &arguments, - const QString &workingDirectory, MOBase::ExecutableInfo::CloseMOStyle closeMO, + const QString &workingDirectory, const QString &steamAppID); private: diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index edcfe223..1a7d1564 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -583,7 +583,7 @@ bool MainWindow::errorReported(QString &logFile) } -int MainWindow::checkForProblems() +size_t MainWindow::checkForProblems() { size_t numProblems = 0; for (IPluginDiagnose *diagnose : m_PluginContainer.plugins()) { @@ -980,7 +980,6 @@ void MainWindow::startExeAction() selectedExecutable.m_Arguments, selectedExecutable.m_WorkingDirectory.length() != 0 ? selectedExecutable.m_WorkingDirectory : selectedExecutable.m_BinaryInfo.absolutePath(), - selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE, selectedExecutable.m_SteamAppID); } else { qCritical("not an action?"); @@ -1497,7 +1496,6 @@ void MainWindow::on_startButton_clicked() selectedExecutable.m_Arguments, selectedExecutable.m_WorkingDirectory.length() != 0 ? selectedExecutable.m_WorkingDirectory : selectedExecutable.m_BinaryInfo.absolutePath(), - selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE, selectedExecutable.m_SteamAppID); } @@ -3423,7 +3421,6 @@ void MainWindow::addAsExecutable() binaryInfo.absoluteFilePath(), arguments, targetInfo.absolutePath(), - ExecutableInfo::CloseMOStyle::DEFAULT_STAY, QString(), Executable::CustomExecutable); refreshExecutablesList(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 489f9145..49476bf3 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -209,7 +209,7 @@ private: bool extractProgress(QProgressDialog &extractProgress, int percentage, std::string fileName); - int checkForProblems(); + size_t checkForProblems(); int getBinaryExecuteInfo(const QFileInfo &targetInfo, QFileInfo &binaryInfo, QString &arguments); QTreeWidgetItem *addFilterItem(QTreeWidgetItem *root, const QString &name, int categoryID, ModListSortProxy::FilterType type); diff --git a/src/organizercore.cpp b/src/organizercore.cpp index fdc11c2a..59a58e48 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -236,7 +236,6 @@ QSettings::Status OrganizerCore::storeSettings(const QString &fileName) settings.setValue("binary", item.m_BinaryInfo.absoluteFilePath()); settings.setValue("arguments", item.m_Arguments); settings.setValue("workingDirectory", item.m_WorkingDirectory); - settings.setValue("closeOnStart", item.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE); settings.setValue("steamAppID", item.m_SteamAppID); } } @@ -338,9 +337,6 @@ void OrganizerCore::updateExecutablesList(QSettings &settings) int numCustomExecutables = settings.beginReadArray("customExecutables"); for (int i = 0; i < numCustomExecutables; ++i) { settings.setArrayIndex(i); - ExecutableInfo::CloseMOStyle closeMO = - settings.value("closeOnStart").toBool() ? ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE - : ExecutableInfo::CloseMOStyle::DEFAULT_STAY; Executable::Flags flags; if (settings.value("custom", true).toBool()) flags |= Executable::CustomExecutable; @@ -351,7 +347,6 @@ void OrganizerCore::updateExecutablesList(QSettings &settings) settings.value("binary").toString(), settings.value("arguments").toString(), settings.value("workingDirectory", "").toString(), - closeMO, settings.value("steamAppID", "").toString(), flags); } @@ -875,7 +870,7 @@ ModList *OrganizerCore::modList() return &m_ModList; } -void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &arguments, const QDir ¤tDirectory, bool closeAfterStart, const QString &steamAppID) +void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &arguments, const QDir ¤tDirectory, const QString &steamAppID) { LockedDialog *dialog = new LockedDialog(qApp->activeWindow()); dialog->show(); @@ -883,55 +878,52 @@ void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &argument HANDLE processHandle = spawnBinaryDirect(binary, arguments, m_CurrentProfile->name(), currentDirectory, steamAppID); if (processHandle != INVALID_HANDLE_VALUE) { - if (closeAfterStart && (m_UserInterface != nullptr)) { - m_UserInterface->closeWindow(); - } else { - if (m_UserInterface != nullptr) { - m_UserInterface->setWindowEnabled(false); - } - // re-enable the locked dialog because what'd be the point otherwise? - dialog->setEnabled(true); - - QCoreApplication::processEvents(); - - DWORD processExitCode; - DWORD retLen; - JOBOBJECT_BASIC_PROCESS_ID_LIST info; - - { - DWORD currentProcess = 0UL; - bool isJobHandle = true; - - DWORD res = ::MsgWaitForMultipleObjects(1, &processHandle, false, 1000, QS_KEY | QS_MOUSE); - while ((res != WAIT_FAILED) && (res != WAIT_OBJECT_0) && !dialog->unlockClicked()) { - if (isJobHandle) { - if (::QueryInformationJobObject(processHandle, JobObjectBasicProcessIdList, &info, sizeof(info), &retLen) > 0) { - if (info.NumberOfProcessIdsInList == 0) { - break; - } else { - if (info.ProcessIdList[0] != currentProcess) { - currentProcess = info.ProcessIdList[0]; - dialog->setProcessName(ToQString(getProcessName(currentProcess))); - } - } + if (m_UserInterface != nullptr) { + m_UserInterface->setWindowEnabled(false); + } + // re-enable the locked dialog because what'd be the point otherwise? + dialog->setEnabled(true); + + QCoreApplication::processEvents(); + + DWORD processExitCode; + DWORD retLen; + JOBOBJECT_BASIC_PROCESS_ID_LIST info; + + { + DWORD currentProcess = 0UL; + bool isJobHandle = true; + + DWORD res = ::MsgWaitForMultipleObjects(1, &processHandle, false, 1000, QS_KEY | QS_MOUSE); + while ((res != WAIT_FAILED) && (res != WAIT_OBJECT_0) && !dialog->unlockClicked()) { + if (isJobHandle) { + if (::QueryInformationJobObject(processHandle, JobObjectBasicProcessIdList, &info, sizeof(info), &retLen) > 0) { + if (info.NumberOfProcessIdsInList == 0) { + break; } else { - // the info-object I passed only provides space for 1 process id. but since this code only cares about whether there - // is more than one that's good enough. ERROR_MORE_DATA simply signals there are at least two processes running. - // any other error probably means the handle is a regular process handle, probably caused by running MO in a job without - // the right to break out. - if (::GetLastError() != ERROR_MORE_DATA) { - isJobHandle = false; + if (info.ProcessIdList[0] != currentProcess) { + currentProcess = info.ProcessIdList[0]; + dialog->setProcessName(ToQString(getProcessName(currentProcess))); } } + } else { + // the info-object I passed only provides space for 1 process id. but since this code only cares about whether there + // is more than one that's good enough. ERROR_MORE_DATA simply signals there are at least two processes running. + // any other error probably means the handle is a regular process handle, probably caused by running MO in a job without + // the right to break out. + if (::GetLastError() != ERROR_MORE_DATA) { + isJobHandle = false; + } } + } - // keep processing events so the app doesn't appear dead - QCoreApplication::processEvents(); + // keep processing events so the app doesn't appear dead + QCoreApplication::processEvents(); - res = ::MsgWaitForMultipleObjects(1, &processHandle, false, 1000, QS_KEY | QS_MOUSE); - } - ::GetExitCodeProcess(processHandle, &processExitCode); + res = ::MsgWaitForMultipleObjects(1, &processHandle, false, 1000, QS_KEY | QS_MOUSE); } + ::GetExitCodeProcess(processHandle, &processExitCode); + ::CloseHandle(processHandle); if (m_UserInterface != nullptr) { @@ -1640,10 +1632,6 @@ std::vector OrganizerCore::fileMapping( directoryEntry->getSubDirectories(current, end); for (; current != end; ++current) { int origin = (*current)->anyOrigin(); - /* - if (origin == 0) { - continue; - }*/ QString originPath = QString::fromStdWString(base->getOriginByID(origin).getPath()); diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp index 23a51891..f3a45dfe 100644 --- a/src/usvfsconnector.cpp +++ b/src/usvfsconnector.cpp @@ -60,8 +60,7 @@ LogWorker::LogWorker() QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd_hh-mm-ss"))) { m_LogFile.open(QIODevice::WriteOnly); - qDebug("usvfs log messages are written to %s", - qPrintable(m_LogFile.fileName())); + qDebug("usvfs log messages are written to %s", qPrintable(m_LogFile.fileName())); } LogWorker::~LogWorker() -- cgit v1.3.1