summaryrefslogtreecommitdiffstats
path: root/src/corelib/json/qjson_p.h
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@digia.com>2014-09-10 10:52:14 +0200
committerJędrzej Nowacki <jedrzej.nowacki@digia.com>2014-09-11 10:54:42 +0200
commitfa9a407b9f7b89e4785c650dcb3e80d08ea3c042 (patch)
tree87a85efb95e21e248b95904b834370b956e804b6 /src/corelib/json/qjson_p.h
parent7b9f7f3891230ddd2b2ef5cf3c760a605a02ee96 (diff)
Revert "Reading QJsonObject property should not modify the object itself."
This reverts commit 20cf632ad5f3ffe7b0fd231724c971f4e07304eb. The commit produced to many problems during statics destruction. For example causing QtCreator crash (QTBUG-40987). Change-Id: Ib52f6a449c2d84deab2de792559a6a065ca45e8d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib/json/qjson_p.h')
-rw-r--r--src/corelib/json/qjson_p.h71
1 files changed, 0 insertions, 71 deletions
diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h
index 2cb26b95a1..104ddaabae 100644
--- a/src/corelib/json/qjson_p.h
+++ b/src/corelib/json/qjson_p.h
@@ -61,8 +61,6 @@
#include <qstring.h>
#include <qendian.h>
#include <qnumeric.h>
-#include <QtCore/qhash.h>
-#include <QtCore/qmutex.h>
#include <limits.h>
#include <limits>
@@ -795,75 +793,6 @@ private:
Q_DISABLE_COPY(Data)
};
-struct ObjectUndefinedKeys
-{
- static void insertKey(const QJsonObject *object, int index, const QString &key)
- {
- QMutexLocker lock(&mutex);
- keys()[object][index] = key;
- }
- static QString takeKey(const QJsonObject *object, int index)
- {
- QMutexLocker lock(&mutex);
- return keys()[object].take(index);
- }
- static void removeKeys(const QJsonObject *object)
- {
- QMutexLocker lock(&mutex);
- keys().remove(object);
- }
-private:
- typedef QHash<const QJsonObject*, QHash<int, QString> > KeysHash;
- static KeysHash &keys()
- {
- static KeysHash keys;
- return keys;
- }
- static QBasicMutex mutex;
-};
-
-} // namespace QJsonPrivate
-
-struct QJsonValueRef::UnionHelper
-{
- static inline QJsonObject *untaggedPointer(QJsonObject *object)
- {
- const quintptr Mask = ~quintptr(0) << 2;
- return reinterpret_cast<QJsonObject*>(quintptr(object) & Mask);
- }
- static inline QJsonObject *taggedPointer(QJsonObject *object)
- {
- const quintptr Mask = 1;
- return reinterpret_cast<QJsonObject*>(quintptr(object) | Mask);
- }
-
- static void setValueAt(QJsonValueRef *ref, QJsonValue value)
- {
- using namespace QJsonPrivate;
- QJsonObject *object = untaggedPointer(ref->o);
- if (ref->o != object)
- object->insert(ObjectUndefinedKeys::takeKey(object, ref->index), value);
- else
- object->setValueAt(ref->index, value);
- }
-
- static QJsonValue valueAt(const QJsonValueRef *ref)
- {
- QJsonObject *object = untaggedPointer(ref->o);
- if (ref->o != object)
- return QJsonValue::Undefined;
- return ref->o->valueAt(ref->index);
- }
-};
-
-/*!
- \internal
- Constructor that creates reference to an undefined value in \a object.
-*/
-inline QJsonValueRef::QJsonValueRef(QJsonObject *object, const QString &key)
- : o(UnionHelper::taggedPointer(object)), is_object(true), index(qHash(key))
-{
- QJsonPrivate::ObjectUndefinedKeys::insertKey(object, index, key);
}
QT_END_NAMESPACE