diff --git a/src/AnalThread.cpp b/src/AnalThread.cpp index feb6209d..0eda8194 100644 --- a/src/AnalThread.cpp +++ b/src/AnalThread.cpp @@ -78,8 +78,14 @@ void AnalThread::run() // Do not reload the file if already loaded QJsonArray openedFiles = Core()->getOpenedFiles(); if (!openedFiles.size()) { - Core()->loadFile(main->getFilename(), binLoadAddr, mapAddr, perms, va, loadBinInfo, + bool fileLoaded = Core()->loadFile(main->getFilename(), binLoadAddr, mapAddr, perms, va, loadBinInfo, forceBinPlugin); + if (!fileLoaded) { + // Something wrong happened, fallback to open dialog + emit openFileFailed(); + interrupted = true; + return; + } } // Set asm OS configuration diff --git a/src/AnalThread.h b/src/AnalThread.h index 3494ef22..6a61f12e 100644 --- a/src/AnalThread.h +++ b/src/AnalThread.h @@ -29,6 +29,7 @@ protected: signals: void updateProgress(QString str); + void openFileFailed(); private: int level; diff --git a/src/Cutter.cpp b/src/Cutter.cpp index edc51cb8..103b5ab0 100644 --- a/src/Cutter.cpp +++ b/src/Cutter.cpp @@ -214,7 +214,6 @@ bool CutterCore::loadFile(QString path, ut64 baddr, ut64 mapaddr, int perms, int f = r_core_file_open(core_, path.toUtf8().constData(), perms, mapaddr); if (!f) { - // @TODO pop warning msg eprintf("r_core_file_open failed\n"); return false; } diff --git a/src/CutterApplication.cpp b/src/CutterApplication.cpp index 8b45bcd9..9f208670 100644 --- a/src/CutterApplication.cpp +++ b/src/CutterApplication.cpp @@ -108,7 +108,7 @@ bool CutterApplication::event(QEvent *e) QFileOpenEvent *openEvent = static_cast(e); if (openEvent) { if (m_FileAlreadyDropped) { - // we already dropped a file in macOS, let's spawn another instance + // We already dropped a file in macOS, let's spawn another instance // (Like the File -> Open) QString fileName = openEvent->file(); QProcess process(this); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 133850c1..28dc933d 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -239,6 +239,17 @@ void MainWindow::openNewFile(const QString &fn, int analLevel, QList ad displayAnalysisOptionsDialog(analLevel, advancedOptions); } +void MainWindow::openNewFileFailed() +{ + displayNewFileDialog(); + QMessageBox mb(this); + mb.setIcon(QMessageBox::Critical); + mb.setStandardButtons(QMessageBox::Ok); + mb.setWindowTitle(tr("Cannot open file!")); + mb.setText(tr("Could not open the file! Make sure the file exists and that you have the correct permissions.")); + mb.exec(); +} + void MainWindow::displayNewFileDialog() { NewFileDialog *n = new NewFileDialog(); @@ -294,7 +305,6 @@ void MainWindow::finalizeOpen() addOutput(tr(" > Finished, happy reversing :)")); // Add fortune message addOutput("\n" + core->cmd("fo")); - //previewDock->setWindowTitle("entry0"); showMaximized(); } diff --git a/src/MainWindow.h b/src/MainWindow.h index bdb11146..f6ae6f86 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -113,6 +113,8 @@ public slots: void toggleResponsive(bool maybe); + void openNewFileFailed(); + private slots: void on_actionAbout_triggered(); diff --git a/src/dialogs/OptionsDialog.cpp b/src/dialogs/OptionsDialog.cpp index f12bbc67..c3b477b6 100644 --- a/src/dialogs/OptionsDialog.cpp +++ b/src/dialogs/OptionsDialog.cpp @@ -61,7 +61,7 @@ OptionsDialog::OptionsDialog(MainWindow *main): // Add this so the dialog resizes when widgets are shown/hidden //this->layout()->setSizeConstraint(QLayout::SetFixedSize); - connect(&analThread, SIGNAL(finished()), this, SLOT(anal_finished())); + connect(&analThread, SIGNAL(finished()), this, SLOT(analysisFinished())); connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(reject())); ui->programLineEdit->setText(main->getFilename()); @@ -171,6 +171,7 @@ void OptionsDialog::setupAndStartAnalysis(int level, QList advanced) // Threads stuff, connect signal/slot connect(&analThread, &AnalThread::updateProgress, this, &OptionsDialog::updateProgress); + connect(&analThread, &AnalThread::openFileFailed, main, &MainWindow::openNewFileFailed); analThread.start(main, level, advanced); } @@ -246,14 +247,15 @@ void OptionsDialog::on_okButton_clicked() setupAndStartAnalysis(ui->analSlider->value(), advanced); } -void OptionsDialog::anal_finished() +void OptionsDialog::analysisFinished() { if (analThread.isInterrupted()) { - done(0); + updateProgress(tr("Analysis aborted.")); + done(1); return; } - ui->statusLabel->setText(tr("Loading interface")); + updateProgress(tr("Loading interface...")); main->addOutput(tr(" > Analysis finished")); main->finalizeOpen(); diff --git a/src/dialogs/OptionsDialog.h b/src/dialogs/OptionsDialog.h index 9d1d359f..1fb49ac0 100644 --- a/src/dialogs/OptionsDialog.h +++ b/src/dialogs/OptionsDialog.h @@ -40,7 +40,7 @@ private slots: void updatePDBLayout(); void updateScriptLayout(); - void anal_finished(); + void analysisFinished(); protected: void closeEvent(QCloseEvent *event) override; diff --git a/src/widgets/VTablesWidget.cpp b/src/widgets/VTablesWidget.cpp index 9a007a99..eb36253a 100644 --- a/src/widgets/VTablesWidget.cpp +++ b/src/widgets/VTablesWidget.cpp @@ -47,9 +47,8 @@ QVariant VTableModel::data(const QModelIndex &index, int role) const return res.name; case ADDRESS: return RAddressString(res.addr); - default: - break; } + break; case VTableDescriptionRole: return QVariant::fromValue(res); default: @@ -63,9 +62,8 @@ QVariant VTableModel::data(const QModelIndex &index, int role) const return tr("VTable ") + QString::number(index.row() + 1); case ADDRESS: return RAddressString(vtables->at(index.row()).addr); - default: - break; } + break; case VTableDescriptionRole: { const VTableDescription &res = vtables->at(index.row()); return QVariant::fromValue(res);