Fix strange behaviour when changing views

The problem was introduce by 3a16d1e, the change in perspectiveSelector
current index triggers currentIndexChanged when the view change has
not been finished, to avoid this we use activated signal and add
a check to do nothing when the index has not changed.
The problem was reported at the forum.
This commit is contained in:
Alejandro Martinez
2023-01-26 12:06:37 -03:00
parent 88246a8b15
commit 0ddea94b7a

View File

@@ -342,7 +342,8 @@ MainWindow::MainWindow(const QDir &home)
perspectiveSelector->setStyle(toolStyle);
perspectiveSelector->setFixedWidth(200 * dpiXFactor);
perspectiveSelector->setFixedHeight(gl_toolheight * dpiYFactor);
connect(perspectiveSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(perspectiveSelected(int)));
// activated instead of currentIndexChange signal is used to avoid triggering when changed by code due to 3a16d1e
connect(perspectiveSelector, SIGNAL(activated(int)), this, SLOT(perspectiveSelected(int)));
HelpWhatsThis *helpPerspectiveSelector = new HelpWhatsThis(perspectiveSelector);
perspectiveSelector->setWhatsThis(helpPerspectiveSelector->getWhatsThisText(HelpWhatsThis::ToolBar_PerspectiveSelector));
@@ -1484,6 +1485,8 @@ MainWindow::perspectiveSelected(int index)
// which perspective is currently being shown?
int prior = current->perspectives_.indexOf(current->perspective_);
if (prior == index) return; // activated but nothing changed
if (index < current->perspectives_.count()) {
// a perspectives was selected