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 From 0686a6d656641f2ac1fc1cd9710dcf538f8ff5c8 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Wed, 30 Mar 2011 14:42:45 +0200 Subject: Fix the painting for widgets painting directly on screen. Reviewed-by: Jiang Jiang --- src/gui/kernel/qcocoaview_mac.mm | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 54e7e3e..b5e5d18 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -254,7 +254,10 @@ static int qCocoaViewCount = 0; qt_mac_retain_graphics_context(context); // We use a different graphics system. - if (QApplicationPrivate::graphicsSystem() != 0) { + // + // Widgets that are set to paint on screen, specifically QGLWidget, + // requires the native engine to execute in order to be drawn. + if (QApplicationPrivate::graphicsSystem() != 0 && !qwidget->testAttribute(Qt::WA_PaintOnScreen)) { // Raster engine. if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) { @@ -334,12 +337,6 @@ static int qCocoaViewCount = 0; qwidget->update(qwidget->rect()); qwidgetprivate->syncBackingStore(qwidget->rect()); } - - // Since we don't want to use the native engine, we must exit, however - // widgets that are set to paint on screen, specifically QGLWidget, - // requires the following code to execute in order to be drawn. - if (!qwidget->testAttribute(Qt::WA_PaintOnScreen)) - return; } // Native engine. -- cgit v0.12 From ecb77c6376202c12ccb0f3683a6c96a60c2c951e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 15:20:06 +0200 Subject: Revert "Fixed underline offset after raster coordinate system change." Temporarily revert commit eeca1aee72a69584aa20bdb9f5c4e48d7e3cbc16, which seemed to cause auto-test failures on Windows 7. --- src/gui/painting/qpainter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 638f4ca..14fb772 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -6468,8 +6468,7 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const const qreal underlineOffset = fe->underlinePosition().toReal(); // deliberately ceil the offset to avoid the underline coming too close to // the text above it. - const qreal aliasedCoordinateDelta = 0.5 - 0.015625; - const qreal underlinePos = pos.y() + qCeil(underlineOffset) - aliasedCoordinateDelta; + const qreal underlinePos = pos.y() + qCeil(underlineOffset); if (underlineStyle == QTextCharFormat::SpellCheckUnderline) { underlineStyle = QTextCharFormat::UnderlineStyle(QApplication::style()->styleHint(QStyle::SH_SpellCheckUnderlineStyle)); -- cgit v0.12 From 918b0fbd8673d3d6d74c655207e9b1688357254b Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Tue, 29 Mar 2011 16:31:40 +0200 Subject: Remove Font Smoothing hack for OS X It only affects text rendering with static text/QTextLayout, rendering to images is not affected. Task-number: QTBUG-18048 Reviewed-by: Eskil --- src/declarative/util/qdeclarativeview.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index 1b50a56..421cd89 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -72,7 +72,6 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE) -extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled; class QDeclarativeScene : public QGraphicsScene { @@ -707,14 +706,7 @@ void QDeclarativeView::paintEvent(QPaintEvent *event) if (frameRateDebug()) time = d->frameTimer.restart(); -#ifdef Q_WS_MAC - bool oldSmooth = qt_applefontsmoothing_enabled; - qt_applefontsmoothing_enabled = false; -#endif QGraphicsView::paintEvent(event); -#ifdef Q_WS_MAC - qt_applefontsmoothing_enabled = oldSmooth; -#endif QDeclarativeDebugTrace::endRange(QDeclarativeDebugTrace::Painting); -- cgit v0.12 From b92a31da01ee50fed4b10282e79f812167faf659 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 30 Mar 2011 14:55:34 +0200 Subject: Fix horizontal centered text drawing without word wrap In this case we can't use line width to align the text, we have to use the rectangle width given in QPainter::drawText for alignment instead. Reviewed-by: Eskil --- src/gui/painting/qpainter.cpp | 17 ++++++++++++----- src/gui/text/qtextengine.cpp | 16 ++++++++++++++++ src/gui/text/qtextengine_p.h | 1 + src/gui/text/qtextlayout.cpp | 19 +------------------ 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 14fb772..64ef549 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -8149,10 +8149,6 @@ start_lengthVariant: engine.option.setTextDirection(layout_direction); if (tf & Qt::AlignJustify) engine.option.setAlignment(Qt::AlignJustify); - else if (tf & Qt::AlignRight) - engine.option.setAlignment(Qt::AlignRight); - else if (tf & Qt::AlignHCenter) - engine.option.setAlignment(Qt::AlignHCenter); else engine.option.setAlignment(Qt::AlignLeft); // do not do alignment twice @@ -8248,7 +8244,18 @@ start_lengthVariant: for (int i = 0; i < textLayout.lineCount(); i++) { QTextLine line = textLayout.lineAt(i); - line.draw(painter, QPointF(r.x(), r.y() + yoff)); + + qreal advance = line.horizontalAdvance(); + xoff = 0; + if (tf & Qt::AlignRight) { + QTextEngine *eng = textLayout.engine(); + xoff = r.width() - advance - + eng->leadingSpaceWidth(eng->lines[line.lineNumber()]).toReal(); + } + else if (tf & Qt::AlignHCenter) + xoff = (r.width() - advance) / 2; + + line.draw(painter, QPointF(r.x() + xoff, r.y() + yoff)); } if (restore) { diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index a63fdbf..6aa333c 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2725,6 +2725,22 @@ void QTextEngine::resolveAdditionalFormats() const specialData->resolvedFormatIndices = indices; } +QFixed QTextEngine::leadingSpaceWidth(const QScriptLine &line) +{ + if (!line.hasTrailingSpaces + || (option.flags() & QTextOption::IncludeTrailingSpaces) + || !isRightToLeft()) + return QFixed(); + + int pos = line.length; + const HB_CharAttributes *attributes = this->attributes(); + if (!attributes) + return QFixed(); + while (pos > 0 && attributes[line.from + pos - 1].whiteSpace) + --pos; + return width(line.from + pos, line.length - pos); +} + QStackTextEngine::QStackTextEngine(const QString &string, const QFont &f) : QTextEngine(string, f), _layoutData(string, _memory, MemSize) diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 50d1ff8..366c5c3 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -609,6 +609,7 @@ public: QString elidedText(Qt::TextElideMode mode, const QFixed &width, int flags = 0) const; void shapeLine(const QScriptLine &line); + QFixed leadingSpaceWidth(const QScriptLine &line); private: void setBoundary(int strPos) const; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 8eff7d2..afe6949 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -66,23 +66,6 @@ QT_BEGIN_NAMESPACE #define SuppressText 0x5012 #define SuppressBackground 0x513 -static inline QFixed leadingSpaceWidth(QTextEngine *eng, const QScriptLine &line) -{ - if (!line.hasTrailingSpaces - || (eng->option.flags() & QTextOption::IncludeTrailingSpaces) - || !(eng->option.alignment() & Qt::AlignRight) - || !eng->isRightToLeft()) - return QFixed(); - - int pos = line.length; - const HB_CharAttributes *attributes = eng->attributes(); - if (!attributes) - return QFixed(); - while (pos > 0 && attributes[line.from + pos - 1].whiteSpace) - --pos; - return eng->width(line.from + pos, line.length - pos); -} - static QFixed alignLine(QTextEngine *eng, const QScriptLine &line) { QFixed x = 0; @@ -93,7 +76,7 @@ static QFixed alignLine(QTextEngine *eng, const QScriptLine &line) if (align & Qt::AlignJustify && eng->isRightToLeft()) align = Qt::AlignRight; if (align & Qt::AlignRight) - x = line.width - (line.textAdvance + leadingSpaceWidth(eng, line)); + x = line.width - (line.textAdvance + eng->leadingSpaceWidth(line)); else if (align & Qt::AlignHCenter) x = (line.width - line.textAdvance)/2; } -- cgit v0.12 From 8abc3cd80fd55c588faffb067ab51feb4b9b6fc5 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 31 Mar 2011 08:52:08 +0400 Subject: QWS: fix the software/hardware cursor switcher because of typo, this never worked before. drop the meaningless local qt_sw_cursor variable and use the correct application-wide qws_sw_cursor one Merge-request: 2587 Reviewed-by: Harald Fernengel --- src/gui/embedded/qscreen_qws.cpp | 3 --- src/gui/embedded/qscreen_qws.h | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp index e207ed1..90561fd 100644 --- a/src/gui/embedded/qscreen_qws.cpp +++ b/src/gui/embedded/qscreen_qws.cpp @@ -64,7 +64,6 @@ QT_BEGIN_NAMESPACE // #define QT_USE_MEMCPY_DUFF #ifndef QT_NO_QWS_CURSOR -bool qt_sw_cursor=false; Q_GUI_EXPORT QScreenCursor * qt_screencursor = 0; #endif Q_GUI_EXPORT QScreen * qt_screen = 0; @@ -119,8 +118,6 @@ ClearCacheFunc QScreen::clearCacheFunc = 0; Returns a pointer to the application's unique screen cursor. */ -extern bool qws_sw_cursor; - /*! Constructs a screen cursor */ diff --git a/src/gui/embedded/qscreen_qws.h b/src/gui/embedded/qscreen_qws.h index 17ffbbb..85c775e 100644 --- a/src/gui/embedded/qscreen_qws.h +++ b/src/gui/embedded/qscreen_qws.h @@ -130,7 +130,7 @@ const int SourcePixmap=1; class QScreenCursor; extern QScreenCursor *qt_screencursor; -extern bool qt_sw_cursor; +extern bool qws_sw_cursor; class Q_GUI_EXPORT QScreenCursor { @@ -145,7 +145,7 @@ public: bool supportsAlphaCursor() const { return supportsAlpha; } - static bool enabled() { return qt_sw_cursor; } + static bool enabled() { return qws_sw_cursor; } QRect boundingRect() const { return QRect(pos - hotspot, size); } QImage image() const { return cursor; } -- cgit v0.12 From a538389b52630ec53734695b8d422c5ec124b0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Ky=C3=B6stil=C3=A4?= Date: Thu, 31 Mar 2011 14:04:47 +0200 Subject: opengl2: Make maximum cached glyph size configurable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the DPI of displays continues to rise, especially on mobile devices, the maximum glyph size of 64 pixels for the glyph cache has become a limitation. This problem is made worse by the fact that when the maximum glyph size is exceeded, the OpenGL paint engine falls back to using rasterized geometry for glyph rendering. This does not produce acceptable quality if the OpenGL rendering surface lacks support for multisampling. This patch offers a solution to the problem by making the cached glyph size configurable at build time. This way the limit can be set according to the capabilities of the target hardware. Signed-off-by: Sami Kyöstilä Merge-request: 1131 Reviewed-by: Samuel Rødal --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 6678522..4d1d5dc 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -98,6 +98,10 @@ extern Q_GUI_EXPORT bool qt_cleartype_enabled; extern bool qt_applefontsmoothing_enabled; #endif +#if !defined(QT_MAX_CACHED_GLYPH_SIZE) +# define QT_MAX_CACHED_GLYPH_SIZE 64 +#endif + Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert); ////////////////////////////////// Private Methods ////////////////////////////////////////// @@ -1473,7 +1477,8 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem // don't try to cache huge fonts or vastly transformed fonts const qreal pixelSize = ti.fontEngine->fontDef.pixelSize; - if (pixelSize * pixelSize * qAbs(det) >= 64 * 64 || det < 0.25f || det > 4.f) + if (pixelSize * pixelSize * qAbs(det) >= QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE || + det < 0.25f || det > 4.f) drawCached = false; QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0 -- cgit v0.12 From 7d9ea423e426aa2809e8848856449c7ba8924458 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Fri, 1 Apr 2011 08:31:15 +0200 Subject: Check that pixmap is not null before accessing it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If QMeeGoGraphicsSystem::createPixmapData is called with origin raster pixmap data holding null image would result to null pointer deference when trying to fetch data pointer. To avoid the crash at graphics system switch pixmap data should be checked if it is NULL. Fixes: NB#237972 Signed-off-by: Pauli Nieminen Merge-request: 1160 Reviewed-by: Jørgen Lind --- src/plugins/graphicssystems/meego/qmeegographicssystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp index c904c3c..c515f55 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp @@ -217,7 +217,7 @@ QPixmapData *QMeeGoGraphicsSystem::createPixmapData(QPixmapData *origin) // and if the pixmap pointer matches our mapping... // create a shared image instead with the given handle. - if (origin->classId() == QPixmapData::RasterClass) { + if (!origin->isNull() && origin->classId() == QPixmapData::RasterClass) { QRasterPixmapData *rasterClass = static_cast (origin); void *rawResource = static_cast (rasterClass->buffer()->data_ptr()->data); -- cgit v0.12 From 9009e0e1138b684b7013903551a37c9ac1ebdd4c Mon Sep 17 00:00:00 2001 From: Arun Voleti Date: Fri, 1 Apr 2011 09:05:07 +0200 Subject: Modified pvrqwswsegl.c to make PowerVR work for processors using flipbuffer chain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 1083 Reviewed-by: Jørgen Lind --- src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c index 8a1fddf..f861838 100644 --- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c +++ b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include +#include #include #include #include @@ -202,7 +202,8 @@ static WSEGLError wseglDeleteDrawable(WSEGLDrawableHandle _drawable) PvrQwsDrawable *drawable = (PvrQwsDrawable *)_drawable; if (!drawable || drawable->type == PvrQwsScreen) return WSEGL_SUCCESS; - pvrQwsFreeBuffers(drawable); + if (pvrQwsDisplay.numFlipBuffers == 0) + pvrQwsFreeBuffers(drawable); if (pvrQwsReleaseWindow(drawable)) pvrQwsDestroyDrawable(drawable); return WSEGL_SUCCESS; -- cgit v0.12