diff --git a/src/cutter.cpp b/src/cutter.cpp index ea2f9ed2..ea6d8488 100644 --- a/src/cutter.cpp +++ b/src/cutter.cpp @@ -414,7 +414,6 @@ bool CutterCore::tryFile(QString path, bool rw) cf = r_core_file_open(this->core_, path.toUtf8().constData(), flags, 0LL); if (!cf) { - eprintf("QRCore::tryFile: Cannot open file?\n"); return false; } diff --git a/src/dialogs/NewFileDialog.cpp b/src/dialogs/NewFileDialog.cpp index 3bec5aed..c4050115 100644 --- a/src/dialogs/NewFileDialog.cpp +++ b/src/dialogs/NewFileDialog.cpp @@ -305,32 +305,29 @@ bool NewFileDialog::fillProjectsList() void NewFileDialog::loadFile(const QString &filename) { - // Check that there is a file selected - QFileInfo checkfile(filename); - if (!checkfile.exists() || !checkfile.isFile()) + if(!Core()->tryFile(filename, false)) { QMessageBox msgBox(this); - msgBox.setText(tr("Select a new program or a previous one\nbefore continuing")); + msgBox.setText(tr("Select a new program or a previous one before continuing.")); msgBox.exec(); + return; } - else - { - // Add file to recent file list - QSettings settings; - QStringList files = settings.value("recentFileList").toStringList(); - files.removeAll(filename); - files.prepend(filename); - while (files.size() > MaxRecentFiles) - files.removeLast(); - settings.setValue("recentFileList", files); + // Add file to recent file list + QSettings settings; + QStringList files = settings.value("recentFileList").toStringList(); + files.removeAll(filename); + files.prepend(filename); + while (files.size() > MaxRecentFiles) + files.removeLast(); - // Close dialog and open MainWindow/OptionsDialog - MainWindow *main = new MainWindow(); - main->openNewFile(filename); + settings.setValue("recentFileList", files); - close(); - } + // Close dialog and open MainWindow/OptionsDialog + MainWindow *main = new MainWindow(); + main->openNewFile(filename); + + close(); } void NewFileDialog::loadProject(const QString &project) diff --git a/src/dialogs/OptionsDialog.cpp b/src/dialogs/OptionsDialog.cpp index dbe64481..31b19086 100644 --- a/src/dialogs/OptionsDialog.cpp +++ b/src/dialogs/OptionsDialog.cpp @@ -67,8 +67,6 @@ OptionsDialog::OptionsDialog(MainWindow *main): connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(reject())); ui->programLineEdit->setText(main->getFilename()); - QFileInfo fi(this->main->getFilename()); - this->core->tryFile(fi.filePath(), fi.isWritable()); } OptionsDialog::~OptionsDialog() {}