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>
This commit is contained in:
hjk
2023-01-12 10:22:38 +01:00
parent 3f528de7db
commit f561740a0b

View File

@@ -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());
}