diff options
author | hjk <hjk@qt.io> | 2023-01-12 10:22:38 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2023-01-12 12:12:23 +0000 |
commit | f561740a0baeec8492a29664243fbeb17baf3e23 (patch) | |
tree | dae6dfe33f3207b3dce7d475939aeb50691e704e | |
parent | 3f528de7db07b735bea9676a0be43d3493009680 (diff) |
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 <jaroslaw.kobus@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r-- | src/libs/utils/pathchooser.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
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<void()> 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()); } |