Avoid Import perspective lockup (#4858)

When a wrong perspective file is imported into a view
This commit is contained in:
Paul Johnson
2026-04-07 20:24:08 +01:00
committed by GitHub
parent 11ce6f8f72
commit 31653d8534
3 changed files with 9 additions and 6 deletions

View File

@@ -476,11 +476,8 @@ AbstractView::importPerspective(QString filename)
if (newone) { if (newone) {
appendPerspective(newone); appendPerspective(newone);
return true; return true;
} else {
// no valid perspective found for this view... (maybe its for another type of view)
QMessageBox::information(this, tr("Perspective Import"), tr("No perspectives found that are appropriate for the current view."));
return false;
} }
return false;
} }
void void

View File

@@ -965,13 +965,16 @@ MainWindow::importPerspective()
pactive = true; pactive = true;
if (current->importPerspective(fileName)) { if (current->importPerspective(fileName)) {
// on success we select the new one // on success we select the new one forcefully, as the view hasn't changed.
resetPerspective(view); resetPerspective(view, true);
//current->setPerspectives(perspectiveSelector); //current->setPerspectives(perspectiveSelector);
// and select remember pactive is true, so we do the heavy lifting here // and select remember pactive is true, so we do the heavy lifting here
perspectiveSelector->setCurrentIndex(current->perspectives_.count()-1); perspectiveSelector->setCurrentIndex(current->perspectives_.count()-1);
current->perspectiveSelected(perspectiveSelector->currentIndex()); current->perspectiveSelected(perspectiveSelector->currentIndex());
} else {
// no valid perspective found for this view... (maybe its for another type of view)
QMessageBox::information(this, tr("Perspective Import"), tr("No perspectives found that are appropriate for the current view."));
} }
pactive = false; pactive = false;
} }

View File

@@ -330,6 +330,9 @@ PerspectiveDialog::importPerspectiveClicked()
// new one added // new one added
emit perspectivesChanged(); emit perspectivesChanged();
} else {
// no valid perspective found for this view... (maybe its for another type of view)
QMessageBox::information(this, tr("Perspective Import"), tr("No perspectives found that are appropriate for the current view."));
} }
} }
} }