Check file using CutterCore::tryFile() instead of QFileInfo

This commit is contained in:
Florian Märkl 2018-01-07 11:58:37 +01:00
parent ec7cef1394
commit 266402095f
3 changed files with 16 additions and 22 deletions

View File

@ -414,7 +414,6 @@ bool CutterCore::tryFile(QString path, bool rw)
cf = r_core_file_open(this->core_, path.toUtf8().constData(), flags, 0LL); cf = r_core_file_open(this->core_, path.toUtf8().constData(), flags, 0LL);
if (!cf) if (!cf)
{ {
eprintf("QRCore::tryFile: Cannot open file?\n");
return false; return false;
} }

View File

@ -305,16 +305,14 @@ bool NewFileDialog::fillProjectsList()
void NewFileDialog::loadFile(const QString &filename) void NewFileDialog::loadFile(const QString &filename)
{ {
// Check that there is a file selected if(!Core()->tryFile(filename, false))
QFileInfo checkfile(filename);
if (!checkfile.exists() || !checkfile.isFile())
{ {
QMessageBox msgBox(this); 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(); msgBox.exec();
return;
} }
else
{
// Add file to recent file list // Add file to recent file list
QSettings settings; QSettings settings;
QStringList files = settings.value("recentFileList").toStringList(); QStringList files = settings.value("recentFileList").toStringList();
@ -330,7 +328,6 @@ void NewFileDialog::loadFile(const QString &filename)
main->openNewFile(filename); main->openNewFile(filename);
close(); close();
}
} }
void NewFileDialog::loadProject(const QString &project) void NewFileDialog::loadProject(const QString &project)

View File

@ -67,8 +67,6 @@ OptionsDialog::OptionsDialog(MainWindow *main):
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());
QFileInfo fi(this->main->getFilename());
this->core->tryFile(fi.filePath(), fi.isWritable());
} }
OptionsDialog::~OptionsDialog() {} OptionsDialog::~OptionsDialog() {}