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 Pick-to: 6.6 Change-Id: I4246f74008df6ad7fcbfde56403397b065fbe861 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>bb10
parent
d18a9dd977
commit
3748b194d4
|
|
@ -423,6 +423,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…
Reference in New Issue