QEventLoopLocker: defend against nullptr arguments
The class would previosuly produce a crash when the QEventLoop* or the QThread* were nullptr or if no QCoreApplication existed. We want, however, the out-of-line constructors of the class to be noexcept, and for that, they should neither allocation nor have preconditions. The former is for another patch; this patch deals with the latter. [ChangeLog][QtCore][QEventLoopLocker] Is now a no-op on nullptr QEventLoop*, QThread*, QCoreApplication::instance() (was: crash). Task-number: QTBUG-114793 Change-Id: I4246f74008df6ad7fcbfde56403397b065fbe861 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 3748b194d4de790540aa74db8d65b602e097f415) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
acaf9b0d2c
commit
90d96766af
@ -407,6 +407,8 @@ void QEventLoopLocker::visit(Func f) const
|
||||
{
|
||||
using Type = QEventLoopLockerPrivate::Type;
|
||||
const auto ptr = d_ptr->pointer();
|
||||
if (!ptr)
|
||||
return;
|
||||
switch (d_ptr->type()) {
|
||||
case Type::EventLoop: return f(static_cast<QEventLoopPrivate *>(ptr));
|
||||
case Type::Thread: return f(static_cast<QThreadPrivate *>(ptr));
|
||||
|
Loading…
x
Reference in New Issue
Block a user