From a8bf19019b3374eefaadb4e054d24089bc4fd5a4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 29 Mar 2011 11:58:40 +0200 Subject: Make the QIconvCodec on Unix not enforce the Latin1 codec. Originally, the QIconvCodec created and disposed of the iconv_t structure at every turn. In Qt 4.5, we started saving it for later in a thread-local storage. We had to introduce a fix to make sure that we didn't create the iconv_t structure before the setlocale(LC_ALL, "") call was made, though: otherwise, we'd keep forever an iconv_t that pointed to the wrong encoding. So now simply restore the Qt 4.4 behaviour: create and dispose of the iconv_t structure if we're called before the QCoreApplication constructor is run or after the static destructors are run. Note: this means QIconvCodec will probably default to US-ASCII when run before QCoreApplication, not Latin 1. Non-ASCII characters (anything with the high bit set) will fail to convert. Task-number: QTBUG-15229? Reviewed-by: Denis Dzyubenko --- src/corelib/codecs/qiconvcodec.cpp | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp index 4497b8c..053b3d2 100644 --- a/src/corelib/codecs/qiconvcodec.cpp +++ b/src/corelib/codecs/qiconvcodec.cpp @@ -173,6 +173,7 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState int invalidCount = 0; int remainingCount = 0; char *remainingBuffer = 0; + IconvState *temporaryState = 0; IconvState **pstate; if (convState) { @@ -193,11 +194,11 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState // we're running after the Q_GLOBAL_STATIC has been deleted // or before the QCoreApplication initialization // bad programmer, no cookie for you - return QString::fromLatin1(chars, len); + pstate = &temporaryState; + } else { + // stateless conversion -- use thread-local data + pstate = &toUnicodeState()->localData(); } - - // stateless conversion -- use thread-local data - pstate = &toUnicodeState()->localData(); } if (!*pstate) { @@ -280,6 +281,7 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState iconv(state->cd, 0, &inBytesLeft, 0, &outBytesLeft); } + delete temporaryState; return QString::fromLatin1(chars, len); } } while (inBytesLeft != 0); @@ -294,6 +296,7 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState iconv(state->cd, 0, &inBytesLeft, 0, &outBytesLeft); } + delete temporaryState; return s; } @@ -337,30 +340,22 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt char **inBytesPtr = &inBytes; #endif + IconvState *temporaryState = 0; QThreadStorage *ts = fromUnicodeState(); - if (!qt_locale_initialized || !ts) { - // we're running after the Q_GLOBAL_STATIC has been deleted - // or before the QCoreApplication initialization - // bad programmer, no cookie for you - if (!len) - // this is a special case - zero-sized string should be - // translated to empty but not-null QByteArray. - return QByteArray(""); - return QString::fromRawData(uc, len).toLatin1(); - } - IconvState *&state = ts->localData(); + IconvState *&state = (qt_locale_initialized && ts) ? ts->localData() : temporaryState; if (!state) { - state = new IconvState(QIconvCodec::createIconv_t(0, UTF16)); - if (state->cd == reinterpret_cast(-1)) { - if (!setByteOrder(state->cd)) { + iconv_t cd = QIconvCodec::createIconv_t(0, UTF16); + if (cd != reinterpret_cast(-1)) { + if (!setByteOrder(cd)) { perror("QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv failed for BOM"); - iconv_close(state->cd); - state->cd = reinterpret_cast(-1); + iconv_close(cd); + cd = reinterpret_cast(-1); return QString(uc, len).toLatin1(); } } + state = new IconvState(cd); } if (state->cd == reinterpret_cast(-1)) { static int reported = 0; @@ -368,6 +363,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt fprintf(stderr, "QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv_open failed\n"); } + delete temporaryState; return QString(uc, len).toLatin1(); } @@ -430,6 +426,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt // reset to initial state iconv(state->cd, 0, &inBytesLeft, 0, &outBytesLeft); + delete temporaryState; return QString(uc, len).toLatin1(); } } @@ -445,6 +442,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt if (convState) convState->invalidChars = invalidCount; + delete temporaryState; return ba; } -- cgit v0.12 From a0690166164b7feb059164d2b587ed54fa675485 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 20 Dec 2010 19:41:08 +0100 Subject: Add a way to obtain the DBusConnection* pointer from a QDBusConnection This is internal API and the behaviour may change without notice. In the future, I could use a different implementation without libdbus-1, so this pointer may be something different. The use of DBusConnection is also entirely implementation-defined, so keeping this connection around is entirely unsupported. You have been warned. --- src/dbus/qdbusconnection.cpp | 15 +++++++++++++++ src/dbus/qdbusconnection.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 3fb63eb..fe7f41e 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -873,6 +873,21 @@ QDBusConnectionInterface *QDBusConnection::interface() const } /*! + \internal + \since 4.8 + + Returns the internal, implementation-defined pointer for this + connection. Currently, this returns a DBusConnection* pointer, + without changing the reference count. It is the responsibility of + the caller to call dbus_connection_ref if it wants to store the + pointer. +*/ +void *QDBusConnection::internalPointer() const +{ + return d ? d->connection : 0; +} + +/*! Returns true if this QDBusConnection object is connected. */ bool QDBusConnection::isConnected() const diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h index ec59434..c0b9905 100644 --- a/src/dbus/qdbusconnection.h +++ b/src/dbus/qdbusconnection.h @@ -163,6 +163,8 @@ public: QDBusConnectionInterface *interface() const; + void *internalPointer() const; + static QDBusConnection connectToBus(BusType type, const QString &name); static QDBusConnection connectToBus(const QString &address, const QString &name); static void disconnectFromBus(const QString &name); -- cgit v0.12 From e2f060294c1f9707fed48c532ba7de382efe3925 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 15 Dec 2010 18:50:01 +0100 Subject: Move the main D-Bus session and system connections to the main thread Some applications experience weird behaviour that sometimes it works and sometimes it doesn't, due to D-Bus being first used in a thread. So instead do everything in the main thread for the two main connections. --- src/dbus/qdbusconnection.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index fe7f41e..1fb11bc 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include "qdbusconnection.h" #include "qdbusconnectioninterface.h" @@ -987,7 +988,16 @@ class QDBusDefaultConnection: public QDBusConnection public: inline QDBusDefaultConnection(BusType type, const char *name) : QDBusConnection(connectToBus(type, QString::fromLatin1(name))), ownName(name) - { } + { + // make sure this connection is running on the main thread + QCoreApplication *instance = QCoreApplication::instance(); + if (!instance) { + qWarning("QDBusConnection: %s D-Bus connection created before QCoreApplication. Application may misbehave.", + type == SessionBus ? "session" : type == SystemBus ? "system" : "generic"); + } else { + QDBusConnectionPrivate::d(*this)->moveToThread(instance->thread()); + } + } inline ~QDBusDefaultConnection() { disconnectFromBus(QString::fromLatin1(ownName)); } -- cgit v0.12 From ee1af4d59da999df32276889d3b40fb01deb0acc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 14 Feb 2011 13:22:05 +0100 Subject: Add a set of connection capabilities to QDBusConnection The capabilities are negotiated with the D-Bus peer or bus at connection time and may include extra features not available when D-Bus 1.0 was released. Currently (as of D-Bus 1.4), the only additional feature is Unix file descriptor passing. Proposed features are "maybe types" and single-precision floating point. They may be added to D-Bus 1.6. Task-number: QTBUG-17478 --- src/dbus/qdbusconnection.cpp | 23 +++++++++++++++++++++++ src/dbus/qdbusconnection.h | 7 ++++++- src/dbus/qdbusconnection_p.h | 1 + src/dbus/qdbusintegrator.cpp | 2 +- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 1fb11bc..4883a4d 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -248,6 +248,17 @@ void QDBusConnectionManager::setConnection(const QString &name, QDBusConnectionP */ /*! + \since 4.8 + \enum QDBusConnection::ConnectionCapabilities + The available capabilities for a D-Bus connection. + + \value UnixFileDescriptorPassing passing of Unix file descriptors to other processes + (see QDBusUnixFileDescriptor) + + \sa connectionCapabilities() +*/ + +/*! Creates a QDBusConnection object attached to the connection with name \a name. This does not open the connection. You have to call connectToBus() to open it. @@ -948,6 +959,18 @@ QString QDBusConnection::name() const } /*! + \since 4.8 + + Returns the capabilities of this connection as negotiated with the bus + server or peer. If this QDBusConnection is not connected, this function + returns no capabilities. +*/ +QDBusConnection::ConnectionCapabilities QDBusConnection::connectionCapabilities() const +{ + return d ? d->capabilities : ConnectionCapabilities(0); +} + +/*! Attempts to register the \a serviceName on the D-Bus server and returns true if the registration succeeded. The registration will fail if the name is already registered by another application. diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h index c0b9905..6ab0ea2 100644 --- a/src/dbus/qdbusconnection.h +++ b/src/dbus/qdbusconnection.h @@ -111,9 +111,13 @@ public: UnregisterNode, UnregisterTree }; - Q_DECLARE_FLAGS(RegisterOptions, RegisterOption) + enum ConnectionCapability { + UnixFileDescriptorPassing = 0x0001 + }; + Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability) + QDBusConnection(const QString &name); QDBusConnection(const QDBusConnection &other); ~QDBusConnection(); @@ -124,6 +128,7 @@ public: QString baseService() const; QDBusError lastError() const; QString name() const; + ConnectionCapabilities connectionCapabilities() const; bool send(const QDBusMessage &message) const; bool callWithCallback(const QDBusMessage &message, QObject *receiver, diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 85308c1..36f7c53 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -262,6 +262,7 @@ signals: public: QAtomicInt ref; + QDBusConnection::ConnectionCapabilities capabilities; QString name; // this connection's name QString baseService; // this connection's base service diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 14138e0..77c4223 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -967,7 +967,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q extern bool qDBusInitThreads(); QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p) - : QObject(p), ref(1), mode(InvalidMode), connection(0), server(0), busService(0), + : QObject(p), ref(1), capabilities(0), mode(InvalidMode), connection(0), server(0), busService(0), watchAndTimeoutLock(QMutex::Recursive), rootNode(QString(QLatin1Char('/'))) { -- cgit v0.12 From 15b58e2b7d0550c433531550d9ad21e44a3435d8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 15 Feb 2011 10:33:27 +0100 Subject: Add a 'capabilities' flag to the marshaller and demarshaller The marshaller and demarshaller need to know the features negotiated with the peer so as to determine what's permitted. This is especially important to the marshaller: the libdbus-1 API may "throw a fit" if we try to pass a type that isn't allowed or the server may disconnect us. The use of the capabilities in the demarshaller are for symmetry and for us to toggle the feature in unit tests. Task-number: QTBUG-17478 --- src/dbus/qdbusargument.cpp | 8 ++++---- src/dbus/qdbusargument_p.h | 10 ++++++---- src/dbus/qdbusdemarshaller.cpp | 8 ++++---- src/dbus/qdbusintegrator.cpp | 14 +++++++------- src/dbus/qdbusmarshaller.cpp | 11 ++++++----- src/dbus/qdbusmessage.cpp | 17 +++++++++-------- src/dbus/qdbusmessage_p.h | 6 ++++-- 7 files changed, 40 insertions(+), 34 deletions(-) diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp index 00f49ba..09f0e82 100644 --- a/src/dbus/qdbusargument.cpp +++ b/src/dbus/qdbusargument.cpp @@ -72,7 +72,7 @@ QByteArray QDBusArgumentPrivate::createSignature(int id) return ""; QByteArray signature; - QDBusMarshaller *marshaller = new QDBusMarshaller; + QDBusMarshaller *marshaller = new QDBusMarshaller(0); marshaller->ba = &signature; // run it @@ -114,7 +114,7 @@ bool QDBusArgumentPrivate::checkWrite(QDBusArgumentPrivate *&d) return false; if (d->message && d->ref != 1) { - QDBusMarshaller *dd = new QDBusMarshaller; + QDBusMarshaller *dd = new QDBusMarshaller(d->capabilities); dd->message = q_dbus_message_copy(d->message); q_dbus_message_iter_init_append(dd->message, &dd->iterator); @@ -157,7 +157,7 @@ bool QDBusArgumentPrivate::checkReadAndDetach(QDBusArgumentPrivate *&d) if (d->ref == 1) return true; // no need to detach - QDBusDemarshaller *dd = new QDBusDemarshaller; + QDBusDemarshaller *dd = new QDBusDemarshaller(d->capabilities); dd->message = q_dbus_message_ref(d->message); dd->iterator = static_cast(d)->iterator; @@ -295,7 +295,7 @@ QDBusArgument::QDBusArgument() return; } - QDBusMarshaller *dd = new QDBusMarshaller; + QDBusMarshaller *dd = new QDBusMarshaller(0); d = dd; // create a new message with any type, we won't sent it anyways diff --git a/src/dbus/qdbusargument_p.h b/src/dbus/qdbusargument_p.h index fe3a9cd..89a383f 100644 --- a/src/dbus/qdbusargument_p.h +++ b/src/dbus/qdbusargument_p.h @@ -65,8 +65,8 @@ class QDBusDemarshaller; class QDBusArgumentPrivate { public: - inline QDBusArgumentPrivate() - : message(0), ref(1) + inline QDBusArgumentPrivate(int flags = 0) + : message(0), ref(1), capabilities(flags) { } ~QDBusArgumentPrivate(); @@ -89,6 +89,7 @@ public: public: DBusMessage *message; QAtomicInt ref; + int capabilities; enum Direction { Marshalling, Demarshalling @@ -98,7 +99,7 @@ public: class QDBusMarshaller: public QDBusArgumentPrivate { public: - QDBusMarshaller() : parent(0), ba(0), closeCode(0), ok(true) + QDBusMarshaller(int flags) : QDBusArgumentPrivate(flags), parent(0), ba(0), closeCode(0), ok(true) { direction = Marshalling; } ~QDBusMarshaller(); @@ -153,7 +154,8 @@ private: class QDBusDemarshaller: public QDBusArgumentPrivate { public: - inline QDBusDemarshaller() : parent(0) { direction = Demarshalling; } + inline QDBusDemarshaller(int flags) : QDBusArgumentPrivate(flags), parent(0) + { direction = Demarshalling; } ~QDBusDemarshaller(); QString currentSignature(); diff --git a/src/dbus/qdbusdemarshaller.cpp b/src/dbus/qdbusdemarshaller.cpp index 6638263..111122e 100644 --- a/src/dbus/qdbusdemarshaller.cpp +++ b/src/dbus/qdbusdemarshaller.cpp @@ -128,7 +128,7 @@ inline QDBusSignature QDBusDemarshaller::toSignature() inline QDBusVariant QDBusDemarshaller::toVariant() { - QDBusDemarshaller sub; + QDBusDemarshaller sub(capabilities); sub.message = q_dbus_message_ref(message); q_dbus_message_iter_recurse(&iterator, &sub.iterator); q_dbus_message_iter_next(&iterator); @@ -249,7 +249,7 @@ QStringList QDBusDemarshaller::toStringList() { QStringList list; - QDBusDemarshaller sub; + QDBusDemarshaller sub(capabilities); q_dbus_message_iter_recurse(&iterator, &sub.iterator); q_dbus_message_iter_next(&iterator); while (!sub.atEnd()) @@ -297,7 +297,7 @@ inline QDBusDemarshaller *QDBusDemarshaller::beginMapEntry() QDBusDemarshaller *QDBusDemarshaller::beginCommon() { - QDBusDemarshaller *d = new QDBusDemarshaller; + QDBusDemarshaller *d = new QDBusDemarshaller(capabilities); d->parent = this; d->message = q_dbus_message_ref(message); @@ -336,7 +336,7 @@ QDBusDemarshaller *QDBusDemarshaller::endCommon() QDBusArgument QDBusDemarshaller::duplicate() { - QDBusDemarshaller *d = new QDBusDemarshaller; + QDBusDemarshaller *d = new QDBusDemarshaller(capabilities); d->iterator = iterator; d->message = q_dbus_message_ref(message); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 77c4223..ee917a5 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -535,7 +535,7 @@ qDBusSignalFilter(DBusConnection *connection, DBusMessage *message, void *data) if (d->mode == QDBusConnectionPrivate::InvalidMode) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - QDBusMessage amsg = QDBusMessagePrivate::fromDBusMessage(message); + QDBusMessage amsg = QDBusMessagePrivate::fromDBusMessage(message, d->capabilities); qDBusDebug() << d << "got message (signal):" << amsg; return d->handleMessage(amsg) ? @@ -1204,7 +1204,7 @@ void QDBusConnectionPrivate::relaySignal(QObject *obj, const QMetaObject *mo, in QDBusMessagePrivate::setParametersValidated(message, true); message.setArguments(args); QDBusError error; - DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, &error); + DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, capabilities, &error); if (!msg) { qWarning("QDBusConnection: Could not emit signal %s.%s: %s", qPrintable(interface), memberName.constData(), qPrintable(error.message())); @@ -1754,7 +1754,7 @@ void QDBusConnectionPrivate::processFinishedCall(QDBusPendingCallPrivate *call) if (call->pending) { // decode the message DBusMessage *reply = q_dbus_pending_call_steal_reply(call->pending); - msg = QDBusMessagePrivate::fromDBusMessage(reply); + msg = QDBusMessagePrivate::fromDBusMessage(reply, connection->capabilities); q_dbus_message_unref(reply); } qDBusDebug() << connection << "got message reply (async):" << msg; @@ -1805,7 +1805,7 @@ int QDBusConnectionPrivate::send(const QDBusMessage& message) // through the d_ptr->localReply link QDBusError error; - DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, &error); + DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, capabilities, &error); if (!msg) { if (message.type() == QDBusMessage::MethodCallMessage) qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s", @@ -1851,7 +1851,7 @@ QDBusMessage QDBusConnectionPrivate::sendWithReply(const QDBusMessage &message, if (!QCoreApplication::instance() || sendMode == QDBus::Block) { QDBusError err; - DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, &err); + DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, capabilities, &err); if (!msg) { qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s", qPrintable(message.service()), qPrintable(message.path()), @@ -1872,7 +1872,7 @@ QDBusMessage QDBusConnectionPrivate::sendWithReply(const QDBusMessage &message, return QDBusMessage::createError(err); } - QDBusMessage amsg = QDBusMessagePrivate::fromDBusMessage(reply); + QDBusMessage amsg = QDBusMessagePrivate::fromDBusMessage(reply, capabilities); q_dbus_message_unref(reply); qDBusDebug() << this << "got message reply (blocking):" << amsg; @@ -1948,7 +1948,7 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM pcall->ref = 0; QDBusError error; - DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, &error); + DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, capabilities, &error); if (!msg) { qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s", qPrintable(message.service()), qPrintable(message.path()), diff --git a/src/dbus/qdbusmarshaller.cpp b/src/dbus/qdbusmarshaller.cpp index 15e56e7..76d76cc 100644 --- a/src/dbus/qdbusmarshaller.cpp +++ b/src/dbus/qdbusmarshaller.cpp @@ -188,7 +188,7 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg) return false; } - QDBusMarshaller sub; + QDBusMarshaller sub(capabilities); open(sub, DBUS_TYPE_VARIANT, signature); bool isOk = sub.appendVariantInternal(value); // don't call sub.close(): it auto-closes @@ -203,7 +203,7 @@ inline void QDBusMarshaller::append(const QStringList &arg) return; } - QDBusMarshaller sub; + QDBusMarshaller sub(capabilities); open(sub, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING); QStringList::ConstIterator it = arg.constBegin(); QStringList::ConstIterator end = arg.constEnd(); @@ -280,6 +280,7 @@ void QDBusMarshaller::open(QDBusMarshaller &sub, int code, const char *signature sub.parent = this; sub.ba = ba; sub.ok = true; + sub.capabilities = capabilities; if (ba) switch (code) { @@ -303,7 +304,7 @@ void QDBusMarshaller::open(QDBusMarshaller &sub, int code, const char *signature QDBusMarshaller *QDBusMarshaller::beginCommon(int code, const char *signature) { - QDBusMarshaller *d = new QDBusMarshaller; + QDBusMarshaller *d = new QDBusMarshaller(capabilities); open(*d, code, signature); return d; } @@ -362,7 +363,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg) if (!d->message) return false; // can't append this one... - QDBusDemarshaller demarshaller; + QDBusDemarshaller demarshaller(capabilities); demarshaller.message = q_dbus_message_ref(d->message); if (d->direction == Demarshalling) { @@ -528,7 +529,7 @@ bool QDBusMarshaller::appendCrossMarshalling(QDBusDemarshaller *demarshaller) // We have to recurse QDBusDemarshaller *drecursed = demarshaller->beginCommon(); - QDBusMarshaller mrecursed; // create on the stack makes it autoclose + QDBusMarshaller mrecursed(capabilities); // create on the stack makes it autoclose QByteArray subSignature; const char *sig = 0; if (code == DBUS_TYPE_VARIANT || code == DBUS_TYPE_ARRAY) { diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp index c13d483..bd77c77 100644 --- a/src/dbus/qdbusmessage.cpp +++ b/src/dbus/qdbusmessage.cpp @@ -95,14 +95,15 @@ QString QDBusMessage::errorMessage() const /*! \internal - Constructs a DBusMessage object from this object. The returned value must be de-referenced - with q_dbus_message_unref. + Constructs a DBusMessage object from \a message. The returned value must be de-referenced + with q_dbus_message_unref. The \a capabilities flags indicates which capabilities to use. The \a error object is set to indicate the error if anything went wrong with the marshalling. Usually, this error message will be placed in the reply, as if the call failed. The \a error pointer must not be null. */ -DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDBusError *error) +DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDBusConnection::ConnectionCapabilities capabilities, + QDBusError *error) { if (!qdbus_loadLibDBus()) { *error = QDBusError(QDBusError::Failed, QLatin1String("Could not open lidbus-1 library")); @@ -177,7 +178,7 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB // we can record this fact d_ptr->parametersValidated = true; - QDBusMarshaller marshaller; + QDBusMarshaller marshaller(capabilities); QVariantList::ConstIterator it = d_ptr->arguments.constBegin(); QVariantList::ConstIterator cend = d_ptr->arguments.constEnd(); q_dbus_message_iter_init_append(msg, &marshaller.iterator); @@ -222,7 +223,7 @@ DBUS_DISABLE_CHECKS \internal Constructs a QDBusMessage by parsing the given DBusMessage object. */ -QDBusMessage QDBusMessagePrivate::fromDBusMessage(DBusMessage *dmsg) +QDBusMessage QDBusMessagePrivate::fromDBusMessage(DBusMessage *dmsg, QDBusConnection::ConnectionCapabilities capabilities) { QDBusMessage message; if (!dmsg) @@ -238,7 +239,7 @@ QDBusMessage QDBusMessagePrivate::fromDBusMessage(DBusMessage *dmsg) message.d_ptr->signature = QString::fromUtf8(q_dbus_message_get_signature(dmsg)); message.d_ptr->msg = q_dbus_message_ref(dmsg); - QDBusDemarshaller demarshaller; + QDBusDemarshaller demarshaller(capabilities); demarshaller.message = q_dbus_message_ref(dmsg); if (q_dbus_message_iter_init(demarshaller.message, &demarshaller.iterator)) while (!demarshaller.atEnd()) @@ -272,7 +273,7 @@ QDBusMessage QDBusMessagePrivate::makeLocal(const QDBusConnectionPrivate &conn, // we must marshall and demarshall again so as to create QDBusArgument // entries for the complex types QDBusError error; - DBusMessage *message = toDBusMessage(asSent, &error); + DBusMessage *message = toDBusMessage(asSent, conn.capabilities, &error); if (!message) { // failed to marshall, so it's a call error return QDBusMessage::createError(error); @@ -280,7 +281,7 @@ QDBusMessage QDBusMessagePrivate::makeLocal(const QDBusConnectionPrivate &conn, q_dbus_message_set_sender(message, conn.baseService.toUtf8()); - QDBusMessage retval = fromDBusMessage(message); + QDBusMessage retval = fromDBusMessage(message, conn.capabilities); retval.d_ptr->localMessage = true; q_dbus_message_unref(message); if (retval.d_ptr->service.isEmpty()) diff --git a/src/dbus/qdbusmessage_p.h b/src/dbus/qdbusmessage_p.h index 6747976..52d4d25 100644 --- a/src/dbus/qdbusmessage_p.h +++ b/src/dbus/qdbusmessage_p.h @@ -56,6 +56,7 @@ #include #include #include +#include struct DBusMessage; @@ -92,8 +93,9 @@ public: static void setParametersValidated(QDBusMessage &msg, bool enable) { msg.d_ptr->parametersValidated = enable; } - static DBusMessage *toDBusMessage(const QDBusMessage &message, QDBusError *error); - static QDBusMessage fromDBusMessage(DBusMessage *dmsg); + static DBusMessage *toDBusMessage(const QDBusMessage &message, QDBusConnection::ConnectionCapabilities capabilities, + QDBusError *error); + static QDBusMessage fromDBusMessage(DBusMessage *dmsg, QDBusConnection::ConnectionCapabilities capabilities); static bool isLocal(const QDBusMessage &msg); static QDBusMessage makeLocal(const QDBusConnectionPrivate &conn, -- cgit v0.12 From 6d8f350808d36aac807cd55eafc447e80af671ad Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 1 May 2010 23:13:44 +0200 Subject: Unix configure: Add support for --sysroot Reviewed-By: axis --- config.tests/unix/compile.test | 4 ++-- configure | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/config.tests/unix/compile.test b/config.tests/unix/compile.test index 29ddea7..f4a7f29 100755 --- a/config.tests/unix/compile.test +++ b/config.tests/unix/compile.test @@ -11,9 +11,9 @@ TEST=$6 EXE=`basename "$6"` DESCRIPTION=$7 shift 7 -LFLAGS="" +LFLAGS="$SYSROOT_FLAG" INCLUDEPATH="" -CXXFLAGS="" +CXXFLAGS="$SYSROOT_FLAG" MAC_ARCH_CXXFLAGS="" MAC_ARCH_LFLAGS="" while [ "$#" -gt 0 ]; do diff --git a/configure b/configure index e88373e..382df60 100755 --- a/configure +++ b/configure @@ -1316,6 +1316,9 @@ while [ "$#" -gt 0 ]; do qconfig) CFG_QCONFIG="$VAL" ;; + sysroot) + CFG_SYSROOT="$VAL" + ;; bindir) QT_INSTALL_BINS="$VAL" ;; @@ -3310,6 +3313,18 @@ if [ "$CFG_EMBEDDED" = "nacl" ]; then TEST_COMPILER="nacl-gcc" fi +SYSROOT_FLAG= +if [ -n "$CFG_SYSROOT" ]; then + if compilerSupportsFlag --sysroot="$CFG_SYSROOT"; then + [ "$OPT_VERBOSE" = "yes" ] && echo "Setting sysroot to: $CFG_SYSROOT" + SYSROOT_FLAG="--sysroot=$CFG_SYSROOT" + else + echo >&2 "The compiler doesn't support the --sysroot flag, I can't set the sysroot" + exit 1 + fi +fi +export SYSROOT_FLAG # used by config.tests/unix/compile.test + # auto-detect precompiled header support if [ "$CFG_PRECOMPILE" = "auto" ]; then if [ `echo "$CFG_MAC_ARCHS" | wc -w` -gt 1 ]; then @@ -8316,6 +8331,16 @@ QT_NAMESPACE = $QT_NAMESPACE QT_NAMESPACE_MAC_CRC = $QT_NAMESPACE_MAC_CRC EOF +if [ -n "$CFG_SYSROOT" ]; then + echo "# sysroot" >>"$QTCONFIG.tmp" + echo `basename "$XQMAKESPEC"` \{ >>"$QTCONFIG.tmp" + echo " QT_SYSROOT += \$\$quote($CFG_SYSROOT)" >>"$QTCONFIG.tmp" + echo " QMAKE_CFLAGS += --sysroot=\$\$QT_SYSROOT" >>"$QTCONFIG.tmp" + echo " QMAKE_CXXFLAGS += --sysroot=\$\$QT_SYSROOT" >>"$QTCONFIG.tmp" + echo " QMAKE_LFLAGS += --sysroot=\$\$QT_SYSROOT" >>"$QTCONFIG.tmp" + echo "}" >> "$QTCONFIG.tmp" + echo >> "$QTCONFIG.tmp" +fi if [ "$CFG_RPATH" = "yes" ]; then echo "QMAKE_RPATHDIR += \"$QT_INSTALL_LIBS\"" >> "$QTCONFIG.tmp" fi -- cgit v0.12