ModeManager: Don't set the mode if we are already in the right one

Setting the mode means resetting all of the UI and repainting the
whole window. This can be painfully slow if the window contains some
large graphical objects, like QML profiler trace.

Change-Id: I64835de49e482826a54e3a844d59bc747ca38370
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Ulf Hermann
2016-08-23 09:23:54 +02:00
parent 5051d614c5
commit abcdadd40e

View File

@@ -144,9 +144,10 @@ static IMode *findMode(Id id)
void ModeManager::activateMode(Id id)
{
const int index = indexOf(id);
if (index >= 0)
d->m_modeStack->setCurrentIndex(index);
const int currentIndex = d->m_modeStack->currentIndex();
const int newIndex = indexOf(id);
if (newIndex != currentIndex && newIndex >= 0)
d->m_modeStack->setCurrentIndex(newIndex);
}
void ModeManager::objectAdded(QObject *obj)