forked from qt-creator/qt-creator
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:
@@ -6,6 +6,7 @@
|
|||||||
#include "commandline.h"
|
#include "commandline.h"
|
||||||
#include "environment.h"
|
#include "environment.h"
|
||||||
#include "fileutils.h"
|
#include "fileutils.h"
|
||||||
|
#include "guard.h"
|
||||||
#include "hostosinfo.h"
|
#include "hostosinfo.h"
|
||||||
#include "macroexpander.h"
|
#include "macroexpander.h"
|
||||||
#include "qtcassert.h"
|
#include "qtcassert.h"
|
||||||
@@ -174,6 +175,7 @@ public:
|
|||||||
const MacroExpander *m_macroExpander = globalMacroExpander();
|
const MacroExpander *m_macroExpander = globalMacroExpander();
|
||||||
std::function<void()> m_openTerminal;
|
std::function<void()> m_openTerminal;
|
||||||
bool m_allowPathFromDevice = false;
|
bool m_allowPathFromDevice = false;
|
||||||
|
Guard m_callGuard;
|
||||||
};
|
};
|
||||||
|
|
||||||
PathChooserPrivate::PathChooserPrivate()
|
PathChooserPrivate::PathChooserPrivate()
|
||||||
@@ -350,11 +352,15 @@ QString PathChooser::expandedDirectory(const QString &input, const Environment &
|
|||||||
|
|
||||||
void PathChooser::setPath(const QString &path)
|
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));
|
d->m_lineEdit->setTextKeepingActiveCursor(QDir::toNativeSeparators(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathChooser::setFilePath(const FilePath &fn)
|
void PathChooser::setFilePath(const FilePath &fn)
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(!d->m_callGuard.isLocked(), return);
|
||||||
|
GuardLocker locker(d->m_callGuard);
|
||||||
d->m_lineEdit->setTextKeepingActiveCursor(fn.toUserOutput());
|
d->m_lineEdit->setTextKeepingActiveCursor(fn.toUserOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user