Allow destruction of QWinEventNotifier in its signal
Avoid use-after-free issue in QProcess. Fixes: QTBUG-96285 Fixes: QTBUG-96359 Pick-to: 6.2 6.1 Change-Id: I953d7a8ecaf301ec3a27db37e13748f905c3d097 Reviewed-by: Christoph Cullmann <cullmann@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
This commit is contained in:
parent
a265333133
commit
4e0082a9ca
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include "qcoreapplication.h"
|
#include "qcoreapplication.h"
|
||||||
#include "qthread.h"
|
#include "qthread.h"
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -238,9 +239,10 @@ bool QWinEventNotifier::event(QEvent * e)
|
|||||||
// when the callback is queued.
|
// when the callback is queued.
|
||||||
d->registered = false;
|
d->registered = false;
|
||||||
|
|
||||||
|
QPointer<QWinEventNotifier> alive(this);
|
||||||
emit activated(d->handleToEvent, QPrivateSignal());
|
emit activated(d->handleToEvent, QPrivateSignal());
|
||||||
|
|
||||||
if (d->enabled && !d->registered) {
|
if (alive && d->enabled && !d->registered) {
|
||||||
SetThreadpoolWait(d->waitObject, d->handleToEvent, NULL);
|
SetThreadpoolWait(d->waitObject, d->handleToEvent, NULL);
|
||||||
d->registered = true;
|
d->registered = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user