From 17b946bd348c12decbf16c553805b0d6e97d1378 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Sun, 13 Sep 2009 09:46:52 +0200 Subject: Do not make Mac-specific checks on FreeBSD. Commit 098be4ff adds a check for MAC_OS_X_VERSION_MAX_ALLOWED and MAC_OS_X_VERSION_10_5, which do not exist on FreeBSD. Therefore, both evaluate to 0 and a Mac-specific header ends up included. This commit properly verifies that Q_OS_MAC is defined before performing that check. Merge-request: 1477 Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemwatcher.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index ae6ef58..b01302b 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -58,7 +58,7 @@ # include "qfilesystemwatcher_inotify_p.h" # include "qfilesystemwatcher_dnotify_p.h" #elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) -# if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) +# if (defined Q_OS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) # include "qfilesystemwatcher_fsevents_p.h" # endif //MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) # include "qfilesystemwatcher_kqueue_p.h" @@ -248,7 +248,7 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine() eng = QDnotifyFileSystemWatcherEngine::create(); return eng; #elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) -# if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) +# if (defined Q_OS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) return QFSEventsFileSystemWatcherEngine::create(); else -- cgit v0.12 From 3c99094f117a60ad39aa626af2af8fe6eb5d054f Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Sun, 13 Sep 2009 09:50:46 +0200 Subject: qdbus tool: enable service activation when calling methods When calling a method of a service, qdbus tool will not check whether the service exists nor if the interface is valid. This allows DBus try to activate the service when we call the method. Merge-request: 1472 Reviewed-by: Thiago Macieira --- tools/qdbus/qdbus/qdbus.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tools/qdbus/qdbus/qdbus.cpp b/tools/qdbus/qdbus/qdbus.cpp index ea31d2f..dd29d9f 100644 --- a/tools/qdbus/qdbus/qdbus.cpp +++ b/tools/qdbus/qdbus/qdbus.cpp @@ -241,13 +241,9 @@ static void placeCall(const QString &service, const QString &path, const QString const QString &member, QStringList args) { QDBusInterface iface(service, path, interface, connection); - if (!iface.isValid()) { - QDBusError err(iface.lastError()); - fprintf(stderr, "Interface '%s' not available in object %s at %s:\n%s (%s)\n", - qPrintable(interface), qPrintable(path), qPrintable(service), - qPrintable(err.name()), qPrintable(err.message())); - exit(1); - } + + // Don't check whether the interface is valid to allow DBus try to + // activate the service if possible. QVariantList params; if (!args.isEmpty()) { @@ -344,7 +340,10 @@ static void placeCall(const QString &service, const QString &path, const QString QDBusMessage reply = iface.callWithArgumentList(QDBus::Block, member, params); if (reply.type() == QDBusMessage::ErrorMessage) { QDBusError err = reply; - printf("Error: %s\n%s\n", qPrintable(err.name()), qPrintable(err.message())); + if (err.type() == QDBusError::ServiceUnknown) + fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service)); + else + printf("Error: %s\n%s\n", qPrintable(err.name()), qPrintable(err.message())); exit(2); } else if (reply.type() != QDBusMessage::ReplyMessage) { fprintf(stderr, "Invalid reply type %d\n", int(reply.type())); @@ -438,12 +437,12 @@ int main(int argc, char **argv) fprintf(stderr, "Service '%s' is not a valid name.\n", qPrintable(service)); exit(1); } - if (!bus->isServiceRegistered(service)) { - fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service)); - exit(1); - } if (args.isEmpty()) { + if (!bus->isServiceRegistered(service)) { + fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service)); + exit(1); + } printf("/\n"); listObjects(service, QString()); exit(0); @@ -455,6 +454,10 @@ int main(int argc, char **argv) exit(1); } if (args.isEmpty()) { + if (!bus->isServiceRegistered(service)) { + fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service)); + exit(1); + } listAllInterfaces(service, path); exit(0); } -- cgit v0.12 From 139cffbfe1598b32ffe658968694d163dc53e3dd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 13 Sep 2009 10:03:45 +0200 Subject: Improve upon the previous commit and allow more cases to activate. Use the Introspect call's return value to determine whether the service exists or not. That way, a call to a non-existing service may activate it. --- tools/qdbus/qdbus/qdbus.cpp | 66 +++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/tools/qdbus/qdbus/qdbus.cpp b/tools/qdbus/qdbus/qdbus.cpp index dd29d9f..2441240 100644 --- a/tools/qdbus/qdbus/qdbus.cpp +++ b/tools/qdbus/qdbus/qdbus.cpp @@ -108,19 +108,28 @@ static void printArg(const QVariant &v) static void listObjects(const QString &service, const QString &path) { - QDBusInterface iface(service, path.isEmpty() ? QLatin1String("/") : path, - QLatin1String("org.freedesktop.DBus.Introspectable"), connection); - if (!iface.isValid()) { - QDBusError err(iface.lastError()); - fprintf(stderr, "Cannot introspect object %s at %s:\n%s (%s)\n", - qPrintable(path.isEmpty() ? QString(QLatin1String("/")) : path), qPrintable(service), - qPrintable(err.name()), qPrintable(err.message())); - exit(1); + // make a low-level call, to avoid introspecting the Introspectable interface + QDBusMessage call = QDBusMessage::createMethodCall(service, path.isEmpty() ? QLatin1String("/") : path, + QLatin1String("org.freedesktop.DBus.Introspectable"), + QLatin1String("Introspect")); + QDBusReply xml = connection.call(call); + + if (path.isEmpty()) { + // top-level + if (xml.isValid()) { + printf("/\n"); + } else { + QDBusError err = xml.error(); + if (err.type() == QDBusError::ServiceUnknown) + fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service)); + else + printf("Error: %s\n%s\n", qPrintable(err.name()), qPrintable(err.message())); + exit(2); + } + } else if (!xml.isValid()) { + // this is not the first object, just fail silently + return; } - QDBusReply xml = iface.call(QLatin1String("Introspect")); - - if (!xml.isValid()) - return; // silently QDomDocument doc; doc.setContent(xml); @@ -192,18 +201,20 @@ static void listInterface(const QString &service, const QString &path, const QSt static void listAllInterfaces(const QString &service, const QString &path) { - QDBusInterface iface(service, path, QLatin1String("org.freedesktop.DBus.Introspectable"), connection); - if (!iface.isValid()) { - QDBusError err(iface.lastError()); - fprintf(stderr, "Cannot introspect object %s at %s:\n%s (%s)\n", - qPrintable(path), qPrintable(service), - qPrintable(err.name()), qPrintable(err.message())); - exit(1); + // make a low-level call, to avoid introspecting the Introspectable interface + QDBusMessage call = QDBusMessage::createMethodCall(service, path.isEmpty() ? QLatin1String("/") : path, + QLatin1String("org.freedesktop.DBus.Introspectable"), + QLatin1String("Introspect")); + QDBusReply xml = connection.call(call); + + if (!xml.isValid()) { + QDBusError err = xml.error(); + if (err.type() == QDBusError::ServiceUnknown) + fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service)); + else + printf("Error: %s\n%s\n", qPrintable(err.name()), qPrintable(err.message())); + exit(2); } - QDBusReply xml = iface.call(QLatin1String("Introspect")); - - if (!xml.isValid()) - return; // silently QDomDocument doc; doc.setContent(xml); @@ -439,11 +450,6 @@ int main(int argc, char **argv) } if (args.isEmpty()) { - if (!bus->isServiceRegistered(service)) { - fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service)); - exit(1); - } - printf("/\n"); listObjects(service, QString()); exit(0); } @@ -454,10 +460,6 @@ int main(int argc, char **argv) exit(1); } if (args.isEmpty()) { - if (!bus->isServiceRegistered(service)) { - fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service)); - exit(1); - } listAllInterfaces(service, path); exit(0); } -- cgit v0.12 From b2f2967411bcb23a807f6a17b042b4c58701af95 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 13 Sep 2009 10:18:57 +0200 Subject: Fix -Wconversion warnings where possible. In order to detect "int foo = myQReal" mistakes, one needs to compile with -Wconversion. However that flag triggers many warnings inside Qt. This commit fixes many of them, like qchar.h:295: warning: conversion to 'ushort' from 'unsigned int' may alter its value qglobal.h:1026: warning: conversion to 'qreal' from 'qint64' may alter its value qbytearray.h:441: warning: conversion to 'char' from 'int' may alter its value Other warnings remain (such as those coming from bitfields) Merge-request: 1460 Reviewed-by: Thiago Macieira --- src/corelib/global/qendian.h | 18 +++++++++--------- src/corelib/global/qglobal.h | 4 ++-- src/corelib/io/qiodevice.h | 2 +- src/corelib/kernel/qmath.h | 16 ++++++++-------- src/corelib/tools/qalgorithms.h | 14 +++++++------- src/corelib/tools/qbitarray.h | 8 ++++---- src/corelib/tools/qbytearray.h | 4 ++-- src/corelib/tools/qchar.h | 10 +++++----- src/corelib/tools/qlist.h | 8 ++++---- src/corelib/tools/qvector.h | 6 +++--- src/gui/kernel/qsizepolicy.h | 4 ++-- 11 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 3c804ce..5d9141f 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -149,9 +149,9 @@ template <> inline quint32 qFromLittleEndian(const uchar *src) template <> inline quint16 qFromLittleEndian(const uchar *src) { - return 0 - | src[0] - | src[1] * 0x0100; + return quint16(0 + | src[0] + | src[1] * 0x0100); } // signed specializations @@ -241,9 +241,9 @@ inline quint32 qFromBigEndian(const uchar *src) template<> inline quint16 qFromBigEndian(const uchar *src) { - return 0 - | src[1] - | src[0] * quint16(0x0100); + return quint16( 0 + | src[1] + | src[0] * quint16(0x0100)); } @@ -288,9 +288,9 @@ template <> inline quint32 qbswap(quint32 source) template <> inline quint16 qbswap(quint16 source) { - return 0 - | ((source & 0x00ff) << 8) - | ((source & 0xff00) >> 8); + return quint16( 0 + | ((source & 0x00ff) << 8) + | ((source & 0xff00) >> 8) ); } // signed specializations diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index b97b9d1..897dcea 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1081,10 +1081,10 @@ inline int qRound(qreal d) #if defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN) inline qint64 qRound64(double d) -{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qint64(d-1) + 0.5) + qint64(d-1); } +{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); } #else inline qint64 qRound64(qreal d) -{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qint64(d-1) + 0.5) + qint64(d-1); } +{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); } #endif template diff --git a/src/corelib/io/qiodevice.h b/src/corelib/io/qiodevice.h index adb8f1c..60ca74c 100644 --- a/src/corelib/io/qiodevice.h +++ b/src/corelib/io/qiodevice.h @@ -198,7 +198,7 @@ public: inline QT3_SUPPORT qint64 writeBlock(const QByteArray &data) { return write(data); } inline QT3_SUPPORT int getch() { char c; return getChar(&c) ? int(uchar(c)) : -1; } - inline QT3_SUPPORT int putch(int c) { return putChar(c) ? int(uchar(c)) : -1; } + inline QT3_SUPPORT int putch(int c) { return putChar(char(c)) ? int(uchar(c)) : -1; } inline QT3_SUPPORT int ungetch(int c) { ungetChar(uchar(c)); return c; } #endif }; diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h index bc0f46f..b521323 100644 --- a/src/corelib/kernel/qmath.h +++ b/src/corelib/kernel/qmath.h @@ -56,7 +56,7 @@ inline int qCeil(qreal v) { #ifdef QT_USE_MATH_H_FLOATS if (sizeof(qreal) == sizeof(float)) - return int(ceilf(v)); + return int(ceilf(float(v))); else #endif return int(ceil(v)); @@ -66,7 +66,7 @@ inline int qFloor(qreal v) { #ifdef QT_USE_MATH_H_FLOATS if (sizeof(qreal) == sizeof(float)) - return int(floorf(v)); + return int(floorf(float(v))); else #endif return int(floor(v)); @@ -76,7 +76,7 @@ inline qreal qSin(qreal v) { #ifdef QT_USE_MATH_H_FLOATS if (sizeof(qreal) == sizeof(float)) - return sinf(v); + return sinf(float(v)); else #endif return sin(v); @@ -86,7 +86,7 @@ inline qreal qCos(qreal v) { #ifdef QT_USE_MATH_H_FLOATS if (sizeof(qreal) == sizeof(float)) - return cosf(v); + return cosf(float(v)); else #endif return cos(v); @@ -96,7 +96,7 @@ inline qreal qAcos(qreal v) { #ifdef QT_USE_MATH_H_FLOATS if (sizeof(qreal) == sizeof(float)) - return acosf(v); + return acosf(float(v)); else #endif return acos(v); @@ -106,7 +106,7 @@ inline qreal qSqrt(qreal v) { #ifdef QT_USE_MATH_H_FLOATS if (sizeof(qreal) == sizeof(float)) - return sqrtf(v); + return sqrtf(float(v)); else #endif return sqrt(v); @@ -116,7 +116,7 @@ inline qreal qLn(qreal v) { #ifdef QT_USE_MATH_H_FLOATS if (sizeof(qreal) == sizeof(float)) - return logf(v); + return logf(float(v)); else #endif return log(v); @@ -126,7 +126,7 @@ inline qreal qPow(qreal x, qreal y) { #ifdef QT_USE_MATH_H_FLOATS if (sizeof(qreal) == sizeof(float)) - return powf(x, y); + return powf(float(x), float(y)); else #endif return pow(x, y); diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index 312cd4c..a68ce27 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -227,7 +227,7 @@ template Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value) { // Implementation is duplicated from QAlgorithmsPrivate to keep existing code - // compiling. We have to allow using *begin and value with different types, + // compiling. We have to allow using *begin and value with different types, // and then implementing operator< for those types. RandomAccessIterator middle; int n = end - begin; @@ -351,7 +351,7 @@ template Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan) { top: - int span = end - start; + int span = int(end - start); if (span < 2) return; @@ -417,9 +417,9 @@ Q_OUTOFLINE_TEMPLATE void qReverse(RandomAccessIterator begin, RandomAccessItera template Q_OUTOFLINE_TEMPLATE void qRotate(RandomAccessIterator begin, RandomAccessIterator middle, RandomAccessIterator end) { - qReverse(begin, middle); - qReverse(middle, end); - qReverse(begin, end); + qReverse(begin, middle); + qReverse(middle, end); + qReverse(begin, end); } template @@ -463,7 +463,7 @@ Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator begin, RandomAc const int span = end - begin; if (span < 2) return; - + const RandomAccessIterator middle = begin + span / 2; qStableSortHelper(begin, middle, t, lessThan); qStableSortHelper(middle, end, t, lessThan); @@ -480,7 +480,7 @@ template Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) { RandomAccessIterator middle; - int n = end - begin; + int n = int(end - begin); int half; while (n > 0) { diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h index c922262..2ae77b7 100644 --- a/src/corelib/tools/qbitarray.h +++ b/src/corelib/tools/qbitarray.h @@ -121,19 +121,19 @@ inline bool QBitArray::testBit(int i) const inline void QBitArray::setBit(int i) { Q_ASSERT(i >= 0 && i < size()); - *(reinterpret_cast(d.data())+1+(i>>3)) |= (1 << (i & 7)); } + *(reinterpret_cast(d.data())+1+(i>>3)) |= uchar(1 << (i & 7)); } inline void QBitArray::clearBit(int i) { Q_ASSERT(i >= 0 && i < size()); - *(reinterpret_cast(d.data())+1+(i>>3)) &= ~(1 << (i & 7)); } + *(reinterpret_cast(d.data())+1+(i>>3)) &= ~uchar(1 << (i & 7)); } inline void QBitArray::setBit(int i, bool val) { if (val) setBit(i); else clearBit(i); } inline bool QBitArray::toggleBit(int i) { Q_ASSERT(i >= 0 && i < size()); - uchar b = 1<< (i&7); uchar* p = reinterpret_cast(d.data())+1+(i>>3); - uchar c = *p&b; *p^=b; return c!=0; } + uchar b = uchar(1<<(i&7)); uchar* p = reinterpret_cast(d.data())+1+(i>>3); + uchar c = uchar(*p&b); *p^=b; return c!=0; } inline bool QBitArray::operator[](int i) const { return testBit(i); } inline bool QBitArray::operator[](uint i) const { return testBit(i); } diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 14425ba..e258481 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -442,10 +442,10 @@ class Q_CORE_EXPORT QByteRef { public: #ifdef Q_COMPILER_MANGLES_RETURN_TYPE inline operator const char() const - { return i < a.d->size ? a.d->data[i] : 0; } + { return i < a.d->size ? a.d->data[i] : char(0); } #else inline operator char() const - { return i < a.d->size ? a.d->data[i] : 0; } + { return i < a.d->size ? a.d->data[i] : char(0); } #endif inline QByteRef &operator=(char c) { if (i >= a.d->size) a.expand(i); else a.detach(); diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h index bcfb361..5ece472 100644 --- a/src/corelib/tools/qchar.h +++ b/src/corelib/tools/qchar.h @@ -292,10 +292,10 @@ public: return (uint(high.ucs)<<10) + low.ucs - 0x35fdc00; } static inline ushort highSurrogate(uint ucs4) { - return (ucs4>>10) + 0xd7c0; + return ushort((ucs4>>10) + 0xd7c0); } static inline ushort lowSurrogate(uint ucs4) { - return ucs4%0x400 + 0xdc00; + return ushort(ucs4%0x400 + 0xdc00); } static Category QT_FASTCALL category(uint ucs4); @@ -366,7 +366,7 @@ inline char QChar::toLatin1() const { return ucs > 0xff ? '\0' : char(ucs); } #endif inline QChar QChar::fromLatin1(char c) { return QChar(ushort(uchar(c))); } -inline QChar::QChar(uchar c, uchar r) : ucs((r << 8) | c){} +inline QChar::QChar(uchar c, uchar r) : ucs(ushort((r << 8) | c)){} inline QChar::QChar(short rc) : ucs(ushort(rc)){} inline QChar::QChar(uint rc) : ucs(ushort(rc & 0xffff)){} inline QChar::QChar(int rc) : ucs(ushort(rc & 0xffff)){} @@ -374,9 +374,9 @@ inline QChar::QChar(SpecialCharacter s) : ucs(ushort(s)) {} inline QChar::QChar(QLatin1Char ch) : ucs(ch.unicode()) {} inline void QChar::setCell(uchar acell) -{ ucs = (ucs & 0xff00) + acell; } +{ ucs = ushort((ucs & 0xff00) + acell); } inline void QChar::setRow(uchar arow) -{ ucs = (ushort(arow)<<8) + (ucs&0xff); } +{ ucs = ushort((ushort(arow)<<8) + (ucs&0xff)); } inline bool operator==(QChar c1, QChar c2) { return c1.unicode() == c2.unicode(); } inline bool operator!=(QChar c1, QChar c2) { return c1.unicode() != c2.unicode(); } diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 3111426..49b5c0d 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -202,7 +202,7 @@ public: inline iterator &operator-=(int j) { i-=j; return *this; } inline iterator operator+(int j) const { return iterator(i+j); } inline iterator operator-(int j) const { return iterator(i-j); } - inline int operator-(iterator j) const { return i - j.i; } + inline int operator-(iterator j) const { return int(i - j.i); } }; friend class iterator; @@ -420,7 +420,7 @@ Q_INLINE_TEMPLATE QList &QList::operator=(const QList &l) template inline typename QList::iterator QList::insert(iterator before, const T &t) { - int iBefore = before.i - reinterpret_cast(p.begin()); + int iBefore = int(before.i - reinterpret_cast(p.begin())); Node *n = reinterpret_cast(p.insert(iBefore)); QT_TRY { node_construct(n, t); @@ -706,7 +706,7 @@ Q_OUTOFLINE_TEMPLATE QList &QList::operator+=(const QList &l) node_copy(n, reinterpret_cast(p.end()), reinterpret_cast(l.p.begin())); } QT_CATCH(...) { // restore the old end - d->end -= (reinterpret_cast(p.end()) - n); + d->end -= int(reinterpret_cast(p.end()) - n); QT_RETHROW; } return *this; @@ -728,7 +728,7 @@ Q_OUTOFLINE_TEMPLATE int QList::indexOf(const T &t, int from) const Node *e = reinterpret_cast(p.end()); while (++n != e) if (n->t() == t) - return n - reinterpret_cast(p.begin()); + return int(n - reinterpret_cast(p.begin())); } return -1; } diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 60d6921..2737a87 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -543,7 +543,7 @@ void QVector::append(const T &t) template Q_TYPENAME QVector::iterator QVector::insert(iterator before, size_type n, const T &t) { - int offset = before - p->array; + int offset = int(before - p->array); if (n != 0) { const T copy(t); if (d->ref != 1 || d->size + n > d->alloc) @@ -577,8 +577,8 @@ Q_TYPENAME QVector::iterator QVector::insert(iterator before, size_type n, template Q_TYPENAME QVector::iterator QVector::erase(iterator abegin, iterator aend) { - int f = abegin - p->array; - int l = aend - p->array; + int f = int(abegin - p->array); + int l = int(aend - p->array); int n = l - f; detach(); if (QTypeInfo::isComplex) { diff --git a/src/gui/kernel/qsizepolicy.h b/src/gui/kernel/qsizepolicy.h index b0c6e9a..2914a21 100644 --- a/src/gui/kernel/qsizepolicy.h +++ b/src/gui/kernel/qsizepolicy.h @@ -224,8 +224,8 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QSizePolicy &); inline void QSizePolicy::transpose() { Policy hData = horizontalPolicy(); Policy vData = verticalPolicy(); - uchar hStretch = horizontalStretch(); - uchar vStretch = verticalStretch(); + uchar hStretch = uchar(horizontalStretch()); + uchar vStretch = uchar(verticalStretch()); setHorizontalPolicy(vData); setVerticalPolicy(hData); setHorizontalStretch(vStretch); -- cgit v0.12 From 04fb09581891c8bab912eb03a40eeda4d2211bc7 Mon Sep 17 00:00:00 2001 From: Till Adam Date: Thu, 3 Sep 2009 20:15:03 +0200 Subject: Fix compilation with QT_NO_CAST_FROM_BYTEARRAY. Merge-request: 1421 Reviewed-By: Thiago Macieira --- src/testlib/qtest.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index 412ad86..5171d3a 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -88,14 +88,14 @@ template<> inline char *toString(const QByteArray &ba) template<> inline char *toString(const QTime &time) { return time.isValid() - ? qstrdup(time.toString(QLatin1String("hh:mm:ss.zzz")).toLatin1()) + ? qstrdup(time.toString(QLatin1String("hh:mm:ss.zzz")).toLatin1().constData()) : qstrdup("Invalid QTime"); } template<> inline char *toString(const QDate &date) { return date.isValid() - ? qstrdup(date.toString(QLatin1String("yyyy/MM/dd")).toLatin1()) + ? qstrdup(date.toString(QLatin1String("yyyy/MM/dd")).toLatin1().constData()) : qstrdup("Invalid QDate"); } @@ -103,7 +103,7 @@ template<> inline char *toString(const QDateTime &dateTime) { return dateTime.isValid() ? qstrdup((dateTime.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")) + - (dateTime.timeSpec() == Qt::LocalTime ? QLatin1String("[local time]") : QLatin1String("[UTC]"))).toLatin1()) + (dateTime.timeSpec() == Qt::LocalTime ? QLatin1String("[local time]") : QLatin1String("[UTC]"))).toLatin1().constData()) : qstrdup("Invalid QDateTime"); } -- cgit v0.12 From f393ae6dd4cc8e40c5b97c18efe7862253bc2bdd Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 14 Sep 2009 09:01:39 +1000 Subject: Make QGLWidget::renderText() desktop only The renderText() function is only for legacy desktop systems, so revert the previous attempts to port it to OpenGL/ES. Documentation note added to direct users to QPainter::drawText() for the correct way to render text onto an OpenGL paint device. Reviewed-by: trustme --- src/opengl/qgl.cpp | 247 ++++++++++++++++------------------------------------- 1 file changed, 72 insertions(+), 175 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 9148456..fcb3510 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -63,7 +63,6 @@ #include "qpixmap.h" #include "qimage.h" -#include "qmatrix4x4.h" #include "qgl_p.h" #if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) @@ -320,26 +319,52 @@ void QGL::setPreferredPaintEngine(QPaintEngine::Type engineType) \sa QGLContext, QGLWidget */ -static inline void qgluProject - (qreal objx, qreal objy, qreal objz, - const QMatrix4x4& model, const QMatrix4x4& proj, const GLint viewport[4], - GLfloat *winx, GLfloat *winy, GLfloat* winz) +#ifndef QT_OPENGL_ES + +static inline void transform_point(GLdouble out[4], const GLdouble m[16], const GLdouble in[4]) +{ +#define M(row,col) m[col*4+row] + out[0] = + M(0, 0) * in[0] + M(0, 1) * in[1] + M(0, 2) * in[2] + M(0, 3) * in[3]; + out[1] = + M(1, 0) * in[0] + M(1, 1) * in[1] + M(1, 2) * in[2] + M(1, 3) * in[3]; + out[2] = + M(2, 0) * in[0] + M(2, 1) * in[1] + M(2, 2) * in[2] + M(2, 3) * in[3]; + out[3] = + M(3, 0) * in[0] + M(3, 1) * in[1] + M(3, 2) * in[2] + M(3, 3) * in[3]; +#undef M +} + +static inline GLint qgluProject(GLdouble objx, GLdouble objy, GLdouble objz, + const GLdouble model[16], const GLdouble proj[16], + const GLint viewport[4], + GLdouble * winx, GLdouble * winy, GLdouble * winz) { - QVector4D transformed = proj.map(model.map(QVector4D(objx, objy, objz, 1))); + GLdouble in[4], out[4]; + + in[0] = objx; + in[1] = objy; + in[2] = objz; + in[3] = 1.0; + transform_point(out, model, in); + transform_point(in, proj, out); - qreal w = transformed.w(); - if (w == 0.0f) - w = 1.0f; // Just in case! + if (in[3] == 0.0) + return GL_FALSE; - qreal x = transformed.x() / w; - qreal y = transformed.y() / w; + in[0] /= in[3]; + in[1] /= in[3]; + in[2] /= in[3]; - *winx = viewport[0] + (1 + x) * viewport[2] / 2; - *winy = viewport[1] + (1 + y) * viewport[3] / 2; + *winx = viewport[0] + (1 + in[0]) * viewport[2] / 2; + *winy = viewport[1] + (1 + in[1]) * viewport[3] / 2; - *winz = (1 + transformed.z() / w) / 2; + *winz = (1 + in[2]) / 2; + return GL_TRUE; } +#endif // !QT_OPENGL_ES + /*! Constructs a QGLFormat object with the following default settings: \list @@ -4131,13 +4156,12 @@ int QGLWidget::fontDisplayListBase(const QFont & font, int listBase) return base; } +#ifndef QT_OPENGL_ES + static void qt_save_gl_state() { -#ifndef QT_OPENGL_ES glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); glPushAttrib(GL_ALL_ATTRIB_BITS); -#endif -#if !defined(QT_OPENGL_ES_2) glMatrixMode(GL_TEXTURE); glPushMatrix(); glLoadIdentity(); @@ -4152,32 +4176,25 @@ static void qt_save_gl_state() glDisable(GL_STENCIL_TEST); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); -#endif // !defined(QT_OPENGL_ES_2) } static void qt_restore_gl_state() { -#if !defined(QT_OPENGL_ES_2) glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); -#endif // !defined(QT_OPENGL_ES_2) -#ifndef QT_OPENGL_ES glPopAttrib(); glPopClientAttrib(); -#endif } static void qt_gl_draw_text(QPainter *p, int x, int y, const QString &str, const QFont &font) { GLfloat color[4]; -#ifndef QT_OPENGL_ES glGetFloatv(GL_CURRENT_COLOR, &color[0]); -#endif QColor col; col.setRgbF(color[0], color[1], color[2],color[3]); @@ -4192,29 +4209,7 @@ static void qt_gl_draw_text(QPainter *p, int x, int y, const QString &str, p->setFont(old_font); } -#if defined(GL_OES_VERSION_1_0) && !defined(GL_OES_VERSION_1_1) - -// OpenGL/ES 1.0 cannot fetch viewports from the GL server. -// We therefore create a default viewport to simulate the fetch. - -static void qt_gl_get_viewport(GLint *view, int deviceWidth, int deviceHeight) -{ - view[0] = 0; - view[1] = 0; - view[2] = deviceWidth; - view[3] = deviceHeight; -} - -#else - -static void qt_gl_get_viewport(GLint *view, int deviceWidth, int deviceHeight) -{ - Q_UNUSED(deviceWidth); - Q_UNUSED(deviceHeight); - glGetIntegerv(GL_VIEWPORT, view); -} - -#endif +#endif // !QT_OPENGL_ES /*! Renders the string \a str into the GL context of this widget. @@ -4230,37 +4225,29 @@ static void qt_gl_get_viewport(GLint *view, int deviceWidth, int deviceHeight) future version of Qt. \note This function clears the stencil buffer. + + \note This function is not supported on OpenGL/ES systems. + \l{Overpainting Example}{Overpaint} with QPainter::drawText() instead. */ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, int) { +#ifndef QT_OPENGL_ES Q_D(QGLWidget); if (str.isEmpty() || !isValid()) return; GLint view[4]; -#ifndef QT_OPENGL_ES bool use_scissor_testing = glIsEnabled(GL_SCISSOR_TEST); -#else - bool use_scissor_testing = false; -#endif + if (!use_scissor_testing) + glGetIntegerv(GL_VIEWPORT, &view[0]); int width = d->glcx->device()->width(); int height = d->glcx->device()->height(); - if (!use_scissor_testing) { - qt_gl_get_viewport(&view[0], width, height); - } else { - view[0] = 0; - view[1] = 0; - view[2] = width; - view[3] = height; - } bool auto_swap = autoBufferSwap(); QPaintEngine *engine = paintEngine(); -#ifndef QT_OPENGL_ES if (engine->type() == QPaintEngine::OpenGL2) static_cast(engine)->setRenderTextActive(true); -#endif QPainter *p; bool reuse_painter = false; if (engine->isActive()) { @@ -4268,30 +4255,22 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, p = engine->painter(); qt_save_gl_state(); -#if !defined(QT_OPENGL_ES_2) glDisable(GL_DEPTH_TEST); glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); -#ifndef QT_OPENGL_ES glOrtho(0, width, height, 0, 0, 1); -#else - glOrthof(0, width, height, 0, 0, 1); -#endif glMatrixMode(GL_MODELVIEW); glLoadIdentity(); -#endif // !defined(QT_OPENGL_ES_2) } else { setAutoBufferSwap(false); // disable glClear() as a result of QPainter::begin() d->disable_clear_on_painter_begin = true; if (engine->type() == QPaintEngine::OpenGL2) { qt_save_gl_state(); -#ifndef QT_OPENGL_ES_2 glMatrixMode(GL_MODELVIEW); glLoadIdentity(); -#endif } p = new QPainter(this); } @@ -4319,75 +4298,17 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, if (engine->type() == QPaintEngine::OpenGL2) qt_restore_gl_state(); } -#ifndef QT_OPENGL_ES if (engine->type() == QPaintEngine::OpenGL2) static_cast(engine)->setRenderTextActive(false); +#else // QT_OPENGL_ES + Q_UNUSED(x); + Q_UNUSED(y); + Q_UNUSED(str); + Q_UNUSED(font); + qWarning("QGLWidget::renderText is not supported under OpenGL/ES"); #endif } -#if defined(QT_OPENGL_ES_2) || \ - (defined(GL_OES_VERSION_1_0) && !defined(GL_OES_VERSION_1_1)) - -// OpenGL/ES 1.0 cannot fetch matrices from the GL server. -// OpenGL/ES 2.0 does not use fixed-function matrices at all. -// We therefore create some default matrices to simulate the fetch. - -static QMatrix4x4 qt_gl_projection_matrix(int deviceWidth, int deviceHeight) -{ - QMatrix4x4 m; - m.ortho(0, deviceWidth, deviceHeight, 0, -1, 1); - return m; -} - -static QMatrix4x4 qt_gl_modelview_matrix(void) -{ - return QMatrix4x4(); -} - -#else // !QT_OPENGL_ES_2 - -static QMatrix4x4 qt_gl_fetch_matrix(GLenum type) -{ - QMatrix4x4 matrix; -#if defined(QT_OPENGL_ES_1_CL) - GLfixed mat[16]; - glGetFixedv(type, mat); - qreal *m = matrix.data(); - for (int index = 0; index < 16; ++index) - m[index] = vt2f(mat[index]); -#else - if (sizeof(qreal) == sizeof(GLfloat)) { - glGetFloatv(type, reinterpret_cast(matrix.data())); -#if !defined(QT_OPENGL_ES) - } else if (sizeof(qreal) == sizeof(GLdouble)) { - glGetDoublev(type, reinterpret_cast(matrix.data())); -#endif - } else { - GLfloat mat[16]; - glGetFloatv(type, mat); - qreal *m = matrix.data(); - for (int index = 0; index < 16; ++index) - m[index] = mat[index]; - } -#endif - matrix.inferSpecialType(); - return matrix; -} - -static QMatrix4x4 qt_gl_projection_matrix(int deviceWidth, int deviceHeight) -{ - Q_UNUSED(deviceWidth); - Q_UNUSED(deviceHeight); - return qt_gl_fetch_matrix(GL_PROJECTION_MATRIX); -} - -static QMatrix4x4 qt_gl_modelview_matrix(void) -{ - return qt_gl_fetch_matrix(GL_MODELVIEW_MATRIX); -} - -#endif // !QT_OPENGL_ES_2 - /*! \overload \a x, \a y and \a z are specified in scene or object coordinates @@ -4395,28 +4316,12 @@ static QMatrix4x4 qt_gl_modelview_matrix(void) can be useful if you want to annotate models with text labels and have the labels move with the model as it is rotated etc. - This function fetches the modelview matrix, projection matrix, and - current viewport from the GL server to map (\a x, \a y, \a z) - into window co-ordinates. This entails several round-trips to the GL - server which will probably impact performance. - - Fetching the modelview and projection matrices is not supported - under OpenGL/ES 1.0 and OpenGL/ES 2.0 so a default orthographic - projection will be used to map the co-ordinates on those platforms. - This probably will not give results that are consistent with desktop - and OpenGL/ES 1.1 systems. Fetching the viewport is not supported - under OpenGL/ES 1.0, so the full device will be used as the viewport. - - This function is deprecated because it is non-portable. It is - recommended that the application map the co-ordinates itself using - application-provided matrix data that reflects the desired - transformation. Then use QPainter::drawText() to draw \a str at - the mapped position. - - \sa QMatrix4x4 + \note This function is not supported on OpenGL/ES systems. + \l{Overpainting Example}{Overpaint} with QPainter::drawText() instead. */ void QGLWidget::renderText(double x, double y, double z, const QString &str, const QFont &font, int) { +#ifndef QT_OPENGL_ES Q_D(QGLWidget); if (str.isEmpty() || !isValid()) return; @@ -4425,31 +4330,23 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con int width = d->glcx->device()->width(); int height = d->glcx->device()->height(); - - QMatrix4x4 model = qt_gl_modelview_matrix(); - QMatrix4x4 proj = qt_gl_projection_matrix(width, height); + GLdouble model[4][4], proj[4][4]; GLint view[4]; - qt_gl_get_viewport(view, width, height); - - GLfloat win_x = 0, win_y = 0, win_z = 0; - qgluProject(qreal(x), qreal(y), qreal(z), - model, proj, &view[0], &win_x, &win_y, &win_z); + glGetDoublev(GL_MODELVIEW_MATRIX, &model[0][0]); + glGetDoublev(GL_PROJECTION_MATRIX, &proj[0][0]); + glGetIntegerv(GL_VIEWPORT, &view[0]); + GLdouble win_x = 0, win_y = 0, win_z = 0; + qgluProject(x, y, z, &model[0][0], &proj[0][0], &view[0], + &win_x, &win_y, &win_z); win_y = height - win_y; // y is inverted QPaintEngine *engine = paintEngine(); -#ifndef QT_OPENGL_ES if (engine->type() == QPaintEngine::OpenGL2) static_cast(engine)->setRenderTextActive(true); -#endif QPainter *p; bool reuse_painter = false; -#ifndef QT_OPENGL_ES bool use_depth_testing = glIsEnabled(GL_DEPTH_TEST); bool use_scissor_testing = glIsEnabled(GL_SCISSOR_TEST); -#else - bool use_depth_testing = false; - bool use_scissor_testing = false; -#endif if (engine->isActive()) { reuse_painter = true; @@ -4471,23 +4368,17 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con } else if (use_scissor_testing) { glEnable(GL_SCISSOR_TEST); } -#if !defined(QT_OPENGL_ES_2) glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(0, 0, width, height); -#ifndef QT_OPENGL_ES glOrtho(0, width, height, 0, 0, 1); -#else - glOrthof(0, width, height, 0, 0, 1); -#endif glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glAlphaFunc(GL_GREATER, 0.0); glEnable(GL_ALPHA_TEST); if (use_depth_testing) glEnable(GL_DEPTH_TEST); - glTranslatef(0, 0, -win_z); -#endif // !defined(QT_OPENGL_ES_2) + glTranslated(0, 0, -win_z); qt_gl_draw_text(p, qRound(win_x), qRound(win_y), str, font); if (reuse_painter) { @@ -4500,9 +4391,15 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con setAutoBufferSwap(auto_swap); d->disable_clear_on_painter_begin = false; } -#ifndef QT_OPENGL_ES if (engine->type() == QPaintEngine::OpenGL2) static_cast(engine)->setRenderTextActive(false); +#else // QT_OPENGL_ES + Q_UNUSED(x); + Q_UNUSED(y); + Q_UNUSED(z); + Q_UNUSED(str); + Q_UNUSED(font); + qWarning("QGLWidget::renderText is not supported under OpenGL/ES"); #endif } -- cgit v0.12 From d622f5db9a81959227145603643a89208d77f611 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 14 Sep 2009 09:18:34 +1000 Subject: qdoc: qglColor() doesn't work under OpenGL/ES 2.0 --- src/opengl/qgl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index fcb3510..f388cd5 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -3970,6 +3970,8 @@ void QGLWidget::glDraw() Calls glColor4 (in RGBA mode) or glIndex (in color-index mode) with the color \a c. Applies to this widgets GL context. + \note This function is not supported on OpenGL/ES 2.0 systems. + \sa qglClearColor(), QGLContext::currentContext(), QColor */ @@ -3993,6 +3995,8 @@ void QGLWidget::qglColor(const QColor& c) const glIndexi(ctx->colorIndex(c)); } #endif //QT_OPENGL_ES +#else + Q_UNUSED(c); #endif //QT_OPENGL_ES_2 } -- cgit v0.12 From 6b401a8f426c089714c656b2ccfd334d3cbe3280 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 14 Sep 2009 09:23:49 +1000 Subject: QGLWidget::fontDisplayListBase() is not supported under OpenGL/ES Update documentation and #ifdef out the implementation. Reviewed-by: trustme --- src/opengl/qgl.cpp | 10 ++++++++-- src/opengl/qgl_p.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index f388cd5..e545c2c 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4113,9 +4113,12 @@ QImage QGLWidget::convertToGLFormat(const QImage& img) the characters in the given \a font. \a listBase indicates the base value used when generating the display lists for the font. The default value is 2000. + + \note This function is not supported on OpenGL/ES systems. */ int QGLWidget::fontDisplayListBase(const QFont & font, int listBase) { +#ifndef QT_OPENGL_ES Q_D(QGLWidget); int base; @@ -4133,9 +4136,7 @@ int QGLWidget::fontDisplayListBase(const QFont & font, int listBase) QString color_key; if (font.styleStrategy() != QFont::NoAntialias) { GLfloat color[4]; -#ifndef QT_OPENGL_ES glGetFloatv(GL_CURRENT_COLOR, color); -#endif color_key.sprintf("%f_%f_%f",color[0], color[1], color[2]); } QString key = font.key() + color_key + QString::number((int) regenerate); @@ -4158,6 +4159,11 @@ int QGLWidget::fontDisplayListBase(const QFont & font, int listBase) base = maxBase; } return base; +#else // QT_OPENGL_ES + Q_UNUSED(font); + Q_UNUSED(listBase); + return 0; +#endif } #ifndef QT_OPENGL_ES diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index fdd28a4..57b40fb 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -196,7 +196,9 @@ public: bool autoSwap; QGLColormap cmap; +#ifndef QT_OPENGL_ES QMap displayListCache; +#endif bool disable_clear_on_painter_begin; -- cgit v0.12 From dcbafc17a0fff2a7de7d4eb61e7fd665e59aae18 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 14 Sep 2009 09:38:26 +1000 Subject: qdoc: document default values for QGLFramebufferObject properties --- src/opengl/qglframebufferobject.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 81f2aa9..4b8a67e 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -120,6 +120,7 @@ void QGLFramebufferObjectFormat::detach() By default the format specifies a non-multisample framebuffer object with no attachments, texture target \c GL_TEXTURE_2D, and internal format \c GL_RGBA8. + On OpenGL/ES systems, the default internal format is \c GL_RGBA. \sa samples(), attachment(), target(), internalTextureFormat() */ @@ -165,8 +166,8 @@ QGLFramebufferObjectFormat::~QGLFramebufferObjectFormat() /*! Sets the number of samples per pixel for a multisample framebuffer object - to \a samples. - A sample count of 0 represents a regular non-multisample framebuffer object. + to \a samples. The default sample count of 0 represents a regular + non-multisample framebuffer object. If the desired amount of samples per pixel is not supported by the hardware then the maximum number of samples per pixel will be used. Note that @@ -185,6 +186,7 @@ void QGLFramebufferObjectFormat::setSamples(int samples) /*! Returns the number of samples per pixel if a framebuffer object is a multisample framebuffer object. Otherwise, returns 0. + The default value is 0. \sa setSamples() */ @@ -205,8 +207,8 @@ void QGLFramebufferObjectFormat::setAttachment(QGLFramebufferObject::Attachment } /*! - Returns the status of the depth and stencil buffers attached to - a framebuffer object. + Returns the configuration of the depth and stencil buffers attached to + a framebuffer object. The default is QGLFramebufferObject::NoAttachment. \sa setAttachment() */ @@ -229,7 +231,8 @@ void QGLFramebufferObjectFormat::setTextureTarget(GLenum target) /*! Returns the texture target of the texture attached to a framebuffer object. - Ignored for multisample framebuffer objects. + Ignored for multisample framebuffer objects. The default is + \c GL_TEXTURE_2D. \sa setTextureTarget(), samples() */ @@ -253,7 +256,9 @@ void QGLFramebufferObjectFormat::setInternalTextureFormat(GLenum internalTexture /*! Returns the internal format of a framebuffer object's texture or - multisample framebuffer object's color buffer. + multisample framebuffer object's color buffer. The default is + \c GL_RGBA8 on desktop OpenGL systems, and \c GL_RGBA on + OpenGL/ES systems. \sa setInternalTextureFormat() */ @@ -641,7 +646,8 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, By default, no depth and stencil buffers are attached. This behavior can be toggled using one of the overloaded constructors. - The default internal texture format is \c GL_RGBA8. + The default internal texture format is \c GL_RGBA8 for desktop + OpenGL, and \c GL_RGBA for OpenGL/ES. It is important that you have a current GL context set when creating the QGLFramebufferObject, otherwise the initialization @@ -727,7 +733,8 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, QMacCompatGLen The \a attachment parameter describes the depth/stencil buffer configuration, \a target the texture target and \a internal_format the internal texture format. The default texture target is \c - GL_TEXTURE_2D, while the default internal format is \c GL_RGBA8. + GL_TEXTURE_2D, while the default internal format is \c GL_RGBA8 + for desktop OpenGL and \c GL_RGBA for OpenGL/ES. \sa size(), texture(), attachment() */ @@ -758,7 +765,8 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, Attachment att The \a attachment parameter describes the depth/stencil buffer configuration, \a target the texture target and \a internal_format the internal texture format. The default texture target is \c - GL_TEXTURE_2D, while the default internal format is \c GL_RGBA8. + GL_TEXTURE_2D, while the default internal format is \c GL_RGBA8 + for desktop OpenGL and \c GL_RGBA for OpenGL/ES. \sa size(), texture(), attachment() */ -- cgit v0.12 From ed5588f6e9ab11d61fb770eb76509a33962cf571 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 14 Sep 2009 09:43:40 +1000 Subject: qdoc: QGLWidgets -> QGLWidget, etc, for proper doc linking. --- src/opengl/qgl.cpp | 20 ++++++++++---------- src/opengl/qglcolormap.cpp | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index e545c2c..bd9b5a5 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -228,7 +228,7 @@ bool qt_gl_preferGL2Engine() \since 4.6 Sets the preferred OpenGL paint engine that is used to draw onto - QGLWidgets, QGLPixelBuffers and QGLFrameBufferObjects with QPainter + QGLWidget, QGLPixelBuffer and QGLFramebufferObject targets with QPainter in Qt. The \a engineType parameter specifies which of the GL engines to @@ -1265,8 +1265,8 @@ QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags() /*! - Returns the default QGLFormat for the application. All QGLWidgets - that are created use this format unless another format is + Returns the default QGLFormat for the application. All QGLWidget + objects that are created use this format unless another format is specified, e.g. when they are constructed. If no special default format has been set using @@ -1353,7 +1353,7 @@ void QGLFormat::setDefaultOverlayFormat(const QGLFormat &f) /*! - Returns true if all the options of the two QGLFormats are equal; + Returns true if all the options of the two QGLFormat objects are equal; otherwise returns false. */ @@ -1371,7 +1371,7 @@ bool operator==(const QGLFormat& a, const QGLFormat& b) /*! - Returns false if all the options of the two QGLFormats are equal; + Returns false if all the options of the two QGLFormat objects are equal; otherwise returns true. */ @@ -3100,7 +3100,7 @@ const QGLContext* QGLContext::currentContext() QGLFormat format\endlink and you can also create widgets with customized rendering \link QGLContext contexts\endlink. - You can also share OpenGL display lists between QGLWidgets (see + You can also share OpenGL display lists between QGLWidget objects (see the documentation of the QGLWidget constructors for details). Note that under Windows, the QGLContext belonging to a QGLWidget @@ -3382,7 +3382,7 @@ bool QGLWidget::isValid() const Returns true if this widget's GL context is shared with another GL context, otherwise false is returned. Context sharing might not be - possible if the QGLWidgets use different formats. + possible if the widgets use different formats. \sa format() */ @@ -3480,7 +3480,7 @@ void QGLWidget::swapBuffers() resizeGL() or paintGL(). This method will try to keep display list and texture object sharing - in effect with other QGLWidgets, but changing the format might make + in effect with other QGLWidget objects, but changing the format might make sharing impossible. Use isSharing() to see if sharing is still in effect. @@ -3784,7 +3784,7 @@ void QGLWidget::paintEvent(QPaintEvent *) /*! Renders the current scene on a pixmap and returns the pixmap. - You can use this method on both visible and invisible QGLWidgets. + You can use this method on both visible and invisible QGLWidget objects. This method will create a pixmap and a temporary QGLContext to render on the pixmap. It will then call initializeGL(), @@ -4866,7 +4866,7 @@ QGLContextResource::~QGLContextResource() if (m_resources.size()) { qWarning("QtOpenGL: Resources are still available at program shutdown.\n" " This is possibly caused by a leaked QGLWidget, \n" - " QGLFrameBufferObject or QGLPixelBuffer."); + " QGLFramebufferObject or QGLPixelBuffer."); } #endif } diff --git a/src/opengl/qglcolormap.cpp b/src/opengl/qglcolormap.cpp index 7edb250..edb5c4f 100644 --- a/src/opengl/qglcolormap.cpp +++ b/src/opengl/qglcolormap.cpp @@ -42,14 +42,14 @@ /*! \class QGLColormap \brief The QGLColormap class is used for installing custom colormaps into - QGLWidgets. + a QGLWidget. \module OpenGL \ingroup painting-3D \ingroup shared QGLColormap provides a platform independent way of specifying and - installing indexed colormaps into QGLWidgets. QGLColormap is + installing indexed colormaps for a QGLWidget. QGLColormap is especially useful when using the OpenGL color-index mode. Under X11 you must use an X server that supports either a \c -- cgit v0.12 From 822f979f4398bb364de34a07bfbaa4ade93502db Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 14 Sep 2009 10:01:34 +1000 Subject: qdoc: QGLFormat documentation improvements --- src/opengl/qgl.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index bd9b5a5..1bcfab8 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -271,7 +271,7 @@ void QGL::setPreferredPaintEngine(QPaintEngine::Type engineType) \i \link setStereo() Stereo buffers.\endlink \i \link setDirectRendering() Direct rendering.\endlink \i \link setOverlay() Presence of an overlay.\endlink - \i \link setPlane() The plane of an overlay format.\endlink + \i \link setPlane() Plane of an overlay.\endlink \i \link setSampleBuffers() Multisample buffers.\endlink \endlist @@ -1353,8 +1353,10 @@ void QGLFormat::setDefaultOverlayFormat(const QGLFormat &f) /*! - Returns true if all the options of the two QGLFormat objects are equal; - otherwise returns false. + Returns true if all the options of the two QGLFormat objects + \a a and \a b are equal; otherwise returns false. + + \relates QGLFormat */ bool operator==(const QGLFormat& a, const QGLFormat& b) @@ -1371,8 +1373,10 @@ bool operator==(const QGLFormat& a, const QGLFormat& b) /*! - Returns false if all the options of the two QGLFormat objects are equal; - otherwise returns true. + Returns false if all the options of the two QGLFormat objects + \a a and \a b are equal; otherwise returns true. + + \relates QGLFormat */ bool operator!=(const QGLFormat& a, const QGLFormat& b) -- cgit v0.12 From c151b747e0d7b45e0c7d5de6964b9dfef207d833 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 14 Sep 2009 10:10:58 +1000 Subject: qdoc: size of a QGLColormap is 256 on all platforms, not just Windows --- src/opengl/qglcolormap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qglcolormap.cpp b/src/opengl/qglcolormap.cpp index edb5c4f..b86f9e0 100644 --- a/src/opengl/qglcolormap.cpp +++ b/src/opengl/qglcolormap.cpp @@ -61,7 +61,7 @@ least a \c PseudoColor visual. Note that you may experience colormap flashing if your X server is running in 8 bit mode. - Under Windows the size of the colormap is always set to 256 + The size() of the colormap is always set to 256 colors. Note that under Windows you can also install colormaps in child widgets. -- cgit v0.12 From c54541adf74bb8a87fd59d31f7e96626d3ca5e43 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 14 Sep 2009 11:53:23 +1000 Subject: Don't have to glEnable(GL_TEXTURE_2D) when using shaders. OpenGL/ES 2.0 systems were giving a GL error when GL_TEXTURE_2D was enabled and disabled. Reviewed-by: trustme --- examples/opengl/hellogl_es2/glwidget.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/examples/opengl/hellogl_es2/glwidget.cpp b/examples/opengl/hellogl_es2/glwidget.cpp index 5200467..a31c34a 100644 --- a/examples/opengl/hellogl_es2/glwidget.cpp +++ b/examples/opengl/hellogl_es2/glwidget.cpp @@ -92,7 +92,6 @@ void GLWidget::showBubbles(bool bubbles) void GLWidget::paintQtLogo() { - glDisable(GL_TEXTURE_2D); program1.setAttributeArray(vertexAttr1, vertices.constData()); program1.setAttributeArray(normalAttr1, normals.constData()); glDrawArrays(GL_TRIANGLES, 0, vertices.size()); @@ -102,7 +101,6 @@ void GLWidget::paintQtLogo() void GLWidget::paintTexturedCube() { - glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, m_uiTexture); GLfloat afVertices[] = { -0.5, 0.5, 0.5, 0.5,-0.5,0.5,-0.5,-0.5,0.5, @@ -172,7 +170,6 @@ void GLWidget::initializeGL () { glClearColor(0.1f, 0.1f, 0.2f, 1.0f); - glEnable(GL_TEXTURE_2D); glGenTextures(1, &m_uiTexture); m_uiTexture = bindTexture(QImage(":/qt.png")); @@ -270,7 +267,6 @@ void GLWidget::paintGL() glClearColor(0.1f, 0.1f, 0.2f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glEnable(GL_TEXTURE_2D); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); -- cgit v0.12 From f3e2ccf63de242feeba10e75fd00ffd43fc038b0 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Mon, 14 Sep 2009 12:33:37 +1000 Subject: AudioDevices demo doesn't do anything on Windows -put example audiodevices in layout. -added more checking to testSettings() in win32 implementation. -disabled objects in example audiodevices that are not editable. -added more checking to alsa implementation for preferredFormat(). -changed internal strings from tr to QLatin1String. Reviewed-by:Justin Mcpherson --- .../multimedia/audio/audiodevices/audiodevices.cpp | 12 +- .../audio/audiodevices/audiodevicesbase.ui | 444 ++++++++++----------- src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 67 +++- src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 36 +- src/multimedia/audio/qaudioinput_alsa_p.cpp | 8 +- src/multimedia/audio/qaudioinput_win32_p.cpp | 2 +- src/multimedia/audio/qaudiooutput_alsa_p.cpp | 8 +- src/multimedia/audio/qaudiooutput_win32_p.cpp | 2 +- 8 files changed, 303 insertions(+), 276 deletions(-) diff --git a/examples/multimedia/audio/audiodevices/audiodevices.cpp b/examples/multimedia/audio/audiodevices/audiodevices.cpp index 52aa4db..0d305ff 100644 --- a/examples/multimedia/audio/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audio/audiodevices/audiodevices.cpp @@ -58,6 +58,14 @@ AudioDevicesBase::~AudioDevicesBase() {} AudioTest::AudioTest( QMainWindow *parent, Qt::WFlags f ) : AudioDevicesBase( parent, f ) { + nearestFreq->setDisabled(true); + nearestChannel->setDisabled(true); + nearestCodec->setDisabled(true); + nearestSampleSize->setDisabled(true); + nearestSampleType->setDisabled(true); + nearestEndian->setDisabled(true); + logOutput->setDisabled(true); + mode = QAudio::AudioOutput; modeBox->addItem("Input"); modeBox->addItem("Output"); @@ -87,6 +95,8 @@ AudioTest::~AudioTest() void AudioTest::test() { // tries to set all the settings picked. + logOutput->clear(); + logOutput->append("NOTE: an invalid codec audio/test exists for testing, to get a fail condition."); if(device) { if(device->isFormatSupported(settings)) { @@ -179,7 +189,7 @@ void AudioTest::deviceChanged(int idx) if(codecz.size()) settings.setCodec(codecz.at(0)); // Add false to create failed condition! - codecsBox->addItem("audio/mpeg"); + codecsBox->addItem("audio/test"); sampleSizesBox->clear(); QList sampleSizez = device->supportedSampleSizes(); diff --git a/examples/multimedia/audio/audiodevices/audiodevicesbase.ui b/examples/multimedia/audio/audiodevices/audiodevicesbase.ui index 674f201..5207338 100644 --- a/examples/multimedia/audio/audiodevices/audiodevicesbase.ui +++ b/examples/multimedia/audio/audiodevices/audiodevicesbase.ui @@ -1,7 +1,8 @@ - + + AudioDevicesBase - - + + 0 0 @@ -9,246 +10,223 @@ 702 - + AudioDevicesBase - - - - 0 - 28 - 504 - 653 - - - - - - 40 - 21 - 321 - 506 - - - - - - - - 1 - 0 - - - - Device - - - - - - - Mode - - - - - - - - - - - - - QFrame::Panel - - - QFrame::Raised - - - Actual Settings - - - Qt::AlignCenter - - - - - - - QFrame::Panel - - - QFrame::Raised - - - Nearest Settings - - - Qt::AlignCenter - - - - - - - Frequency - - - - - - - Frequency - - - - - - - - - - - - - Channels - - - - - - - Channel - - - - - - - - - - - - - Codecs - - - - - - - Codec - - - - - - - - - - - - - SampleSize - - - - - - - SampleSize - - - - - - - - - - - - - SampleType - - - - - - - SampleType - - - - - - - - - - - - - Endianess - - - - - - - Endianess - - - - - - - - - - - - - - 0 - 40 - - - - - - - - Test - - - - - + + + + + + + + + 1 + 0 + + + + Device + + + + + + + Mode + + + + + + + + + + + + + QFrame::Panel + + + QFrame::Raised + + + Actual Settings + + + Qt::AlignCenter + + + + + + + QFrame::Panel + + + QFrame::Raised + + + Nearest Settings + + + Qt::AlignCenter + + + + + + + Frequency + + + + + + + Frequency + + + + + + + + + + + + + Channels + + + + + + + Channel + + + + + + + + + + + + + Codecs + + + + + + + Codec + + + + + + + + + + + + + SampleSize + + + + + + + SampleSize + + + + + + + + + + + + + SampleType + + + + + + + SampleType + + + + + + + + + + + + + Endianess + + + + + + + Endianess + + + + + + + + + + + + + + 0 + 40 + + + + + + + + Test + + + + + + - - + + 0 0 504 - 28 - - - - - - - 0 - 681 - 504 - 21 + 19 + diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index 4ed1b41..c944cf0 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -81,13 +81,18 @@ QAudioFormat QAudioDeviceInfoPrivate::preferredFormat() const nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(16); - nearest.setCodec(tr("audio/pcm")); + nearest.setCodec(QLatin1String("audio/pcm")); } else { nearest.setFrequency(8000); nearest.setChannels(1); - nearest.setSampleType(QAudioFormat::SignedInt); + nearest.setSampleType(QAudioFormat::UnSignedInt); nearest.setSampleSize(8); - nearest.setCodec(tr("audio/pcm")); + nearest.setCodec(QLatin1String("audio/pcm")); + if(!testSettings(nearest)) { + nearest.setChannels(2); + nearest.setSampleSize(16); + nearest.setSampleType(QAudioFormat::SignedInt); + } } return nearest; } @@ -145,9 +150,9 @@ bool QAudioDeviceInfoPrivate::open() { int err = 0; QString dev = device; - if(!dev.contains(tr("default"))) { + if(!dev.contains(QLatin1String("default"))) { int idx = snd_card_get_index(dev.toLocal8Bit().constData()); - dev = QString(tr("hw:%1,0")).arg(idx); + dev = QString(QLatin1String("hw:%1,0")).arg(idx); } if(mode == QAudio::AudioOutput) { err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); @@ -172,16 +177,15 @@ bool QAudioDeviceInfoPrivate::testSettings(const QAudioFormat& format) const { // Set nearest to closest settings that do work. // See if what is in settings will work (return value). - int err = 0; snd_pcm_t* handle; snd_pcm_hw_params_t *params; QString dev = device; // open() - if(!dev.contains(tr("default"))) { + if(!dev.contains(QLatin1String("default"))) { int idx = snd_card_get_index(dev.toLocal8Bit().constData()); - dev = QString(tr("hw:%1,0")).arg(idx); + dev = QString(QLatin1String("hw:%1,0")).arg(idx); } if(mode == QAudio::AudioOutput) { err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); @@ -205,8 +209,45 @@ bool QAudioDeviceInfoPrivate::testSettings(const QAudioFormat& format) const snd_pcm_hw_params_alloca( ¶ms ); snd_pcm_hw_params_any( handle, params ); + // set the values! + snd_pcm_hw_params_set_channels(handle,params,format.channels()); + snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); + switch(format.sampleSize()) { + case 8: + if(format.sampleType() == QAudioFormat::SignedInt) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8); + else if(format.sampleType() == QAudioFormat::UnSignedInt) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8); + break; + case 16: + if(format.sampleType() == QAudioFormat::SignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE); + } else if(format.sampleType() == QAudioFormat::UnSignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE); + } + break; + case 32: + if(format.sampleType() == QAudioFormat::SignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE); + } else if(format.sampleType() == QAudioFormat::UnSignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE); + } + } + // For now, just accept only audio/pcm codec - if(!format.codec().startsWith(tr("audio/pcm"))) { + if(!format.codec().startsWith(QLatin1String("audio/pcm"))) { err=-1; } else testCodec = true; @@ -313,7 +354,7 @@ void QAudioDeviceInfoPrivate::updateLists() typez.append(QAudioFormat::SignedInt); typez.append(QAudioFormat::UnSignedInt); typez.append(QAudioFormat::Float); - codecz.append(tr("audio/pcm")); + codecz.append(QLatin1String("audio/pcm")); close(); } @@ -346,10 +387,10 @@ QList QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode) if(io == NULL) _m = mode; - QString str = tr(name); + QString str = QLatin1String(name); - if(str.contains(tr("default"))) { - int pos = str.indexOf(tr("="),0); + if(str.contains(QLatin1String("default"))) { + int pos = str.indexOf(QLatin1String("="),0); devices.append(str.mid(pos+1).toLocal8Bit().constData()); } } diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index 371f442..ba9f5e2 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -99,13 +99,13 @@ QAudioFormat QAudioDeviceInfoPrivate::preferredFormat() const nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(16); - nearest.setCodec(tr("audio/pcm")); + nearest.setCodec(QLatin1String("audio/pcm")); } else { nearest.setFrequency(11025); nearest.setChannels(1); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(8); - nearest.setCodec(tr("audio/pcm")); + nearest.setCodec(QLatin1String("audio/pcm")); } return nearest; } @@ -174,27 +174,25 @@ bool QAudioDeviceInfoPrivate::testSettings(const QAudioFormat& format) const // Set nearest to closest settings that do work. // See if what is in settings will work (return value). - bool testChannel = false; - bool testCodec = false; - bool testFreq = false; - - int err = 0; + bool failed = false; // For now, just accept only audio/pcm codec - if(!format.codec().startsWith(tr("audio/pcm"))) { - err=-1; - } else - testCodec = true; + if(!format.codec().startsWith(QLatin1String("audio/pcm"))) + failed = true; - if(err>=0 && format.channels() != -1) { - testChannel = true; - } + if(!failed && !(format.channels() == 1 || format.channels() == 2)) + failed = true; - if(err>=0 && format.frequency() != -1) { - testFreq = true; + if(!failed) { + if(!(format.frequency() == 8000 || format.frequency() == 11025 || format.frequency() == 22050 || + format.frequency() == 44100 || format.frequency() == 48000 || format.frequency() == 96000)) + failed = true; } - if(err == 0) { + if(!failed && !(format.sampleSize() == 8 || format.sampleSize() == 16)) + failed = true; + + if(!failed) { // settings work return true; } @@ -209,7 +207,7 @@ void QAudioDeviceInfoPrivate::updateLists() DWORD fmt = NULL; QString tmp; - if(device.compare(tr("default")) == 0) + if(device.compare(QLatin1String("default")) == 0) base = true; if(mode == QAudio::AudioOutput) { @@ -331,7 +329,7 @@ void QAudioDeviceInfoPrivate::updateLists() typez.append(QAudioFormat::SignedInt); typez.append(QAudioFormat::UnSignedInt); - codecz.append(tr("audio/pcm")); + codecz.append(QLatin1String("audio/pcm")); } } diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index c98102c..f36ffc8 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -78,7 +78,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor pullMode = true; resuming = false; - QStringList list1 = QString(tr(device)).split(tr(":")); + QStringList list1 = QString(QLatin1String(device)).split(QLatin1String(":")); m_device = QByteArray(list1.at(0).toLocal8Bit().constData()); timer = new QTimer(this); @@ -254,9 +254,9 @@ bool QAudioInputPrivate::open() int count=0; unsigned int freakuency=settings.frequency(); - QString dev = QString(tr(m_device.constData())); - if(!dev.contains(tr("default"))) { - dev = QString(tr("default:CARD=%1")).arg(tr(m_device.constData())); + QString dev = QString(QLatin1String(m_device.constData())); + if(!dev.contains(QLatin1String("default"))) { + dev = QString(QLatin1String("default:CARD=%1")).arg(QLatin1String(m_device.constData())); } // Step 1: try and open the device diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index 315a59b..31441ae 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -245,7 +245,7 @@ bool QAudioInputPrivate::open() == MMSYSERR_NOERROR) { QString tmp; tmp = QString::fromUtf16((const unsigned short*)wic.szPname); - if(tmp.compare(tr(m_device)) == 0) { + if(tmp.compare(QLatin1String(m_device)) == 0) { devId = ii; break; } diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp index 45ff115..e8a3f5c 100644 --- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -81,7 +81,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF resuming = false; opened = false; - QStringList list1 = QString(tr(device)).split(tr(":")); + QStringList list1 = QString(QLatin1String(device)).split(QLatin1String(":")); m_device = QByteArray(list1.at(0).toLocal8Bit().constData()); timer = new QTimer(this); @@ -277,9 +277,9 @@ bool QAudioOutputPrivate::open() int count=0; unsigned int freakuency=settings.frequency(); - QString dev = tr(m_device.constData()); - if(!dev.contains(tr("default"))) { - dev = QString(tr("default:CARD=%1")).arg(tr(m_device.constData())); + QString dev = QLatin1String(m_device.constData()); + if(!dev.contains(QLatin1String("default"))) { + dev = QString(QLatin1String("default:CARD=%1")).arg(QLatin1String(m_device.constData())); } // Step 1: try and open the device while((count < 5) && (err < 0)) { diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index fae680c..aea3a3f 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -241,7 +241,7 @@ bool QAudioOutputPrivate::open() == MMSYSERR_NOERROR) { QString tmp; tmp = QString::fromUtf16((const unsigned short*)woc.szPname); - if(tmp.compare(tr(m_device)) == 0) { + if(tmp.compare(QLatin1String(m_device)) == 0) { devId = ii; break; } -- cgit v0.12 From 7809276c405d4b32eb671737ea0967b673ea271c Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 14 Sep 2009 13:26:25 +1000 Subject: Use redF(), etc when setting GL colors Reviewed-by: Sarah Smith --- src/opengl/qgl.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 1bcfab8..f8a88601 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -3983,7 +3983,7 @@ void QGLWidget::qglColor(const QColor& c) const { #if !defined(QT_OPENGL_ES_2) #ifdef QT_OPENGL_ES - glColor4f(c.red()/255.0, c.green()/255.0, c.blue()/255.0, c.alpha()/255.0); + glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF()); #else Q_D(const QGLWidget); const QGLContext *ctx = QGLContext::currentContext(); @@ -4015,15 +4015,13 @@ void QGLWidget::qglColor(const QColor& c) const void QGLWidget::qglClearColor(const QColor& c) const { #ifdef QT_OPENGL_ES - glClearColor((GLfloat)c.red() / 255.0, (GLfloat)c.green() / 255.0, - (GLfloat)c.blue() / 255.0, (GLfloat) c.alpha() / 255.0); + glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF()); #else Q_D(const QGLWidget); const QGLContext *ctx = QGLContext::currentContext(); if (ctx) { if (ctx->format().rgba()) - glClearColor((GLfloat)c.red() / 255.0, (GLfloat)c.green() / 255.0, - (GLfloat)c.blue() / 255.0, (GLfloat) c.alpha() / 255.0); + glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF()); else if (!d->cmap.isEmpty()) { // QGLColormap in use? int i = d->cmap.find(c.rgb()); if (i < 0) -- cgit v0.12 From 732660e89af34c76f6aa8a46ce8507dfd5fad077 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 14 Sep 2009 13:30:38 +1000 Subject: qdoc: QGLWidget::colormap() returns a QGLColormap, not a QColormap --- src/opengl/qgl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index f8a88601..c2b747a 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4092,10 +4092,10 @@ QImage QGLWidget::convertToGLFormat(const QImage& img) colormaps installed. Asking for the colormap of a child widget will return the colormap for the child's top-level widget. - If no colormap has been set for this widget, the QColormap + If no colormap has been set for this widget, the QGLColormap returned will be empty. - \sa setColormap() + \sa setColormap(), QGLColormap::isEmpty() */ /*! -- cgit v0.12 From 9e3fb515207f8d80fe87b6e34e78d3d201b0b438 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 14 Sep 2009 12:30:44 +1000 Subject: Performance: reduce TLS overhead of QGLContext::currentContext() The handling for the current QGLContext was looking up the same TLS data several times per call (hasLocalData() and localData() calls particularly). This change also refactors the code a little so that the setting of the QGLContext within makeCurrent() and doneCurrent() is in one location in the code instead of six (one per platform). Reviewed-by: Michael Brasser Reviewed-by: Sarah Smith --- src/opengl/qgl.cpp | 27 ++++++++++++++++++++++++--- src/opengl/qgl_mac.mm | 10 ++-------- src/opengl/qgl_p.h | 7 ++----- src/opengl/qgl_qws.cpp | 13 +++---------- src/opengl/qgl_win.cpp | 10 ++-------- src/opengl/qgl_wince.cpp | 13 +++---------- src/opengl/qgl_x11.cpp | 13 +++---------- src/opengl/qgl_x11egl.cpp | 13 +++---------- 8 files changed, 42 insertions(+), 64 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index c2b747a..1a0957c 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -103,7 +103,11 @@ QT_BEGIN_NAMESPACE QGLExtensionFuncs QGLContextPrivate::qt_extensionFuncs; #endif -QThreadStorage qgl_context_storage; +struct QGLThreadContext { + QGLContext *context; +}; + +static QThreadStorage qgl_context_storage; Q_GLOBAL_STATIC(QGLFormat, qgl_default_format) @@ -2939,11 +2943,28 @@ void QGLContext::setInitialized(bool on) const QGLContext* QGLContext::currentContext() { - if (qgl_context_storage.hasLocalData()) - return qgl_context_storage.localData()->context; + QGLThreadContext *threadContext = qgl_context_storage.localData(); + if (threadContext) + return threadContext->context; return 0; } +void QGLContextPrivate::setCurrentContext(QGLContext *context) +{ + QGLThreadContext *threadContext = qgl_context_storage.localData(); + if (!threadContext) { + if (!QThread::currentThread()) { + // We don't have a current QThread, so just set the static. + QGLContext::currentCtx = context; + return; + } + threadContext = new QGLThreadContext; + qgl_context_storage.setLocalData(threadContext); + } + threadContext->context = context; + QGLContext::currentCtx = context; // XXX: backwards-compat, not thread-safe +} + /*! \fn bool QGLContext::chooseContext(const QGLContext* shareContext = 0) diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm index dd9d9ff..063082b 100644 --- a/src/opengl/qgl_mac.mm +++ b/src/opengl/qgl_mac.mm @@ -493,11 +493,7 @@ void QGLContext::makeCurrent() #else [static_cast(d->cx) makeCurrentContext]; #endif - currentCtx = this; - if (!qgl_context_storage.hasLocalData() && QThread::currentThread()) - qgl_context_storage.setLocalData(new QGLThreadContext); - if (qgl_context_storage.hasLocalData()) - qgl_context_storage.localData()->context = this; + QGLContextPrivate::setCurrentContext(this); } #ifndef QT_MAC_USE_COCOA @@ -656,9 +652,7 @@ void QGLContext::doneCurrent() ) return; - currentCtx = 0; - if (qgl_context_storage.hasLocalData()) - qgl_context_storage.localData()->context = 0; + QGLContextPrivate::setCurrentContext(0); #ifndef QT_MAC_USE_COCOA aglSetCurrentContext(0); #else diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 57b40fb..2b74e69 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -351,6 +351,8 @@ public: static inline QGLExtensionFuncs& extensionFuncs(QGLContextGroup *) { return qt_extensionFuncs; } #endif + static void setCurrentContext(QGLContext *context); + QPixmapFilter *createPixmapFilter(int type) const; }; @@ -398,11 +400,6 @@ public: Q_DECLARE_OPERATORS_FOR_FLAGS(QGLExtensions::Extensions) -struct QGLThreadContext { - QGLContext *context; -}; -extern QThreadStorage qgl_context_storage; - class QGLShareRegister { public: diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp index 759f9de..7197776 100644 --- a/src/opengl/qgl_qws.cpp +++ b/src/opengl/qgl_qws.cpp @@ -260,13 +260,8 @@ void QGLContext::makeCurrent() return; } - if (d->eglContext->makeCurrent()) { - if (!qgl_context_storage.hasLocalData() && QThread::currentThread()) - qgl_context_storage.setLocalData(new QGLThreadContext); - if (qgl_context_storage.hasLocalData()) - qgl_context_storage.localData()->context = this; - currentCtx = this; - } + if (d->eglContext->makeCurrent()) + QGLContextPrivate::setCurrentContext(this); } void QGLContext::doneCurrent() @@ -275,9 +270,7 @@ void QGLContext::doneCurrent() if (d->eglContext) d->eglContext->doneCurrent(); - if (qgl_context_storage.hasLocalData()) - qgl_context_storage.localData()->context = 0; - currentCtx = 0; + QGLContextPrivate::setCurrentContext(0); } diff --git a/src/opengl/qgl_win.cpp b/src/opengl/qgl_win.cpp index 78dad80..2f9e225 100644 --- a/src/opengl/qgl_win.cpp +++ b/src/opengl/qgl_win.cpp @@ -1173,11 +1173,7 @@ void QGLContext::makeCurrent() } if (wglMakeCurrent(d->dc, d->rc)) { - if (!qgl_context_storage.hasLocalData() && QThread::currentThread()) - qgl_context_storage.setLocalData(new QGLThreadContext); - if (qgl_context_storage.hasLocalData()) - qgl_context_storage.localData()->context = this; - currentCtx = this; + QGLContextPrivate::setCurrentContext(this); } else { qwglError("QGLContext::makeCurrent()", "wglMakeCurrent"); } @@ -1187,10 +1183,8 @@ void QGLContext::makeCurrent() void QGLContext::doneCurrent() { Q_D(QGLContext); - currentCtx = 0; wglMakeCurrent(0, 0); - if (qgl_context_storage.hasLocalData()) - qgl_context_storage.localData()->context = 0; + QGLContextPrivate::setCurrentContext(0); if (deviceIsPixmap() && d->hbitmap) { QPixmap *pm = static_cast(d->paintDevice); *pm = QPixmap::fromWinHBITMAP(d->hbitmap); diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp index 83efca8..4e655f1 100644 --- a/src/opengl/qgl_wince.cpp +++ b/src/opengl/qgl_wince.cpp @@ -450,13 +450,8 @@ void QGLContext::makeCurrent() return; } - if (d->eglContext->makeCurrent()) { - if (!qgl_context_storage.hasLocalData() && QThread::currentThread()) - qgl_context_storage.setLocalData(new QGLThreadContext); - if (qgl_context_storage.hasLocalData()) - qgl_context_storage.localData()->context = this; - currentCtx = this; - } + if (d->eglContext->makeCurrent()) + QGLContextPrivate::setCurrentContext(this); } @@ -467,9 +462,7 @@ void QGLContext::doneCurrent() if (d->eglContext) d->eglContext->doneCurrent(); - if (qgl_context_storage.hasLocalData()) - qgl_context_storage.localData()->context = 0; - currentCtx = 0; + QGLContextPrivate::setCurrentContext(0); } void QGLContext::swapBuffers() const diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index cb1da18..da7972d 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -791,22 +791,15 @@ void QGLContext::makeCurrent() if (!ok) qWarning("QGLContext::makeCurrent(): Failed."); - if (ok) { - if (!qgl_context_storage.hasLocalData() && QThread::currentThread()) - qgl_context_storage.setLocalData(new QGLThreadContext); - if (qgl_context_storage.hasLocalData()) - qgl_context_storage.localData()->context = this; - currentCtx = this; - } + if (ok) + QGLContextPrivate::setCurrentContext(this); } void QGLContext::doneCurrent() { Q_D(QGLContext); glXMakeCurrent(qt_x11Info(d->paintDevice)->display(), 0, 0); - if (qgl_context_storage.hasLocalData()) - qgl_context_storage.localData()->context = 0; - currentCtx = 0; + QGLContextPrivate::setCurrentContext(0); } diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index c54315f..7dfd642 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -146,13 +146,8 @@ void QGLContext::makeCurrent() return; } - if (d->eglContext->makeCurrent()) { - if (!qgl_context_storage.hasLocalData() && QThread::currentThread()) - qgl_context_storage.setLocalData(new QGLThreadContext); - if (qgl_context_storage.hasLocalData()) - qgl_context_storage.localData()->context = this; - currentCtx = this; - } + if (d->eglContext->makeCurrent()) + QGLContextPrivate::setCurrentContext(this); } void QGLContext::doneCurrent() @@ -161,9 +156,7 @@ void QGLContext::doneCurrent() if (d->eglContext) d->eglContext->doneCurrent(); - if (qgl_context_storage.hasLocalData()) - qgl_context_storage.localData()->context = 0; - currentCtx = 0; + QGLContextPrivate::setCurrentContext(0); } -- cgit v0.12 From 2cc93f74b531c653fde19c52f925b20b04c69b36 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 10 Sep 2009 07:42:20 +0200 Subject: Autotest preventing gl from crashing on shutdown with dangling contexts --- tests/auto/qgl/tst_qgl.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index ebbfbae..a0b8b5d 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -81,6 +81,8 @@ private slots: void stackedFBOs(); void colormap(); void fboFormat(); + + void testDontCrashOnDanglingResources(); }; tst_QGL::tst_QGL() @@ -1513,5 +1515,16 @@ void tst_QGL::fboFormat() QVERIFY(format1c != format4c); } +void tst_QGL::testDontCrashOnDanglingResources() +{ + // We have a number of Q_GLOBAL_STATICS inside the QtOpenGL + // library. This test is verify that we don't crash as a result of + // them calling into libgl on application shutdown. + QWidget *widget = new UnclippedWidget(); + widget->show(); + qApp->processEvents(); + widget->hide(); +} + QTEST_MAIN(tst_QGL) #include "tst_qgl.moc" -- cgit v0.12 From b7f3fe8557f4c4b9ec90449649a9a929f8f50393 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 11 Sep 2009 09:26:08 +0200 Subject: fix compile error debug output --- src/gui/text/qfontdatabase_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/gui/text/qfontdatabase_win.cpp index 6b874af..ae26dab 100644 --- a/src/gui/text/qfontdatabase_win.cpp +++ b/src/gui/text/qfontdatabase_win.cpp @@ -471,7 +471,7 @@ static void initializeDb() // print the database for (int f = 0; f < db->count; f++) { QtFontFamily *family = db->families[f]; - qDebug(" %s: %p", family->name.latin1(), family); + qDebug(" %s: %p", qPrintable(family->name), family); populate_database(family->name); #if 0 -- cgit v0.12 From 97ac103fb5a0139c007c8e2073a7a2cee1423618 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 14 Sep 2009 07:13:40 +0200 Subject: Fixed compilation of some ifdef'ed out debug messages. Reviewed-by: trustme --- src/gui/painting/qpaintengine_raster.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 46a3362..bac0a76 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -114,7 +114,7 @@ extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // // #define QT_DEBUG_DRAW #ifdef QT_DEBUG_DRAW -void dumpClip(int width, int height, QClipData *clip); +void dumpClip(int width, int height, const QClipData *clip); #endif #define QT_FAST_SPANS @@ -495,7 +495,7 @@ bool QRasterPaintEngine::begin(QPaintDevice *device) << ") devType:" << device->devType() << "devRect:" << d->deviceRect; if (d->baseClip) { - dumpClip(d->rasterBuffer->width(), d->rasterBuffer->height(), d->baseClip); + dumpClip(d->rasterBuffer->width(), d->rasterBuffer->height(), &*d->baseClip); } #endif @@ -534,7 +534,7 @@ bool QRasterPaintEngine::end() Q_D(QRasterPaintEngine); qDebug() << "QRasterPaintEngine::end devRect:" << d->deviceRect; if (d->baseClip) { - dumpClip(d->rasterBuffer->width(), d->rasterBuffer->height(), d->baseClip); + dumpClip(d->rasterBuffer->width(), d->rasterBuffer->height(), &*d->baseClip); } #endif @@ -1181,6 +1181,11 @@ static void qrasterpaintengine_dirty_clip(QRasterPaintEnginePrivate *d, QRasterP d->solid_color_filler.clip = d->clip(); d->solid_color_filler.adjustSpanMethods(); + +#ifdef QT_DEBUG_DRAW + dumpClip(d->rasterBuffer->width(), d->rasterBuffer->height(), &*d->clip()); +#endif + } @@ -1780,9 +1785,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush) if (path.isEmpty()) return; #ifdef QT_DEBUG_DRAW - QRealRect vectorPathBounds = path.controlPointRect(); - QRectF rf(vectorPathBounds.x1, vectorPathBounds.y1, - vectorPathBounds.x2 - vectorPathBounds.x1, vectorPathBounds.y2 - vectorPathBounds.y1); + QRectF rf = path.controlPointRect(); qDebug() << "QRasterPaintEngine::fill(): " << "size=" << path.elementCount() << ", hints=" << hex << path.hints() @@ -6068,7 +6071,7 @@ static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip, */ #ifdef QT_DEBUG_DRAW -void dumpClip(int width, int height, QClipData *clip) +void dumpClip(int width, int height, const QClipData *clip) { QImage clipImg(width, height, QImage::Format_ARGB32_Premultiplied); clipImg.fill(0xffff0000); @@ -6078,8 +6081,10 @@ void dumpClip(int width, int height, QClipData *clip) int y0 = height; int y1 = 0; + ((QClipData *) clip)->spans(); // Force allocation of the spans structure... + for (int i = 0; i < clip->count; ++i) { - QSpan *span = clip->spans() + i; + const QSpan *span = ((QClipData *) clip)->spans() + i; for (int j = 0; j < span->len; ++j) clipImg.setPixel(span->x + j, span->y, 0xffffff00); x0 = qMin(x0, int(span->x)); -- cgit v0.12 From 3aa5fec77b2e1edbcbd1d7735389725076f91cbf Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 14 Sep 2009 08:14:12 +0200 Subject: Fixed groupbox drawing on xp when hitting the fallback code. When swapping the alphachannel we need to make sure we create proper premultiplied pixels. When setting alpha to 0, that means also setting the other pixel values to 0. This bug was made visible by the gl graphics system. Reviewed-by: MariusSO --- src/gui/styles/qwindowsxpstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 5645950..0dc1832 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -586,7 +586,7 @@ bool QWindowsXPStylePrivate::swapAlphaChannel(const QRect &rect, bool allPixels) } register unsigned int alphaValue = (*buffer) & 0xFF000000; if (alphaValue == 0xFF000000) { - *buffer &= 0x00FFFFFF; + *buffer = 0; valueChange = true; } else if (alphaValue == 0) { *buffer |= 0xFF000000; -- cgit v0.12