Crash fix in ~QVariant
QVariant handlers can not be unregistered. We are not able to guarantee that such operation is safe and we do not want to. Change-Id: Id9a12e6a8c750110e4a08eab1de3e07e5c408675 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
a4a61bb3ef
commit
bfd2b30faf
@ -96,8 +96,6 @@ public:
|
||||
{
|
||||
Handlers[name] = handler;
|
||||
}
|
||||
|
||||
inline void unregisterHandler(const QModulesPrivate::Names name);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@ -892,21 +890,11 @@ Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler()
|
||||
return &qt_kernel_variant_handler;
|
||||
}
|
||||
|
||||
inline void HandlersManager::unregisterHandler(const QModulesPrivate::Names name)
|
||||
{
|
||||
Handlers[name] = &qt_dummy_variant_handler;
|
||||
}
|
||||
|
||||
Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names */name, const QVariant::Handler *handler)
|
||||
{
|
||||
handlerManager.registerHandler(static_cast<QModulesPrivate::Names>(name), handler);
|
||||
}
|
||||
|
||||
Q_CORE_EXPORT void QVariantPrivate::unregisterHandler(const int /* Modules::Names */ name)
|
||||
{
|
||||
handlerManager.unregisterHandler(static_cast<QModulesPrivate::Names>(name));
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QVariant
|
||||
\brief The QVariant class acts like a union for the most common Qt data types.
|
||||
|
@ -459,7 +459,6 @@ private:
|
||||
|
||||
namespace QVariantPrivate {
|
||||
Q_CORE_EXPORT void registerHandler(const int /* Modules::Names */ name, const QVariant::Handler *handler);
|
||||
Q_CORE_EXPORT void unregisterHandler(const int /* Modules::Names */ name);
|
||||
}
|
||||
|
||||
#if !defined(QT_NO_DEBUG_STREAM)
|
||||
|
@ -143,7 +143,6 @@ QFont *QGuiApplicationPrivate::app_font = 0;
|
||||
bool QGuiApplicationPrivate::obey_desktop_settings = true;
|
||||
|
||||
extern void qRegisterGuiVariant();
|
||||
extern void qUnregisterGuiVariant();
|
||||
extern void qInitDrawhelperAsm();
|
||||
extern void qInitImageConversions();
|
||||
|
||||
@ -358,8 +357,6 @@ QGuiApplication::~QGuiApplication()
|
||||
|
||||
clearPalette();
|
||||
|
||||
qUnregisterGuiVariant();
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
d->cursor_list.clear();
|
||||
#endif
|
||||
|
@ -389,12 +389,4 @@ void qRegisterGuiVariant()
|
||||
}
|
||||
Q_CONSTRUCTOR_FUNCTION(qRegisterGuiVariant)
|
||||
|
||||
void qUnregisterGuiVariant()
|
||||
{
|
||||
QVariantPrivate::unregisterHandler(QModulesPrivate::Gui);
|
||||
qMetaTypeGuiHelper = 0;
|
||||
}
|
||||
Q_DESTRUCTOR_FUNCTION(qUnregisterGuiVariant)
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -184,12 +184,4 @@ void qRegisterWidgetsVariant()
|
||||
}
|
||||
Q_CONSTRUCTOR_FUNCTION(qRegisterWidgetsVariant)
|
||||
|
||||
void qUnregisterWidgetsVariant()
|
||||
{
|
||||
QVariantPrivate::unregisterHandler(QModulesPrivate::Widgets);
|
||||
qMetaTypeWidgetsHelper = 0;
|
||||
}
|
||||
Q_DESTRUCTOR_FUNCTION(qUnregisterWidgetsVariant)
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include <qmatrix4x4.h>
|
||||
#include <qpen.h>
|
||||
#include <qpolygon.h>
|
||||
#include <qpalette.h>
|
||||
#include <qtransform.h>
|
||||
#include <qvector2d.h>
|
||||
#include <qvector3d.h>
|
||||
@ -286,6 +287,9 @@ private slots:
|
||||
void loadQt5Stream();
|
||||
void saveQt5Stream_data();
|
||||
void saveQt5Stream();
|
||||
|
||||
void guiVariantAtExit();
|
||||
void widgetsVariantAtExit();
|
||||
private:
|
||||
void dataStream_data(QDataStream::Version version);
|
||||
void loadQVariantFromDataStream(QDataStream::Version version);
|
||||
@ -3735,5 +3739,29 @@ void tst_QVariant::debugStreamType()
|
||||
QVERIFY(msgHandler.testPassed());
|
||||
}
|
||||
|
||||
void tst_QVariant::guiVariantAtExit()
|
||||
{
|
||||
// crash test, it should not crash at QGuiApplication exit
|
||||
static QVariant cursor = QCursor();
|
||||
static QVariant point = QPoint();
|
||||
static QVariant image = QImage();
|
||||
static QVariant pallete = QPalette();
|
||||
Q_UNUSED(cursor);
|
||||
Q_UNUSED(point);
|
||||
Q_UNUSED(image);
|
||||
Q_UNUSED(pallete);
|
||||
QVERIFY(true);
|
||||
}
|
||||
|
||||
void tst_QVariant::widgetsVariantAtExit()
|
||||
{
|
||||
// crash test, it should not crash at QGuiApplication exit
|
||||
static QVariant icon= QIcon();
|
||||
static QVariant sizePolicy = QSizePolicy();
|
||||
Q_UNUSED(icon);
|
||||
Q_UNUSED(sizePolicy);
|
||||
QVERIFY(true);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QVariant)
|
||||
#include "tst_qvariant.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user