summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/corelib/kernel/qmetaobject_p.h2
-rw-r--r--src/dbus/qdbusmetaobject.cpp49
-rw-r--r--src/dbus/qdbusmetaobject_p.h2
3 files changed, 9 insertions, 44 deletions
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index 509dede4cb..108d332d61 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -180,7 +180,7 @@ struct QMetaObjectPrivate
static inline const QMetaObjectPrivate *get(const QMetaObject *metaobject)
{ return reinterpret_cast<const QMetaObjectPrivate*>(metaobject->d.data); }
- static const char *rawStringData(const QMetaObject *mo, int index);
+ Q_CORE_EXPORT static const char *rawStringData(const QMetaObject *mo, int index);
static int indexOfSignalRelative(const QMetaObject **baseObject,
const char* name,
diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp
index bd7b83bf65..eb2d3dffa8 100644
--- a/src/dbus/qdbusmetaobject.cpp
+++ b/src/dbus/qdbusmetaobject.cpp
@@ -54,6 +54,7 @@
#include "qdbusabstractinterface_p.h"
#include <private/qmetaobject_p.h>
+#include <private/qmetaobjectbuilder_p.h>
#ifndef QT_NO_DBUS
@@ -355,36 +356,6 @@ void QDBusMetaObjectGenerator::parseProperties()
void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
{
- class MetaStringTable
- {
- public:
- typedef QHash<QByteArray, int> Entries; // string --> offset mapping
- typedef Entries::const_iterator const_iterator;
- Entries::const_iterator constBegin() const
- { return m_entries.constBegin(); }
- Entries::const_iterator constEnd() const
- { return m_entries.constEnd(); }
-
- MetaStringTable() : m_offset(0) {}
-
- int enter(const QByteArray &value)
- {
- Entries::iterator it = m_entries.find(value);
- if (it != m_entries.end())
- return it.value();
- int pos = m_offset;
- m_entries.insert(value, pos);
- m_offset += value.size() + 1;
- return pos;
- }
-
- int arraySize() const { return m_offset; }
-
- private:
- Entries m_entries;
- int m_offset;
- };
-
// this code here is mostly copied from qaxbase.cpp
// with a few modifications to make it cleaner
@@ -397,7 +368,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
idata.resize(sizeof(QDBusMetaObjectPrivate) / sizeof(int));
QDBusMetaObjectPrivate *header = reinterpret_cast<QDBusMetaObjectPrivate *>(idata.data());
- Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 6, "QtDBus meta-object generator should generate the same version as moc");
+ Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 7, "QtDBus meta-object generator should generate the same version as moc");
header->revision = QMetaObjectPrivate::OutputRevision;
header->className = 0;
header->classInfoCount = 0;
@@ -425,7 +396,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count();
idata.resize(data_size + 1);
- MetaStringTable strings;
+ QMetaStringTable strings;
strings.enter(className.toLatin1());
int offset = header->methodData;
@@ -484,14 +455,8 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
Q_ASSERT(offset == header->propertyDBusData);
Q_ASSERT(signatureOffset == header->methodDBusData);
- char *string_data = new char[strings.arraySize()];
- {
- MetaStringTable::const_iterator it;
- for (it = strings.constBegin(); it != strings.constEnd(); ++it) {
- memcpy(string_data + it.value(), it.key().constData(), it.key().size());
- string_data[it.value() + it.key().size()] = '\0';
- }
- }
+ char *string_data = new char[strings.blobSize()];
+ strings.writeBlob(string_data);
uint *uint_data = new uint[idata.size()];
memcpy(uint_data, idata.data(), idata.size() * sizeof(int));
@@ -499,7 +464,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
// put the metaobject together
obj->d.data = uint_data;
obj->d.extradata = 0;
- obj->d.stringdata = string_data;
+ obj->d.stringdata = reinterpret_cast<const QByteArrayData *>(string_data);
obj->d.superdata = &QDBusAbstractInterface::staticMetaObject;
}
@@ -618,7 +583,7 @@ const char *QDBusMetaObject::dbusNameForMethod(int id) const
//id -= methodOffset();
if (id >= 0 && id < priv(d.data)->methodCount) {
int handle = priv(d.data)->methodDBusData + id*intsPerMethod;
- return d.stringdata + d.data[handle];
+ return QMetaObjectPrivate::rawStringData(this, d.data[handle]);
}
return 0;
}
diff --git a/src/dbus/qdbusmetaobject_p.h b/src/dbus/qdbusmetaobject_p.h
index 7a8de41fa0..23a7d53016 100644
--- a/src/dbus/qdbusmetaobject_p.h
+++ b/src/dbus/qdbusmetaobject_p.h
@@ -71,7 +71,7 @@ struct Q_DBUS_EXPORT QDBusMetaObject: public QMetaObject
QDBusError &error);
~QDBusMetaObject()
{
- delete [] d.stringdata;
+ delete [] reinterpret_cast<const char *>(d.stringdata);
delete [] d.data;
}