forked from qt-creator/qt-creator
QmlDesigner: Fix crumblebar recursion
If a file that already exist in crumblebar is pushed into crumblebar, pop the bar until the first instance of the specified file is on the top of the bar and skip the push. Fixes: QDS-6307 Change-Id: I75f7d575db3fc6bb5b629ea1e6b61ea2905726b4 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Samuel Ghinet <samuel.ghinet@qt.io>
This commit is contained in:
@@ -83,20 +83,29 @@ void CrumbleBar::pushFile(const Utils::FilePath &fileName)
|
|||||||
if (!m_isInternalCalled) {
|
if (!m_isInternalCalled) {
|
||||||
crumblePath()->clear();
|
crumblePath()->clear();
|
||||||
} else {
|
} else {
|
||||||
CrumbleBarInfo lastElementCrumbleBarInfo = crumblePath()->dataForLastIndex().value<CrumbleBarInfo>();
|
// If the path already exists in crumblePath, pop up to first instance of that to avoid
|
||||||
|
// cyclical crumblePath
|
||||||
|
int match = -1;
|
||||||
|
for (int i = crumblePath()->length() - 1; i >= 0; --i) {
|
||||||
|
CrumbleBarInfo info = crumblePath()->dataForIndex(i).value<CrumbleBarInfo>();
|
||||||
|
if (info.fileName == fileName)
|
||||||
|
match = i;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lastElementCrumbleBarInfo.displayName.isEmpty()
|
if (match != -1) {
|
||||||
&& lastElementCrumbleBarInfo.fileName == fileName)
|
for (int i = crumblePath()->length() - 1 - match; i > 0; --i)
|
||||||
crumblePath()->popElement();
|
crumblePath()->popElement();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CrumbleBarInfo crumbleBarInfo;
|
CrumbleBarInfo info = crumblePath()->dataForLastIndex().value<CrumbleBarInfo>();
|
||||||
crumbleBarInfo.fileName = fileName;
|
if (info.fileName != fileName) {
|
||||||
|
CrumbleBarInfo crumbleBarInfo;
|
||||||
crumblePath()->pushElement(fileName.fileName(), QVariant::fromValue(crumbleBarInfo));
|
crumbleBarInfo.fileName = fileName;
|
||||||
|
crumblePath()->pushElement(fileName.fileName(), QVariant::fromValue(crumbleBarInfo));
|
||||||
|
}
|
||||||
|
|
||||||
m_isInternalCalled = false;
|
m_isInternalCalled = false;
|
||||||
|
|
||||||
updateVisibility();
|
updateVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user