From 77a6f2a3b9389e806cff6777098cf901bef4bf46 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Wed, 25 Mar 2015 14:04:21 +0100 Subject: [PATCH] Properly handle abort of open dialog --- src/gui/Mainwindow.cxx | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/gui/Mainwindow.cxx b/src/gui/Mainwindow.cxx index 33e48bc..7ea9012 100644 --- a/src/gui/Mainwindow.cxx +++ b/src/gui/Mainwindow.cxx @@ -129,15 +129,29 @@ void Mainwindow::quit() } void Mainwindow::open() { - QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", - tr("Binaries (*)")); - manager->reset(fileName.toStdString()); + QFileDialog dialog(this, tr("Open bianry"), "", tr("Binaries (*)")); + + if (dialog.exec()) { + QStringList files = dialog.selectedFiles(); + if(1 != files.size()) { + LOG4CXX_ERROR(logger, "Needs exactly one file name") + } else { + manager->reset(files[0].toStdString()); + } + } } void Mainwindow::load() { - QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", - tr("Frida Archives (*.frida)")); - manager->load(fileName.toStdString()); + QFileDialog dialog(this, tr("Open saved FrIDa file"), "", tr("Frida Archives (*.frida)")); + + if (dialog.exec()) { + QStringList files = dialog.selectedFiles(); + if(1 != files.size()) { + LOG4CXX_ERROR(logger, "Needs exactly one file name") + } else { + manager->load(files[0].toStdString()); + } + } } void Mainwindow::save() { -- 2.39.5