From f561740a0baeec8492a29664243fbeb17baf3e23 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 12 Jan 2023 10:22:38 +0100 Subject: Utils: Guard against endless loop in PathChooser Adding a slash to the text in the path chooser for a custom build directory currently triggers an endless recursion. This here does not fix the actual problem but at least prevents the crash. Task-number: QTCREATORBUG-28682 Change-Id: Ic7d70ccfaccc1fd9437ca41e8b40b027718af6cb Reviewed-by: Jarek Kobus Reviewed-by: Eike Ziller --- src/libs/utils/pathchooser.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libs/utils/pathchooser.cpp b/src/libs/utils/pathchooser.cpp index ef30703c9b..6b11f4fea5 100644 --- a/src/libs/utils/pathchooser.cpp +++ b/src/libs/utils/pathchooser.cpp @@ -6,6 +6,7 @@ #include "commandline.h" #include "environment.h" #include "fileutils.h" +#include "guard.h" #include "hostosinfo.h" #include "macroexpander.h" #include "qtcassert.h" @@ -174,6 +175,7 @@ public: const MacroExpander *m_macroExpander = globalMacroExpander(); std::function m_openTerminal; bool m_allowPathFromDevice = false; + Guard m_callGuard; }; PathChooserPrivate::PathChooserPrivate() @@ -350,11 +352,15 @@ QString PathChooser::expandedDirectory(const QString &input, const Environment & void PathChooser::setPath(const QString &path) { + QTC_ASSERT(!d->m_callGuard.isLocked(), return); + GuardLocker locker(d->m_callGuard); d->m_lineEdit->setTextKeepingActiveCursor(QDir::toNativeSeparators(path)); } void PathChooser::setFilePath(const FilePath &fn) { + QTC_ASSERT(!d->m_callGuard.isLocked(), return); + GuardLocker locker(d->m_callGuard); d->m_lineEdit->setTextKeepingActiveCursor(fn.toUserOutput()); } -- cgit v1.2.3