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()
{
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;

View File

@ -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

View File

@ -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);
}

View File

@ -237,8 +237,14 @@ void OptionsDialog::setupAndStartAnalysis(int level, QList<QString> 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);