mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-30 00:35:25 +00:00
Added message box when r_core_file_open fails
This commit is contained in:
parent
8ab3a3664c
commit
43b147c6eb
@ -78,8 +78,14 @@ void AnalThread::run()
|
|||||||
// Do not reload the file if already loaded
|
// Do not reload the file if already loaded
|
||||||
QJsonArray openedFiles = Core()->getOpenedFiles();
|
QJsonArray openedFiles = Core()->getOpenedFiles();
|
||||||
if (!openedFiles.size()) {
|
if (!openedFiles.size()) {
|
||||||
Core()->loadFile(main->getFilename(), binLoadAddr, mapAddr, perms, va, loadBinInfo,
|
bool fileLoaded = Core()->loadFile(main->getFilename(), binLoadAddr, mapAddr, perms, va, loadBinInfo,
|
||||||
forceBinPlugin);
|
forceBinPlugin);
|
||||||
|
if (!fileLoaded) {
|
||||||
|
// Something wrong happened, fallback to open dialog
|
||||||
|
emit openFileFailed();
|
||||||
|
interrupted = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set asm OS configuration
|
// Set asm OS configuration
|
||||||
|
@ -29,6 +29,7 @@ protected:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void updateProgress(QString str);
|
void updateProgress(QString str);
|
||||||
|
void openFileFailed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int level;
|
int level;
|
||||||
|
@ -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);
|
f = r_core_file_open(core_, path.toUtf8().constData(), perms, mapaddr);
|
||||||
if (!f) {
|
if (!f) {
|
||||||
// @TODO pop warning msg
|
|
||||||
eprintf("r_core_file_open failed\n");
|
eprintf("r_core_file_open failed\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ bool CutterApplication::event(QEvent *e)
|
|||||||
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(e);
|
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(e);
|
||||||
if (openEvent) {
|
if (openEvent) {
|
||||||
if (m_FileAlreadyDropped) {
|
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)
|
// (Like the File -> Open)
|
||||||
QString fileName = openEvent->file();
|
QString fileName = openEvent->file();
|
||||||
QProcess process(this);
|
QProcess process(this);
|
||||||
|
@ -239,6 +239,17 @@ void MainWindow::openNewFile(const QString &fn, int analLevel, QList<QString> ad
|
|||||||
displayAnalysisOptionsDialog(analLevel, advancedOptions);
|
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()
|
void MainWindow::displayNewFileDialog()
|
||||||
{
|
{
|
||||||
NewFileDialog *n = new NewFileDialog();
|
NewFileDialog *n = new NewFileDialog();
|
||||||
@ -294,7 +305,6 @@ void MainWindow::finalizeOpen()
|
|||||||
addOutput(tr(" > Finished, happy reversing :)"));
|
addOutput(tr(" > Finished, happy reversing :)"));
|
||||||
// Add fortune message
|
// Add fortune message
|
||||||
addOutput("\n" + core->cmd("fo"));
|
addOutput("\n" + core->cmd("fo"));
|
||||||
//previewDock->setWindowTitle("entry0");
|
|
||||||
showMaximized();
|
showMaximized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +113,8 @@ public slots:
|
|||||||
|
|
||||||
void toggleResponsive(bool maybe);
|
void toggleResponsive(bool maybe);
|
||||||
|
|
||||||
|
void openNewFileFailed();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_actionAbout_triggered();
|
void on_actionAbout_triggered();
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ OptionsDialog::OptionsDialog(MainWindow *main):
|
|||||||
// Add this so the dialog resizes when widgets are shown/hidden
|
// Add this so the dialog resizes when widgets are shown/hidden
|
||||||
//this->layout()->setSizeConstraint(QLayout::SetFixedSize);
|
//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()));
|
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
|
||||||
|
|
||||||
ui->programLineEdit->setText(main->getFilename());
|
ui->programLineEdit->setText(main->getFilename());
|
||||||
@ -171,6 +171,7 @@ void OptionsDialog::setupAndStartAnalysis(int level, QList<QString> advanced)
|
|||||||
|
|
||||||
// Threads stuff, connect signal/slot
|
// Threads stuff, connect signal/slot
|
||||||
connect(&analThread, &AnalThread::updateProgress, this, &OptionsDialog::updateProgress);
|
connect(&analThread, &AnalThread::updateProgress, this, &OptionsDialog::updateProgress);
|
||||||
|
connect(&analThread, &AnalThread::openFileFailed, main, &MainWindow::openNewFileFailed);
|
||||||
analThread.start(main, level, advanced);
|
analThread.start(main, level, advanced);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,14 +247,15 @@ void OptionsDialog::on_okButton_clicked()
|
|||||||
setupAndStartAnalysis(ui->analSlider->value(), advanced);
|
setupAndStartAnalysis(ui->analSlider->value(), advanced);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsDialog::anal_finished()
|
void OptionsDialog::analysisFinished()
|
||||||
{
|
{
|
||||||
if (analThread.isInterrupted()) {
|
if (analThread.isInterrupted()) {
|
||||||
done(0);
|
updateProgress(tr("Analysis aborted."));
|
||||||
|
done(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->statusLabel->setText(tr("Loading interface"));
|
updateProgress(tr("Loading interface..."));
|
||||||
main->addOutput(tr(" > Analysis finished"));
|
main->addOutput(tr(" > Analysis finished"));
|
||||||
|
|
||||||
main->finalizeOpen();
|
main->finalizeOpen();
|
||||||
|
@ -40,7 +40,7 @@ private slots:
|
|||||||
void updatePDBLayout();
|
void updatePDBLayout();
|
||||||
void updateScriptLayout();
|
void updateScriptLayout();
|
||||||
|
|
||||||
void anal_finished();
|
void analysisFinished();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
@ -47,9 +47,8 @@ QVariant VTableModel::data(const QModelIndex &index, int role) const
|
|||||||
return res.name;
|
return res.name;
|
||||||
case ADDRESS:
|
case ADDRESS:
|
||||||
return RAddressString(res.addr);
|
return RAddressString(res.addr);
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case VTableDescriptionRole:
|
case VTableDescriptionRole:
|
||||||
return QVariant::fromValue(res);
|
return QVariant::fromValue(res);
|
||||||
default:
|
default:
|
||||||
@ -63,9 +62,8 @@ QVariant VTableModel::data(const QModelIndex &index, int role) const
|
|||||||
return tr("VTable ") + QString::number(index.row() + 1);
|
return tr("VTable ") + QString::number(index.row() + 1);
|
||||||
case ADDRESS:
|
case ADDRESS:
|
||||||
return RAddressString(vtables->at(index.row()).addr);
|
return RAddressString(vtables->at(index.row()).addr);
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case VTableDescriptionRole: {
|
case VTableDescriptionRole: {
|
||||||
const VTableDescription &res = vtables->at(index.row());
|
const VTableDescription &res = vtables->at(index.row());
|
||||||
return QVariant::fromValue(res);
|
return QVariant::fromValue(res);
|
||||||
|
Loading…
Reference in New Issue
Block a user