Remove QVariant constructor taking Qt::GlobalColor.

The constructor is wrong, it creates instance of QVariant encapsulating
a QColor instance. QVariant should not implicitly convert data, never.

Change-Id: Idc794ecdecb42d8b53fee3f993bf51ddd43f595d
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
bb10
Jędrzej Nowacki 2012-04-13 14:52:34 +02:00 committed by Qt by Nokia
parent 10c88faf79
commit ff55d64f67
6 changed files with 7 additions and 34 deletions

6
dist/changes-5.0.0 vendored
View File

@ -68,6 +68,12 @@ information about a particular change.
method returns void is to compare the return value of QMetaMethod::returnType()
to QMetaType::Void.
- QVariant:
* Inconsistent constructor taking Qt::GlobalColor and producing QVariant(QColor)
instance was removed. Code constructing such variants can be migrated by
explicitly calling QColor constructor. For example from "QVariant(Qt::red)"
to "QVariant(QColor(Qt::red))"
- QTestLib:
* The plain-text, xml and lightxml test output formats have been changed to
show a test result for every row of test data in data-driven tests. In

View File

@ -1349,19 +1349,6 @@ QVariant::QVariant(const char *val)
Constructs a new variant with the regular expression value \a re.
*/
/*! \since 4.2
\fn QVariant::QVariant(Qt::GlobalColor color)
Constructs a new variant of type QVariant::Color and initializes
it with \a color.
This is a convenience constructor that allows \c{QVariant(Qt::blue);}
to create a valid QVariant storing a QColor.
Note: This constructor will assert if the application does not link
to the Qt GUI library.
*/
QVariant::QVariant(Type type)
{ create(type, 0); }
QVariant::QVariant(int typeId, const void *copy)
@ -1443,7 +1430,6 @@ QVariant::QVariant(const QRegExp &regExp) { d.is_null = false; d.type = RegExp;
QVariant::QVariant(const QRegularExpression &re) { d.is_null = false; d.type = QMetaType::QRegularExpression; v_construct<QRegularExpression>(&d, re); }
#endif // QT_BOOTSTRAPPED
#endif // QT_NO_REGEXP
QVariant::QVariant(Qt::GlobalColor color) { create(62, &color); }
/*!
Returns the storage type of the value stored in the variant.

View File

@ -248,7 +248,6 @@ class Q_CORE_EXPORT QVariant
QVariant(const QUrl &url);
QVariant(const QEasingCurve &easing);
#endif
QVariant(Qt::GlobalColor color);
QVariant& operator=(const QVariant &other);
#ifdef Q_COMPILER_RVALUE_REFS

View File

@ -108,15 +108,6 @@ struct GuiTypesFilter {
static void construct(QVariant::Private *x, const void *copy)
{
const int type = x->type;
if (Q_UNLIKELY(type == 62)) {
// small 'trick' to let a QVariant(Qt::blue) create a variant
// of type QColor
// TODO Get rid of this hack.
x->type = QVariant::Color;
QColor color(*reinterpret_cast<const Qt::GlobalColor *>(copy));
v_construct<QColor>(x, &color);
return;
}
QVariantConstructor<GuiTypesFilter> constructor(x, copy);
QMetaTypeSwitcher::switcher<void>(constructor, type, 0);
}

View File

@ -97,7 +97,7 @@ void tst_QMimeData::colorData() const
QCOMPARE(qvariant_cast<QColor>(mimeData.colorData()), red);
// change, verify
mimeData.setColorData(Qt::blue);
mimeData.setColorData(QColor(Qt::blue));
QVERIFY(mimeData.hasColor());
QCOMPARE(qvariant_cast<QColor>(mimeData.colorData()), blue);
}

View File

@ -235,8 +235,6 @@ private slots:
void saveLoadCustomTypes();
void globalColor();
void variantMap();
void variantHash();
@ -2447,13 +2445,6 @@ void tst_QVariant::url()
QCOMPARE(v3.toString(), str);
}
void tst_QVariant::globalColor()
{
QVariant variant(Qt::blue);
QVERIFY(variant.type() == QVariant::Color);
QVERIFY(qVariantValue<QColor>(variant) == QColor(Qt::blue));
}
void tst_QVariant::variantMap()
{
QMap<QString, QVariant> map;