summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mainwindow.cpp3
-rw-r--r--src/organizercore.cpp3
-rw-r--r--src/usvfsconnector.cpp4
-rw-r--r--src/usvfsconnector.h16
4 files changed, 25 insertions, 1 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index e6b454c5..3c749bf5 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -5012,6 +5012,9 @@ void MainWindow::on_bossButton_clicked()
createStdoutPipe(&stdOutRead, &stdOutWrite);
try {
m_OrganizerCore.prepareVFS();
+ } catch (const UsvfsConnectorException &e) {
+ qDebug(e.what());
+ return;
} catch (const std::exception &e) {
QMessageBox::warning(qApp->activeWindow(), tr("Error"), e.what());
return;
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 74ec752e..5c85e323 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -1311,6 +1311,9 @@ HANDLE OrganizerCore::spawnBinaryProcess(const QFileInfo &binary,
if (m_AboutToRun(binary.absoluteFilePath())) {
try {
m_USVFS.updateMapping(fileMapping(profileName, customOverwrite));
+ } catch (const UsvfsConnectorException &e) {
+ qDebug(e.what());
+ return INVALID_HANDLE_VALUE;
} catch (const std::exception &e) {
QMessageBox::warning(window, tr("Error"), e.what());
return INVALID_HANDLE_VALUE;
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
index ffbdf3aa..4ffc81c0 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.cpp
@@ -166,6 +166,10 @@ void UsvfsConnector::updateMapping(const MappingType &mapping)
ClearVirtualMappings();
for (auto map : mapping) {
+ if (progress.wasCanceled()) {
+ ClearVirtualMappings();
+ throw UsvfsConnectorException("VFS mapping canceled by user");
+ }
progress.setValue(value++);
if (value % 10 == 0) {
QCoreApplication::processEvents();
diff --git a/src/usvfsconnector.h b/src/usvfsconnector.h
index 0935bac1..40f8857b 100644
--- a/src/usvfsconnector.h
+++ b/src/usvfsconnector.h
@@ -21,7 +21,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#ifndef USVFSCONNECTOR_H
#define USVFSCONNECTOR_H
-
+#include <exception>
#include <filemapping.h>
#include <QString>
#include <QThread>
@@ -58,6 +58,20 @@ private:
};
+class UsvfsConnectorException : public std::exception {
+
+public:
+ UsvfsConnectorException(const QString &text)
+ : std::exception(), m_Message(text.toLocal8Bit()) {}
+
+ virtual const char* what() const throw()
+ { return m_Message.constData(); }
+private:
+ QByteArray m_Message;
+
+};
+
+
class UsvfsConnector : public QObject {
Q_OBJECT