Do not show MainWindow if loading failed

This commit is contained in:
Florian Märkl 2018-07-07 12:39:28 +02:00
parent 9ecca8fe38
commit 5777b1905c
4 changed files with 13 additions and 2 deletions

View File

@ -24,6 +24,7 @@ void AnalTask::interrupt()
void AnalTask::runTask() void AnalTask::runTask()
{ {
log(tr("Loading Binary...\n")); log(tr("Loading Binary...\n"));
openFailed = false;
Core()->setCPU(options.arch, options.cpu, options.bits); Core()->setCPU(options.arch, options.cpu, options.bits);
@ -46,6 +47,7 @@ void AnalTask::runTask()
options.forceBinPlugin); options.forceBinPlugin);
if (!fileLoaded) { if (!fileLoaded) {
// Something wrong happened, fallback to open dialog // Something wrong happened, fallback to open dialog
openFailed = true;
emit openFileFailed(); emit openFileFailed();
interrupt(); interrupt();
return; return;

View File

@ -53,6 +53,8 @@ public:
void interrupt() override; void interrupt() override;
bool getOpenFileFailed() { return openFailed; }
protected: protected:
void runTask() override; void runTask() override;
@ -61,6 +63,8 @@ signals:
private: private:
InitialOptions options; InitialOptions options;
bool openFailed = false;
}; };
#endif // ANALTHREAD_H #endif // ANALTHREAD_H

View File

@ -57,7 +57,6 @@ void AsyncTaskDialog::updateProgressTimer()
label += " "; label += " ";
} }
label += tr("%n seconds", "%n second", secondsElapsed % 60); label += tr("%n seconds", "%n second", secondsElapsed % 60);
printf("setText %s\n", label.toLocal8Bit().constData());
ui->timeLabel->setText(label); ui->timeLabel->setText(label);
} }

View File

@ -237,8 +237,14 @@ void OptionsDialog::setupAndStartAnalysis(int level, QList<QString> advanced)
AnalTask *analTask = new AnalTask(); AnalTask *analTask = new AnalTask();
analTask->setOptions(options); analTask->setOptions(options);
MainWindow *main = this->main;
connect(analTask, &AnalTask::openFileFailed, main, &MainWindow::openNewFileFailed); 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); AsyncTask::Ptr analTaskPtr(analTask);