Commit 7e3db546 authored by jhammen's avatar jhammen
Browse files

remove missing open files from project list

parent b68c0587
......@@ -54,8 +54,8 @@ EditorWidget::EditorWidget(NamedFile &file) : mfile(file), undoable(false), redo
bool EditorWidget::load() {
QFile file(mfile.path);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
QMessageBox::warning(this, tr("Bipscript IDE"), tr("Error opening %1:\n%2").arg(mfile.path),
file.errorString());
QMessageBox::warning(this, tr("Bipscript IDE"),
tr("Error opening %1:\n%2").arg(mfile.path).arg(file.errorString()));
return false;
}
......
......@@ -146,7 +146,7 @@ void MainWindow::engineDisconnect() {
ui->actionJackConnect->setEnabled(true);
}
void MainWindow::createOrOpenEditor(NamedFile &file) {
bool MainWindow::createOrOpenEditor(NamedFile &file) {
EditorWidget *editor = findEditor(file.path);
if (editor) {
ui->tabWidget->setCurrentWidget(editor);
......@@ -164,16 +164,19 @@ void MainWindow::createOrOpenEditor(NamedFile &file) {
connect(editor, SIGNAL(copyAvailable(bool)), ui->actionCopy, SLOT(setEnabled(bool)));
// add to project list as open file
projectList.currentProject().openFile(file.path);
} else {
return false;
}
}
selectedFolder = nullptr;
enableFileActions(editor);
return true;
}
void MainWindow::createOrOpenEditor(const QString &path) {
bool MainWindow::createOrOpenEditor(const QString &path) {
QFileInfo fileInfo(path);
NamedFile file(fileInfo.fileName(), fileInfo.filePath());
createOrOpenEditor(file);
return createOrOpenEditor(file);
}
EditorWidget *MainWindow::currentEditor() {
......@@ -642,7 +645,11 @@ void MainWindow::loadProject() {
NamedFile &folder = project.folder(i);
ui->folderTree->addTopLevelItem(toTreeFolder(folder));
}
foreach (const QString &path, project.openFiles()) { createOrOpenEditor(path); }
foreach (const QString &path, project.openFiles()) {
if (!createOrOpenEditor(path)) {
project.closeFile(path);
}
}
EditorWidget *editor = findEditor(project.activeFile());
if (editor) {
ui->tabWidget->setCurrentWidget(editor);
......
......@@ -100,8 +100,8 @@ class MainWindow : public QMainWindow {
QLabel bbtWidget;
QLabel engineWidget;
// private methods
void createOrOpenEditor(NamedFile &);
void createOrOpenEditor(const QString &);
bool createOrOpenEditor(NamedFile &);
bool createOrOpenEditor(const QString &);
EditorWidget *currentEditor();
void enableFileActions(EditorWidget *editor);
void enableTransportControls(bool enabled);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment