summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@nokia.com>2012-03-16 15:15:08 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-19 12:17:33 +0100
commit39e00631932af761dd56476874700582d0b82e95 (patch)
treec02376c649650e1380a069c88710710694c00513
parent95d6f8a4cf3fba2fd675f0e6b5de0ce1d702da26 (diff)
Remove a dead code from QVariant.
Remove some "safety" code, but essentially it was a dead code. Change-Id: Ie19c29d4cce8b72be5dbaca53c03adc63e8c3dc5 Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
-rw-r--r--src/corelib/kernel/qvariant_p.h35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h
index 90756d76cc..75c94ed401 100644
--- a/src/corelib/kernel/qvariant_p.h
+++ b/src/corelib/kernel/qvariant_p.h
@@ -172,7 +172,12 @@ class QVariantComparator {
};
template<typename T>
struct FilteredComparator<T, /* IsAcceptedType = */ false> {
- static bool compare(const QVariant::Private *, const QVariant::Private *) { return false; }
+ static bool compare(const QVariant::Private *, const QVariant::Private *)
+ {
+ // It is not possible to construct a QVariant containing not fully defined type
+ Q_ASSERT(false);
+ return false;
+ }
};
public:
QVariantComparator(const QVariant::Private *a, const QVariant::Private *b)
@@ -307,7 +312,12 @@ public:
// we need that as sizof(void) is undefined and it is needed in HasIsNullMethod
bool delegate(const void *) { Q_ASSERT(false); return m_d->is_null; }
bool delegate(const QMetaTypeSwitcher::UnknownType *) { return m_d->is_null; }
- bool delegate(const QMetaTypeSwitcher::NotBuiltinType *) { return m_d->is_null; }
+ bool delegate(const QMetaTypeSwitcher::NotBuiltinType *)
+ {
+ // QVariantIsNull is used only for built-in types
+ Q_ASSERT(false);
+ return m_d->is_null;
+ }
protected:
const QVariant::Private *m_d;
};
@@ -373,8 +383,8 @@ public:
void delegate(const QMetaTypeSwitcher::NotBuiltinType*)
{
- qWarning("Trying to construct an instance of an invalid type, type id: %i", m_x->type);
- m_x->type = QVariant::Invalid;
+ // QVariantConstructor is used only for built-in types.
+ Q_ASSERT(false);
}
void delegate(const void*)
@@ -411,7 +421,11 @@ class QVariantDestructor
};
template<typename T>
struct FilteredDestructor<T, /* IsAcceptedType = */ false> {
- FilteredDestructor(QVariant::Private *) {} // ignore non accessible types
+ FilteredDestructor(QVariant::Private *)
+ {
+ // It is not possible to create not accepted type
+ Q_ASSERT(false);
+ }
};
public:
@@ -433,7 +447,8 @@ public:
void delegate(const QMetaTypeSwitcher::NotBuiltinType*)
{
- qWarning("Trying to destruct an instance of an invalid type, type id: %i", m_d->type);
+ // QVariantDestructor class is used only for a built-in type
+ Q_ASSERT(false);
}
// Ignore nonconstructible type
void delegate(const QMetaTypeSwitcher::UnknownType*) {}
@@ -460,9 +475,10 @@ class QVariantDebugStream
};
template<typename T>
struct Filtered<T, /* IsAcceptedType = */ false> {
- Filtered(QDebug dbg, QVariant::Private *d)
+ Filtered(QDebug /* dbg */, QVariant::Private *)
{
- dbg.nospace() << "QVariant::Type(" << d->type << ")";
+ // It is not possible to construct not acccepted type, QVariantConstructor creates an invalid variant for them
+ Q_ASSERT(false);
}
};
@@ -480,7 +496,8 @@ public:
void delegate(const QMetaTypeSwitcher::NotBuiltinType*)
{
- qWarning("Trying to stream an instance of an invalid type, type id: %i", m_d->type);
+ // QVariantDebugStream class is used only for a built-in type
+ Q_ASSERT(false);
}
void delegate(const QMetaTypeSwitcher::UnknownType*)
{