forked from qt-creator/qt-creator
FancyLineEdit: Make sure to not leave any threads hanging around
Add them to the global future synchronizer, so they are canceled and waited for before deleting any plugin instances. Change-Id: Iec78b7566905815c4d2b4cc7410d10b2da16c7b7 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "camelcasecursor.h"
|
||||
#include "execmenu.h"
|
||||
#include "futuresynchronizer.h"
|
||||
#include "historycompleter.h"
|
||||
#include "hostosinfo.h"
|
||||
#include "icon.h"
|
||||
@@ -98,6 +99,7 @@ class FancyLineEditPrivate : public QObject
|
||||
{
|
||||
public:
|
||||
explicit FancyLineEditPrivate(FancyLineEdit *parent);
|
||||
~FancyLineEditPrivate();
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
||||
@@ -163,6 +165,12 @@ FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent)
|
||||
}
|
||||
}
|
||||
|
||||
FancyLineEditPrivate::~FancyLineEditPrivate()
|
||||
{
|
||||
if (m_validatorWatcher)
|
||||
m_validatorWatcher->cancel();
|
||||
}
|
||||
|
||||
bool FancyLineEditPrivate::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
int buttonIndex = -1;
|
||||
@@ -446,12 +454,27 @@ void FancyLineEdit::setFiltering(bool on)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Set a synchronous or asynchronous validation function \a fn.
|
||||
Asynchronous validation functions can continue to run after destruction of the
|
||||
FancyLineEdit instance. During shutdown asynchronous validation functions can continue
|
||||
to run until before the plugin instances are deleted (at that point the plugin manager
|
||||
waits for them to finish before continuing).
|
||||
|
||||
\sa defaultValidationFunction()
|
||||
*/
|
||||
void FancyLineEdit::setValidationFunction(const FancyLineEdit::ValidationFunction &fn)
|
||||
{
|
||||
d->m_validationFunction = fn;
|
||||
validate();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the default validation function, which synchonously executes the line edit's
|
||||
validator.
|
||||
|
||||
\sa setValidationFunction()
|
||||
*/
|
||||
FancyLineEdit::ValidationFunction FancyLineEdit::defaultValidationFunction()
|
||||
{
|
||||
return &FancyLineEdit::validateWithValidator;
|
||||
@@ -581,6 +604,7 @@ void FancyLineEdit::validate()
|
||||
|
||||
AsyncValidationFuture future = validationFunction(text());
|
||||
d->m_validatorWatcher->setFuture(future);
|
||||
Utils::futureSynchronizer()->addFuture(future);
|
||||
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user