From 5777b1905c9ec3b445e60062b9803d227d0b26b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sat, 7 Jul 2018 12:39:28 +0200 Subject: [PATCH] Do not show MainWindow if loading failed --- src/AnalTask.cpp | 2 ++ src/AnalTask.h | 4 ++++ src/dialogs/AsyncTaskDialog.cpp | 1 - src/dialogs/OptionsDialog.cpp | 8 +++++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/AnalTask.cpp b/src/AnalTask.cpp index 15d7ff6e..5afc9a88 100644 --- a/src/AnalTask.cpp +++ b/src/AnalTask.cpp @@ -24,6 +24,7 @@ void AnalTask::interrupt() void AnalTask::runTask() { log(tr("Loading Binary...\n")); + openFailed = false; Core()->setCPU(options.arch, options.cpu, options.bits); @@ -46,6 +47,7 @@ void AnalTask::runTask() options.forceBinPlugin); if (!fileLoaded) { // Something wrong happened, fallback to open dialog + openFailed = true; emit openFileFailed(); interrupt(); return; diff --git a/src/AnalTask.h b/src/AnalTask.h index 4ff8e6ee..3cdf1cce 100644 --- a/src/AnalTask.h +++ b/src/AnalTask.h @@ -53,6 +53,8 @@ public: void interrupt() override; + bool getOpenFileFailed() { return openFailed; } + protected: void runTask() override; @@ -61,6 +63,8 @@ signals: private: InitialOptions options; + + bool openFailed = false; }; #endif // ANALTHREAD_H diff --git a/src/dialogs/AsyncTaskDialog.cpp b/src/dialogs/AsyncTaskDialog.cpp index d34556d0..6f805013 100644 --- a/src/dialogs/AsyncTaskDialog.cpp +++ b/src/dialogs/AsyncTaskDialog.cpp @@ -57,7 +57,6 @@ void AsyncTaskDialog::updateProgressTimer() label += " "; } label += tr("%n seconds", "%n second", secondsElapsed % 60); - printf("setText %s\n", label.toLocal8Bit().constData()); ui->timeLabel->setText(label); } diff --git a/src/dialogs/OptionsDialog.cpp b/src/dialogs/OptionsDialog.cpp index 8987b33e..7db4db9e 100644 --- a/src/dialogs/OptionsDialog.cpp +++ b/src/dialogs/OptionsDialog.cpp @@ -237,8 +237,14 @@ void OptionsDialog::setupAndStartAnalysis(int level, QList advanced) AnalTask *analTask = new AnalTask(); analTask->setOptions(options); + MainWindow *main = this->main; connect(analTask, &AnalTask::openFileFailed, main, &MainWindow::openNewFileFailed); - connect(analTask, &AsyncTask::finished, main, &MainWindow::finalizeOpen); + connect(analTask, &AsyncTask::finished, main, [analTask, main]() { + if (analTask->getOpenFileFailed()) { + return; + } + main->finalizeOpen(); + }); AsyncTask::Ptr analTaskPtr(analTask);