From: Christoph Egger Date: Wed, 25 Mar 2015 13:04:21 +0000 (+0100) Subject: Properly handle abort of open dialog X-Git-Tag: v0.1~17 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=77a6f2a3b9389e806cff6777098cf901bef4bf46;p=frida%2Ffrida.git Properly handle abort of open dialog --- 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() {