From 190f64aab3fc8bb8e325bf48326c7b09d62b6419 Mon Sep 17 00:00:00 2001 From: Julien Blanc Date: Tue, 18 Mar 2014 11:58:49 +0100 Subject: Added timezone support for datetime fields in PSQL This patch adds correct timezone support in PSQL plugin. Prior to this patch, no timezone support was provided, so only the following case worked : * using local time in both client application and postgresql server * datetime were using second precision This patch tries to take care that postgresql has two different datatypes for date time, respectively : * timestamp with time zone * timestamp without time zone Both are internally stored as UTC values, but are not parsed the same. * timestamp with time zone assumes that there is a time zone information and will parse date time accordingly, and then, convert into UTC before storing them * timestamp without time zone assumes that there is no time zone information and will silently ignore any, unless the datetime is explicitly specified as having a time zone, in case it will convert it into UTC before storing it Both are retrieved as local time values, with the following difference * timestamp with time zone includes the timezone information (2014-02-12 10:20:12+0100 for example) * timestamp without time zone does not include it The patch does the following : * parse the date retrieved by postgresql server using QDateTime functions, which work correctly * always convert the date to UTC before giving it to postgresql * force time zone so that timezone information is taken into account by postgresql * also adds the milliseconds when storing QDateTime values The following configurations are tested to work : * client and server using same timezone, timestamp with or without tz * client and server using different timezone, timestamp with tz The following configuration will *not* work : * client and server using different timezones, timestamp without tz Because data will be converted to local time by the postgresql server, so when returned it will be different from what had been serialized. Prior to this patch, it gave the illusion to work because since TZ information was lost, time was stored as local time from postgresql. Lots of inconsistencies occurred, though, in case client tz changes... I don't expect this to be an issue since having different TZ in server and client and *not* handling this is a broken setup anyway. Almost based on changes proposed by julien.blanc@nmc-company.fr [ChangeLog][QtSql] Added timezone support for datetime fields in PSQL Task-number: QTBUG-36211 Change-Id: I5650a5ef60cb3f14f0ab619825612831c7e90c12 Reviewed-by: Mark Brand --- src/sql/drivers/psql/qsql_psql.cpp | 43 +++++++++++++++----------------------- 1 file changed, 17 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index e76dcc26a0..4268ea06f6 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -426,11 +426,8 @@ QVariant QPSQLResult::data(int i) #ifndef QT_NO_DATESTRING if (str.isEmpty()) return QVariant(QTime()); - if (str.at(str.length() - 3) == QLatin1Char('+') || str.at(str.length() - 3) == QLatin1Char('-')) - // strip the timezone - // TODO: fix this when timestamp support comes into QDateTime - return QVariant(QTime::fromString(str.left(str.length() - 3), Qt::ISODate)); - return QVariant(QTime::fromString(str, Qt::ISODate)); + else + return QVariant(QTime::fromString(str, Qt::ISODate)); #else return QVariant(str); #endif @@ -438,19 +435,13 @@ QVariant QPSQLResult::data(int i) case QVariant::DateTime: { QString dtval = QString::fromLatin1(val); #ifndef QT_NO_DATESTRING - if (dtval.length() < 10) - return QVariant(QDateTime()); - // remove the timezone - // TODO: fix this when timestamp support comes into QDateTime - if (dtval.at(dtval.length() - 3) == QLatin1Char('+') || dtval.at(dtval.length() - 3) == QLatin1Char('-')) - dtval.chop(3); - // milliseconds are sometimes returned with 2 digits only - if (dtval.at(dtval.length() - 3).isPunct()) - dtval += QLatin1Char('0'); - if (dtval.isEmpty()) + if (dtval.length() < 10) { return QVariant(QDateTime()); - else - return QVariant(QDateTime::fromString(dtval, Qt::ISODate)); + } else { + QChar sign = dtval[dtval.size() - 3]; + if (sign == QLatin1Char('-') || sign == QLatin1Char('+')) dtval += QLatin1String(":00"); + return QVariant(QDateTime::fromString(dtval, Qt::ISODate).toLocalTime()); + } #else return QVariant(dtval); #endif @@ -536,6 +527,11 @@ QSqlRecord QPSQLResult::record() const int precision = PQfmod(d->result, i); switch (ptype) { + case QTIMESTAMPOID: + case QTIMESTAMPTZOID: + precision = 3; + break; + case QNUMERICOID: if (precision != -1) { len = (precision >> 16); @@ -1263,15 +1259,10 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const case QVariant::DateTime: #ifndef QT_NO_DATESTRING if (field.value().toDateTime().isValid()) { - QDate dt = field.value().toDateTime().date(); - QTime tm = field.value().toDateTime().time(); - // msecs need to be right aligned otherwise psql interprets them wrong - r = QLatin1Char('\'') + QString::number(dt.year()) + QLatin1Char('-') - + QString::number(dt.month()).rightJustified(2, QLatin1Char('0')) + QLatin1Char('-') - + QString::number(dt.day()).rightJustified(2, QLatin1Char('0')) + QLatin1Char(' ') - + tm.toString() + QLatin1Char('.') - + QString::number(tm.msec()).rightJustified(3, QLatin1Char('0')) - + QLatin1Char('\''); + // we force the value to be considered with a timezone information, and we force it to be UTC + // this is safe since postgresql stores only the UTC value and not the timezone offset (only used + // while parsing), so we have correct behavior in both case of with timezone and without tz + r = QLatin1String("TIMESTAMP WITH TIME ZONE ") + QLatin1Char('\'') + field.value().toDateTime().toUTC().toString(QLatin1String("yyyy-MM-ddThh:mm:ss.zzz")) + QLatin1Char('Z') + QLatin1Char('\''); } else { r = QLatin1String("NULL"); } -- cgit v1.2.3 From a44749855e381a6f856b7b89ecd42aadcc2797bf Mon Sep 17 00:00:00 2001 From: Maximilian Hrabowski Date: Sat, 11 Oct 2014 13:44:28 +0200 Subject: QODBC: fix converted string values empty SQLServer 2012 SQL Server 2012 Native Client (version 11.0.2100.60) or later introduced a change in the behavior of the SQLGetData method when converted string values are involved. In older version a (sometimes wrong) size was returned. Now always SQL_NO_TOTAL is returned which signals to read as much data as available. SQL_NO_TOTAL was handled like SQL_NULL_DATA in the code before which indicates a NULL value so the returned string was empty. See link for more info: http://msdn.microsoft.com/en-us/library/jj219209.aspx Change-Id: Ia0d2296caf593890b301ee1848d1bf3eb8d7b6fe Reviewed-by: Mark Brand --- src/sql/drivers/odbc/qsql_odbc.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index f95fb8868e..2b14809943 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -373,10 +373,20 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni colSize*sizeof(SQLTCHAR), &lengthIndicator); if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) { - if (lengthIndicator == SQL_NULL_DATA || lengthIndicator == SQL_NO_TOTAL) { + if (lengthIndicator == SQL_NULL_DATA) { fieldVal.clear(); break; } + // starting with ODBC Native Client 2012, SQL_NO_TOTAL is returned + // instead of the length (which sometimes was wrong in older versions) + // see link for more info: http://msdn.microsoft.com/en-us/library/jj219209.aspx + // if length indicator equals SQL_NO_TOTAL, indicating that + // more data can be fetched, but size not known, collect data + // and fetch next block + if (lengthIndicator == SQL_NO_TOTAL) { + fieldVal += fromSQLTCHAR(buf, colSize); + continue; + } // if SQL_SUCCESS_WITH_INFO is returned, indicating that // more data can be fetched, the length indicator does NOT // contain the number of bytes returned - it contains the -- cgit v1.2.3 From b60773934dc0231b53e1fde3e5927d969bbf6298 Mon Sep 17 00:00:00 2001 From: Israel Lins Date: Mon, 15 Dec 2014 12:24:42 -0300 Subject: [QDateTime] ISO Time zone designators can be [+-]HH Added support on QDateTime::fromString to read correctly dates on ISO format with Time zone designators at format [+-]HH Change-Id: Ied5c3b7950aee3d0879af0e05398081395c18df5 Reviewed-by: Thiago Macieira Reviewed-by: Mark Brand --- src/corelib/tools/qdatetime.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index f0f6a56755..021eb5ae5d 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -248,7 +248,7 @@ static QString toOffsetString(Qt::DateFormat format, int offset) .arg((qAbs(offset) / 60) % 60, 2, 10, QLatin1Char('0')); } -// Parse offset in [+-]HH[:]MM format +// Parse offset in [+-]HH[[:]MM] format static int fromOffsetString(const QString &offsetString, bool *valid) { *valid = false; @@ -272,7 +272,7 @@ static int fromOffsetString(const QString &offsetString, bool *valid) // Split the hour and minute parts QStringList parts = offsetString.mid(1).split(QLatin1Char(':')); if (parts.count() == 1) { - // [+-]HHMM format + // [+-]HHMM or [+-]HH format parts.append(parts.at(0).mid(2)); parts[0] = parts.at(0).left(2); } @@ -282,7 +282,7 @@ static int fromOffsetString(const QString &offsetString, bool *valid) if (!ok) return 0; - const int minute = parts.at(1).toInt(&ok); + const int minute = (parts.at(1).isEmpty()) ? 0 : parts.at(1).toInt(&ok); if (!ok || minute < 0 || minute > 59) return 0; @@ -4428,8 +4428,7 @@ QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format) } else { // the loop below is faster but functionally equal to: // const int signIndex = isoString.indexOf(QRegExp(QStringLiteral("[+-]"))); - const int sizeOfTimeZoneString = 4; - int signIndex = isoString.size() - sizeOfTimeZoneString - 1; + int signIndex = isoString.size() - 1; bool found = false; { const QChar plus = QLatin1Char('+'); -- cgit v1.2.3 From 86ca4de8a257611d5811a1cbf9c8b5c9336188e9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 2 Jan 2015 11:20:59 -0200 Subject: Doc: fix the type listed for the functions in QAtomicInteger The "int" was a left over when this was documentation for QAtomicInt. Change-Id: If7b7688982d27cbbd42f080eff7d08344b587f44 Reviewed-by: Richard J. Moore --- src/corelib/thread/qatomic.cpp | 86 ++++++++++++++++++------------------- src/corelib/thread/qatomic.h | 96 +++++++++++++++++++++--------------------- 2 files changed, 91 insertions(+), 91 deletions(-) (limited to 'src') diff --git a/src/corelib/thread/qatomic.cpp b/src/corelib/thread/qatomic.cpp index 2ac32d5d6b..0f4c8efb03 100644 --- a/src/corelib/thread/qatomic.cpp +++ b/src/corelib/thread/qatomic.cpp @@ -250,7 +250,7 @@ /*! - \fn int QAtomicInteger::load() const + \fn T QAtomicInteger::load() const Atomically loads the value of this QAtomicInteger using relaxed memory ordering. The value is not modified in any way, but note that there's no @@ -260,7 +260,7 @@ */ /*! - \fn int QAtomicInteger::loadAcquire() const + \fn T QAtomicInteger::loadAcquire() const Atomically loads the value of this QAtomicInteger using the "Acquire" memory ordering. The value is not modified in any way, but note that there's no @@ -270,7 +270,7 @@ */ /*! - \fn void QAtomicInteger::store(int newValue) + \fn void QAtomicInteger::store(T newValue) Atomically stores the \a newValue value into this atomic type, using relaxed memory ordering. @@ -279,7 +279,7 @@ */ /*! - \fn void QAtomicInteger::storeRelease(int newValue) + \fn void QAtomicInteger::storeRelease(T newValue) Atomically stores the \a newValue value into this atomic type, using the "Release" memory ordering. @@ -288,7 +288,7 @@ */ /*! - \fn QAtomicInteger::operator int() const + \fn QAtomicInteger::operator T() const \since 5.3 Atomically loads the value of this QAtomicInteger using a sequentially @@ -300,7 +300,7 @@ */ /*! - \fn QAtomicInteger &QAtomicInteger::operator=(int newValue) + \fn QAtomicInteger &QAtomicInteger::operator=(T newValue) \since 5.3 Atomically stores the \a newValue value into this atomic type using a @@ -335,7 +335,7 @@ */ /*! - \fn int QAtomicInteger::operator++() + \fn T QAtomicInteger::operator++() \since 5.3 Atomically pre-increments the value of this QAtomicInteger. Returns the new @@ -348,7 +348,7 @@ */ /*! - \fn int QAtomicInteger::operator++(int) + \fn T QAtomicInteger::operator++(int) \since 5.3 Atomically post-increments the value of this QAtomicInteger. Returns the old @@ -373,7 +373,7 @@ */ /*! - \fn int QAtomicInteger::operator--() + \fn T QAtomicInteger::operator--() \since 5.3 Atomically pre-decrements the value of this QAtomicInteger. Returns the new @@ -386,7 +386,7 @@ */ /*! - \fn int QAtomicInteger::operator--(int) + \fn T QAtomicInteger::operator--(int) \since 5.3 Atomically post-decrements the value of this QAtomicInteger. Returns the old @@ -409,7 +409,7 @@ Returns \c true if atomic test-and-set is wait-free, false otherwise. */ -/*! \fn bool QAtomicInteger::testAndSetRelaxed(int expectedValue, int newValue) +/*! \fn bool QAtomicInteger::testAndSetRelaxed(T expectedValue, T newValue) Atomic test-and-set. @@ -423,7 +423,7 @@ processor to freely reorder memory accesses. */ -/*! \fn bool QAtomicInteger::testAndSetAcquire(int expectedValue, int newValue) +/*! \fn bool QAtomicInteger::testAndSetAcquire(T expectedValue, T newValue) Atomic test-and-set. @@ -438,7 +438,7 @@ be re-ordered before the atomic operation. */ -/*! \fn bool QAtomicInteger::testAndSetRelease(int expectedValue, int newValue) +/*! \fn bool QAtomicInteger::testAndSetRelease(T expectedValue, T newValue) Atomic test-and-set. @@ -453,7 +453,7 @@ re-ordered after the atomic operation. */ -/*! \fn bool QAtomicInteger::testAndSetOrdered(int expectedValue, int newValue) +/*! \fn bool QAtomicInteger::testAndSetOrdered(T expectedValue, T newValue) Atomic test-and-set. @@ -480,7 +480,7 @@ otherwise. */ -/*! \fn int QAtomicInteger::fetchAndStoreRelaxed(int newValue) +/*! \fn T QAtomicInteger::fetchAndStoreRelaxed(T newValue) Atomic fetch-and-store. @@ -492,7 +492,7 @@ processor to freely reorder memory accesses. */ -/*! \fn int QAtomicInteger::fetchAndStoreAcquire(int newValue) +/*! \fn T QAtomicInteger::fetchAndStoreAcquire(T newValue) Atomic fetch-and-store. @@ -505,7 +505,7 @@ be re-ordered before the atomic operation. */ -/*! \fn int QAtomicInteger::fetchAndStoreRelease(int newValue) +/*! \fn T QAtomicInteger::fetchAndStoreRelease(T newValue) Atomic fetch-and-store. @@ -518,7 +518,7 @@ re-ordered after the atomic operation. */ -/*! \fn int QAtomicInteger::fetchAndStoreOrdered(int newValue) +/*! \fn T QAtomicInteger::fetchAndStoreOrdered(T newValue) Atomic fetch-and-store. @@ -543,7 +543,7 @@ otherwise. */ -/*! \fn int QAtomicInteger::fetchAndAddRelaxed(int valueToAdd) +/*! \fn T QAtomicInteger::fetchAndAddRelaxed(T valueToAdd) Atomic fetch-and-add. @@ -557,7 +557,7 @@ \sa operator+=(), fetchAndSubRelaxed() */ -/*! \fn int QAtomicInteger::fetchAndAddAcquire(int valueToAdd) +/*! \fn T QAtomicInteger::fetchAndAddAcquire(T valueToAdd) Atomic fetch-and-add. @@ -572,7 +572,7 @@ \sa operator+=(), fetchAndSubAcquire() */ -/*! \fn int QAtomicInteger::fetchAndAddRelease(int valueToAdd) +/*! \fn T QAtomicInteger::fetchAndAddRelease(T valueToAdd) Atomic fetch-and-add. @@ -587,7 +587,7 @@ \sa operator+=(), fetchAndSubRelease() */ -/*! \fn int QAtomicInteger::fetchAndAddOrdered(int valueToAdd) +/*! \fn T QAtomicInteger::fetchAndAddOrdered(T valueToAdd) Atomic fetch-and-add. @@ -602,7 +602,7 @@ \sa operator+=(), fetchAndSubOrdered() */ -/*! \fn int QAtomicInteger::operator+=(int valueToAdd) +/*! \fn T QAtomicInteger::operator+=(T valueToAdd) \since 5.3 Atomic add-and-fetch. @@ -616,7 +616,7 @@ \sa fetchAndAddOrdered(), operator-=() */ -/*! \fn int QAtomicInteger::fetchAndSubRelaxed(int valueToSub) +/*! \fn T QAtomicInteger::fetchAndSubRelaxed(T valueToSub) \since 5.3 Atomic fetch-and-sub. @@ -631,7 +631,7 @@ \sa operator-=(), fetchAndAddRelaxed() */ -/*! \fn int QAtomicInteger::fetchAndSubAcquire(int valueToSub) +/*! \fn T QAtomicInteger::fetchAndSubAcquire(T valueToSub) \since 5.3 Atomic fetch-and-sub. @@ -647,7 +647,7 @@ \sa operator-=(), fetchAndAddAcquire() */ -/*! \fn int QAtomicInteger::fetchAndSubRelease(int valueToSub) +/*! \fn T QAtomicInteger::fetchAndSubRelease(T valueToSub) \since 5.3 Atomic fetch-and-sub. @@ -663,7 +663,7 @@ \sa operator-=(), fetchAndAddRelease() */ -/*! \fn int QAtomicInteger::fetchAndSubOrdered(int valueToSub) +/*! \fn T QAtomicInteger::fetchAndSubOrdered(T valueToSub) \since 5.3 Atomic fetch-and-sub. @@ -679,7 +679,7 @@ \sa operator-=(), fetchAndAddOrdered() */ -/*! \fn int QAtomicInteger::operator-=(int valueToSub) +/*! \fn T QAtomicInteger::operator-=(T valueToSub) \since 5.3 Atomic sub-and-fetch. @@ -693,7 +693,7 @@ \sa fetchAndSubOrdered(), operator+=() */ -/*! \fn int QAtomicInteger::fetchAndOrRelaxed(int valueToOr) +/*! \fn T QAtomicInteger::fetchAndOrRelaxed(T valueToOr) \since 5.3 Atomic fetch-and-or. @@ -708,7 +708,7 @@ \sa operator|=() */ -/*! \fn int QAtomicInteger::fetchAndOrAcquire(int valueToOr) +/*! \fn T QAtomicInteger::fetchAndOrAcquire(T valueToOr) \since 5.3 Atomic fetch-and-or. @@ -724,7 +724,7 @@ \sa operator|=() */ -/*! \fn int QAtomicInteger::fetchAndOrRelease(int valueToOr) +/*! \fn T QAtomicInteger::fetchAndOrRelease(T valueToOr) \since 5.3 Atomic fetch-and-or. @@ -740,7 +740,7 @@ \sa operator|=() */ -/*! \fn int QAtomicInteger::fetchAndOrOrdered(int valueToOr) +/*! \fn T QAtomicInteger::fetchAndOrOrdered(T valueToOr) \since 5.3 Atomic fetch-and-or. @@ -756,7 +756,7 @@ \sa operator|=() */ -/*! \fn int QAtomicInteger::operator|=(int valueToOr) +/*! \fn T QAtomicInteger::operator|=(T valueToOr) \since 5.3 Atomic or-and-fetch. @@ -770,7 +770,7 @@ \sa fetchAndOrOrdered() */ -/*! \fn int QAtomicInteger::fetchAndXorRelaxed(int valueToXor) +/*! \fn T QAtomicInteger::fetchAndXorRelaxed(T valueToXor) \since 5.3 Atomic fetch-and-xor. @@ -785,7 +785,7 @@ \sa operator^=() */ -/*! \fn int QAtomicInteger::fetchAndXorAcquire(int valueToXor) +/*! \fn T QAtomicInteger::fetchAndXorAcquire(T valueToXor) \since 5.3 Atomic fetch-and-xor. @@ -801,7 +801,7 @@ \sa operator^=() */ -/*! \fn int QAtomicInteger::fetchAndXorRelease(int valueToXor) +/*! \fn T QAtomicInteger::fetchAndXorRelease(T valueToXor) \since 5.3 Atomic fetch-and-xor. @@ -817,7 +817,7 @@ \sa operator^=() */ -/*! \fn int QAtomicInteger::fetchAndXorOrdered(int valueToXor) +/*! \fn T QAtomicInteger::fetchAndXorOrdered(T valueToXor) \since 5.3 Atomic fetch-and-xor. @@ -833,7 +833,7 @@ \sa operator^=() */ -/*! \fn int QAtomicInteger::operator^=(int valueToXor) +/*! \fn T QAtomicInteger::operator^=(T valueToXor) \since 5.3 Atomic xor-and-fetch. @@ -847,7 +847,7 @@ \sa fetchAndXorOrdered() */ -/*! \fn int QAtomicInteger::fetchAndAndRelaxed(int valueToAnd) +/*! \fn T QAtomicInteger::fetchAndAndRelaxed(T valueToAnd) \since 5.3 Atomic fetch-and-and. @@ -862,7 +862,7 @@ \sa operator&=() */ -/*! \fn int QAtomicInteger::fetchAndAndAcquire(int valueToAnd) +/*! \fn T QAtomicInteger::fetchAndAndAcquire(T valueToAnd) \since 5.3 Atomic fetch-and-and. @@ -878,7 +878,7 @@ \sa operator&=() */ -/*! \fn int QAtomicInteger::fetchAndAndRelease(int valueToAnd) +/*! \fn T QAtomicInteger::fetchAndAndRelease(T valueToAnd) \since 5.3 Atomic fetch-and-and. @@ -894,7 +894,7 @@ \sa operator&=() */ -/*! \fn int QAtomicInteger::fetchAndAndOrdered(int valueToAnd) +/*! \fn T QAtomicInteger::fetchAndAndOrdered(T valueToAnd) \since 5.3 Atomic fetch-and-and. @@ -910,7 +910,7 @@ \sa operator&=() */ -/*! \fn int QAtomicInteger::operator&=(int valueToAnd) +/*! \fn T QAtomicInteger::operator&=(T valueToAnd) \since 5.3 Atomic add-and-fetch. diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h index 7526cfe0e6..72cb3866a5 100644 --- a/src/corelib/thread/qatomic.h +++ b/src/corelib/thread/qatomic.h @@ -76,13 +76,13 @@ public: } #ifdef Q_QDOC - int load() const; - int loadAcquire() const; - void store(int newValue); - void storeRelease(int newValue); + T load() const; + T loadAcquire() const; + void store(T newValue); + void storeRelease(T newValue); - operator int() const; - QAtomicInteger &operator=(int); + operator T() const; + QAtomicInteger &operator=(T); static Q_DECL_CONSTEXPR bool isReferenceCountingNative(); static Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree(); @@ -93,56 +93,56 @@ public: static Q_DECL_CONSTEXPR bool isTestAndSetNative(); static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree(); - bool testAndSetRelaxed(int expectedValue, int newValue); - bool testAndSetAcquire(int expectedValue, int newValue); - bool testAndSetRelease(int expectedValue, int newValue); - bool testAndSetOrdered(int expectedValue, int newValue); + bool testAndSetRelaxed(T expectedValue, T newValue); + bool testAndSetAcquire(T expectedValue, T newValue); + bool testAndSetRelease(T expectedValue, T newValue); + bool testAndSetOrdered(T expectedValue, T newValue); static Q_DECL_CONSTEXPR bool isFetchAndStoreNative(); static Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree(); - int fetchAndStoreRelaxed(int newValue); - int fetchAndStoreAcquire(int newValue); - int fetchAndStoreRelease(int newValue); - int fetchAndStoreOrdered(int newValue); + T fetchAndStoreRelaxed(T newValue); + T fetchAndStoreAcquire(T newValue); + T fetchAndStoreRelease(T newValue); + T fetchAndStoreOrdered(T newValue); static Q_DECL_CONSTEXPR bool isFetchAndAddNative(); static Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree(); - int fetchAndAddRelaxed(int valueToAdd); - int fetchAndAddAcquire(int valueToAdd); - int fetchAndAddRelease(int valueToAdd); - int fetchAndAddOrdered(int valueToAdd); - - int fetchAndSubRelaxed(int valueToSub); - int fetchAndSubAcquire(int valueToSub); - int fetchAndSubRelease(int valueToSub); - int fetchAndSubOrdered(int valueToSub); - - int fetchAndOrRelaxed(int valueToOr); - int fetchAndOrAcquire(int valueToOr); - int fetchAndOrRelease(int valueToOr); - int fetchAndOrOrdered(int valueToOr); - - int fetchAndAndRelaxed(int valueToAnd); - int fetchAndAndAcquire(int valueToAnd); - int fetchAndAndRelease(int valueToAnd); - int fetchAndAndOrdered(int valueToAnd); - - int fetchAndXorRelaxed(int valueToXor); - int fetchAndXorAcquire(int valueToXor); - int fetchAndXorRelease(int valueToXor); - int fetchAndXorOrdered(int valueToXor); - - int operator++(); - int operator++(int); - int operator--(); - int operator--(int); - int operator+=(int value); - int operator-=(int value); - int operator|=(int value); - int operator&=(int value); - int operator^=(int value); + T fetchAndAddRelaxed(T valueToAdd); + T fetchAndAddAcquire(T valueToAdd); + T fetchAndAddRelease(T valueToAdd); + T fetchAndAddOrdered(T valueToAdd); + + T fetchAndSubRelaxed(T valueToSub); + T fetchAndSubAcquire(T valueToSub); + T fetchAndSubRelease(T valueToSub); + T fetchAndSubOrdered(T valueToSub); + + T fetchAndOrRelaxed(T valueToOr); + T fetchAndOrAcquire(T valueToOr); + T fetchAndOrRelease(T valueToOr); + T fetchAndOrOrdered(T valueToOr); + + T fetchAndAndRelaxed(T valueToAnd); + T fetchAndAndAcquire(T valueToAnd); + T fetchAndAndRelease(T valueToAnd); + T fetchAndAndOrdered(T valueToAnd); + + T fetchAndXorRelaxed(T valueToXor); + T fetchAndXorAcquire(T valueToXor); + T fetchAndXorRelease(T valueToXor); + T fetchAndXorOrdered(T valueToXor); + + T operator++(); + T operator++(int); + T operator--(); + T operator--(int); + T operator+=(T value); + T operator-=(T value); + T operator|=(T value); + T operator&=(T value); + T operator^=(T value); #endif }; -- cgit v1.2.3 From 350c60b79e720d005a1a554fd177dbda607079cf Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Tue, 30 Dec 2014 19:26:09 +0200 Subject: Link against QMAKE_LIBS_EXECINFO when using backtrace(3). Add a new mkspec variable, QMAKE_LIBS_EXECINFO, for platforms where backtrace(3), backtrace_symbols(3) and others are not in libc, but rather in a separate library -- on the BSDs, this is libexecinfo. Use it in corelib/global/global.pri so that libqt5core links against it and has the proper dependency when necessary. Change-Id: I62ac36c9b3ba7ab0719420cb795087d43ec138a4 Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira --- src/corelib/global/global.pri | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index fb0e7fd708..e0dd9e4f36 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -35,6 +35,9 @@ INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global # Only used on platforms with CONFIG += precompile_header PRECOMPILED_HEADER = global/qt_pch.h +# qlogging.cpp uses backtrace(3), which is in a separate library on the BSDs. +LIBS_PRIVATE += $$QMAKE_LIBS_EXECINFO + linux*:!cross_compile:!static:!*-armcc* { QMAKE_LFLAGS += -Wl,-e,qt_core_boilerplate prog=$$quote(if (/program interpreter: (.*)]/) { print $1; }) -- cgit v1.2.3 From d7fa2d060a58b0e79d7df84a4fc54f44de9b2610 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 16 Oct 2014 20:52:44 +0200 Subject: Fix a memleak in QAssociativeIterable::value() QtMetaTypePrivate::QAssociativeIterableImpl::{find,begin,end}() allocate a new _iterator, so when they're used outside of the ref-counted world of QAssociativeIterable::const_iterator, their lifetime needs to be manually managed. Instead of going to that length, which failed in previous iterations of this patch, implement value() in terms of (new) find() and let find() operate on const_iterator. Because of forwards compatibility between patch releases, use (unexported) friend functions for now with the intention to make them proper member functions come Qt 5.5. Task-number: QTBUG-41469 Change-Id: I43b21eae0c2fc4c182369e669a8b3b457be68885 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.cpp | 49 +++++++++++++++++++++++++++-------------- src/corelib/kernel/qvariant.h | 6 +++++ 2 files changed, 39 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 2ac1bb11fb..f76201802b 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3844,6 +3844,13 @@ void QAssociativeIterable::const_iterator::end() m_impl.end(); } +void find(QAssociativeIterable::const_iterator &it, const QVariant &key) +{ + Q_ASSERT(key.userType() == it.m_impl._metaType_id_key); + const QtMetaTypePrivate::VariantData dkey(key.userType(), key.constData(), 0 /*key.flags()*/); + it.m_impl.find(dkey); +} + /*! Returns a QAssociativeIterable::const_iterator for the beginning of the container. This can be used in stl-style iteration. @@ -3870,28 +3877,38 @@ QAssociativeIterable::const_iterator QAssociativeIterable::end() const return it; } +/*! + \internal + + Returns a QAssociativeIterable::const_iterator for the given key \a key + in the container, if the types are convertible. + + If the key is not found, returns end(). + + This can be used in stl-style iteration. + + \sa begin(), end(), value() +*/ +QAssociativeIterable::const_iterator find(const QAssociativeIterable &iterable, const QVariant &key) +{ + QAssociativeIterable::const_iterator it(iterable, new QAtomicInt(0)); + QVariant key_ = key; + if (key_.canConvert(iterable.m_impl._metaType_id_key) && key_.convert(iterable.m_impl._metaType_id_key)) + find(it, key_); + else + it.end(); + return it; +} + /*! Returns the value for the given \a key in the container, if the types are convertible. */ QVariant QAssociativeIterable::value(const QVariant &key) const { - QVariant key_ = key; - if (!key_.canConvert(m_impl._metaType_id_key)) - return QVariant(); - if (!key_.convert(m_impl._metaType_id_key)) + const const_iterator it = find(*this, key); + if (it == end()) return QVariant(); - const QtMetaTypePrivate::VariantData dkey(key_.userType(), key_.constData(), 0 /*key.flags()*/); - QtMetaTypePrivate::QAssociativeIterableImpl impl = m_impl; - impl.find(dkey); - QtMetaTypePrivate::QAssociativeIterableImpl endIt = m_impl; - endIt.end(); - if (impl.equal(endIt)) - return QVariant(); - const QtMetaTypePrivate::VariantData d = impl.getCurrentValue(); - QVariant v(d.metaTypeId, d.data, d.flags); - if (d.metaTypeId == qMetaTypeId()) - return *reinterpret_cast(d.data); - return v; + return *it; } /*! diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 7dce813bb5..90f3e8fbae 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -633,6 +633,9 @@ public: void begin(); void end(); + // ### Qt 5.5: make find() (1st one) a member function + friend void find(const_iterator &it, const QVariant &key); + friend const_iterator find(const QAssociativeIterable &iterable, const QVariant &key); public: ~const_iterator(); const_iterator(const const_iterator &other); @@ -662,6 +665,9 @@ public: const_iterator begin() const; const_iterator end() const; +private: // ### Qt 5.5: make it a public find() member function: + friend const_iterator find(const QAssociativeIterable &iterable, const QVariant &key); +public: QVariant value(const QVariant &key) const; -- cgit v1.2.3 From 38a3158d2fe32dc55c6b6286fac58f782571294a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Fri, 12 Dec 2014 12:33:04 +0000 Subject: Windows: Fix QColorDialog's live updates while picking outside color Microsoft's SetCapture() doesn't work on windows owned by other processes, so instead we use a timer. This is the same approach as used by qttools/src/pixeltool. The mouse move approach however is more elegant and doesn't hammer the CPU with QCursor::pos() calls when idle. For this reason the workaround is Q_OS_WIN only. Task-number: QTBUG-34538 Change-Id: I40a6f7df5bf2a3a29ade8fe4a92f5b5c4ece7efb Reviewed-by: Friedemann Kleint --- src/widgets/dialogs/qcolordialog.cpp | 40 ++++++++++++++++++++++++++++++++---- src/widgets/dialogs/qcolordialog.h | 1 + src/widgets/dialogs/qcolordialog_p.h | 12 ++++++++++- 3 files changed, 48 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index f04e5b9ea6..882bb999fb 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -57,6 +57,7 @@ #include "qdialogbuttonbox.h" #include "qscreen.h" #include "qcursor.h" +#include "qtimer.h" #include @@ -1577,6 +1578,11 @@ void QColorDialogPrivate::_q_pickScreenColor() #else q->grabMouse(); #endif + +#ifdef Q_OS_WIN + // On Windows mouse tracking doesn't work over other processes's windows + updateTimer->start(30); +#endif q->grabKeyboard(); /* With setMouseTracking(true) the desired color can be more precisedly picked up, * and continuously pushing the mouse button is not necessary. @@ -1600,6 +1606,9 @@ void QColorDialogPrivate::releaseColorPicking() cp->setCrossVisible(true); q->removeEventFilter(colorPickingEventFilter); q->releaseMouse(); +#ifdef Q_OS_WIN + updateTimer->stop(); +#endif q->releaseKeyboard(); q->setMouseTracking(false); lblScreenColorInfo->setText(QLatin1String("\n")); @@ -1782,6 +1791,10 @@ void QColorDialogPrivate::initWidgets() cancel = buttons->addButton(QDialogButtonBox::Cancel); QObject::connect(cancel, SIGNAL(clicked()), q, SLOT(reject())); +#ifdef Q_OS_WIN + updateTimer = new QTimer(q); + QObject::connect(updateTimer, SIGNAL(timeout()), q, SLOT(_q_updateColorPicking())); +#endif retranslateStrings(); } @@ -2196,18 +2209,37 @@ void QColorDialog::changeEvent(QEvent *e) QDialog::changeEvent(e); } -bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e) +void QColorDialogPrivate::_q_updateColorPicking() { - // If the cross is visible the grabbed color will be black most of the times - cp->setCrossVisible(!cp->geometry().contains(e->pos())); +#ifndef QT_NO_CURSOR + Q_Q(QColorDialog); + static QPoint lastGlobalPos; + QPoint newGlobalPos = QCursor::pos(); + if (lastGlobalPos == newGlobalPos) + return; + lastGlobalPos = newGlobalPos; - const QPoint globalPos = e->globalPos(); + if (!q->rect().contains(q->mapFromGlobal(newGlobalPos))) // Inside the dialog mouse tracking works, handleColorPickingMouseMove will be called + updateColorPicking(newGlobalPos); +#endif // ! QT_NO_CURSOR +} + +void QColorDialogPrivate::updateColorPicking(const QPoint &globalPos) +{ const QColor color = grabScreenColor(globalPos); // QTBUG-39792, do not change standard, custom color selectors while moving as // otherwise it is not possible to pre-select a custom cell for assignment. setCurrentColor(color, ShowColor); lblScreenColorInfo->setText(QColorDialog::tr("Cursor at %1, %2, color: %3\nPress ESC to cancel") .arg(globalPos.x()).arg(globalPos.y()).arg(color.name())); +} + +bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e) +{ + // If the cross is visible the grabbed color will be black most of the times + cp->setCrossVisible(!cp->geometry().contains(e->pos())); + + updateColorPicking(e->globalPos()); return true; } diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h index d23254a2b2..b06da2ab13 100644 --- a/src/widgets/dialogs/qcolordialog.h +++ b/src/widgets/dialogs/qcolordialog.h @@ -116,6 +116,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_newCustom(int, int)) Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int)) Q_PRIVATE_SLOT(d_func(), void _q_pickScreenColor()) + Q_PRIVATE_SLOT(d_func(), void _q_updateColorPicking()) friend class QColorShower; }; diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h index af3ebe8925..2b501522f5 100644 --- a/src/widgets/dialogs/qcolordialog_p.h +++ b/src/widgets/dialogs/qcolordialog_p.h @@ -63,6 +63,7 @@ class QVBoxLayout; class QPushButton; class QWellArray; class QColorPickingEventFilter; +class QTimer; class QColorDialogPrivate : public QDialogPrivate { @@ -75,7 +76,11 @@ public: SetColorAll = ShowColor | SelectColor }; - QColorDialogPrivate() : options(new QColorDialogOptions) {} + QColorDialogPrivate() : options(new QColorDialogOptions) +#ifdef Q_OS_WIN + , updateTimer(0) +#endif + {} QPlatformColorDialogHelper *platformColorDialogHelper() const { return static_cast(platformHelper()); } @@ -104,6 +109,8 @@ public: void _q_newCustom(int, int); void _q_newStandard(int, int); void _q_pickScreenColor(); + void _q_updateColorPicking(); + void updateColorPicking(const QPoint &pos); void releaseColorPicking(); bool handleColorPickingMouseMove(QMouseEvent *e); bool handleColorPickingMouseButtonRelease(QMouseEvent *e); @@ -136,6 +143,9 @@ public: QPointer receiverToDisconnectOnClose; QByteArray memberToDisconnectOnClose; +#ifdef Q_OS_WIN + QTimer *updateTimer; +#endif #ifdef Q_WS_MAC void openCocoaColorPanel(const QColor &initial, -- cgit v1.2.3 From 16c32c6dfbca03a46d1a2bb87b6c1c365e6179d5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Sat, 27 Dec 2014 20:36:37 +0100 Subject: JPEG: Fix reading of EXIF orientation. The orientation is unsigned short, read it as such. In JPEG-files created by Ricoh/Pentax cameras, the data is saved in Motorola format. Reading the wrong data size will produce invalid values when converting the byte order. Change-Id: I8f7c5dc5bfc10c02e090d3654aaefa047229a962 Task-number: QTBUG-43563 Reviewed-by: Friedemann Kleint --- src/gui/image/qjpeghandler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp index 87992bcced..9cf9947b6c 100644 --- a/src/gui/image/qjpeghandler.cpp +++ b/src/gui/image/qjpeghandler.cpp @@ -826,10 +826,10 @@ static int getExifOrientation(QByteArray &exifData) quint16 tag; quint16 type; quint32 components; - quint32 value; - - stream >> tag >> type >> components >> value; + quint16 value; + quint16 dummy; + stream >> tag >> type >> components >> value >> dummy; if (tag == 0x0112) { // Tag Exif.Image.Orientation if (components !=1) return -1; -- cgit v1.2.3 From f3e9f11265bc6715d4d1c6e2d734fad923b10d05 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 2 Jan 2015 17:45:09 -0200 Subject: Fix change-of-sign warnings with ICC qlocale_p.h(427): error #68: integer conversion resulted in a change of sign We hadn't enabled Q_COMPILER_CONSTEXPR for ICC. Change-Id: Ie7e3070b9f8f2cf512d2745001312865e698596b Reviewed-by: Olivier Goffart Reviewed-by: Marc Mutz --- src/corelib/tools/qlocale_p.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index c5e62027c4..4e3022478a 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -418,9 +418,9 @@ Q_STATIC_ASSERT(!ascii_isspace('\0')); Q_STATIC_ASSERT(!ascii_isspace('\a')); Q_STATIC_ASSERT(!ascii_isspace('a')); Q_STATIC_ASSERT(!ascii_isspace('\177')); -Q_STATIC_ASSERT(!ascii_isspace('\200')); -Q_STATIC_ASSERT(!ascii_isspace('\xA0')); -Q_STATIC_ASSERT(!ascii_isspace('\377')); +Q_STATIC_ASSERT(!ascii_isspace(uchar('\200'))); +Q_STATIC_ASSERT(!ascii_isspace(uchar('\xA0'))); +Q_STATIC_ASSERT(!ascii_isspace(uchar('\377'))); #endif QT_END_NAMESPACE -- cgit v1.2.3 From 01fc82e3574614762d2ce061dd45ce4995c79e7f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 2 Jan 2015 17:45:30 -0200 Subject: Re-enable constexpr for ICC 15 The bug noted in d88e4edcd548e5bb024e75016c5a3449d103bd8d appears to be resolved. Change-Id: Id20906ff83f74bd16267d44bf447626b81187e71 Reviewed-by: Olivier Goffart Reviewed-by: Marc Mutz --- src/corelib/global/qcompilerdetection.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 5f8ca5c7cc..36ba57a0ff 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -553,6 +553,7 @@ # define Q_COMPILER_UNRESTRICTED_UNIONS # endif # if __INTEL_COMPILER >= 1500 +# define Q_COMPILER_CONSTEXPR # define Q_COMPILER_ALIGNAS # define Q_COMPILER_ALIGNOF # define Q_COMPILER_INHERITING_CONSTRUCTORS -- cgit v1.2.3 From 624ee454ec58074c1156b8a82f48ba83279c44fa Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 11 Dec 2014 13:58:52 -0800 Subject: Make QDBusConnection and QDBusServer return an error on default objects The error of "Not connected". This incidentally solves a crash when QDBusServer().lastError() is called but libdbus-1 couldn't be found. Change-Id: Id93f447d00c0aa6660d4528c4bbce5998d9186a8 Reviewed-by: Alex Blasche --- src/dbus/qdbusconnection.cpp | 2 +- src/dbus/qdbusserver.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 1a56f53a63..a46df16ac5 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -959,7 +959,7 @@ bool QDBusConnection::isConnected() const */ QDBusError QDBusConnection::lastError() const { - return d ? d->lastError : QDBusError(); + return d ? d->lastError : QDBusError(QDBusError::Disconnected, QStringLiteral("Not connected.")); } /*! diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp index 54b38ee848..b2c76a8750 100644 --- a/src/dbus/qdbusserver.cpp +++ b/src/dbus/qdbusserver.cpp @@ -129,7 +129,7 @@ bool QDBusServer::isConnected() const */ QDBusError QDBusServer::lastError() const { - return d->lastError; + return d ? d->lastError : QDBusError(QDBusError::Disconnected, QStringLiteral("Not connected.")); } /*! -- cgit v1.2.3 From 2bdcea9d31d07c32e085a5194873c735e519855d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 12 Dec 2014 15:20:58 +0100 Subject: iOS: Remove QIOSKeyboardListener self-change assert/guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We're fairly confident self won't change in that case, and the assert was causing warnings in release builds. Change-Id: I4a826579bb4cedef8423e8d43cb370e1f3b80407 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosinputcontext.mm | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index 76c02d939f..bbfc03667e 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -75,9 +75,7 @@ static QUIView *focusView() - (id)initWithQIOSInputContext:(QIOSInputContext *)context { - id originalSelf = self; if (self = [super initWithTarget:self action:@selector(gestureStateChanged:)]) { - Q_ASSERT(self == originalSelf); m_context = context; -- cgit v1.2.3 From 9d9b785259103ebed616bd59a3b3f2fd6cb95019 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 18 Dec 2014 15:59:23 -0800 Subject: Give ICC-as-Clang a Q_CC_CLANG version number too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Give it version number 3.5 for current compatibility. Change-Id: Ia023d29b3b3946f8642a0550279ae63cbb803fc5 Reviewed-by: Tor Arne Vestbø --- src/corelib/global/qcompilerdetection.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 36ba57a0ff..3f813e163b 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -145,6 +145,10 @@ # if defined(__INTEL_COMPILER) /* Intel C++ also masquerades as GCC */ # define Q_CC_INTEL (__INTEL_COMPILER) +# ifdef __clang__ +/* Intel C++ masquerades as Clang masquerading as GCC */ +# define Q_CC_CLANG 305 +# endif # define Q_ASSUME_IMPL(expr) __assume(expr) # define Q_UNREACHABLE_IMPL() __builtin_unreachable() # if __INTEL_COMPILER >= 1300 && !defined(__APPLE__) -- cgit v1.2.3 From acf80b9a2b913e898ed4c4ed14d4ea79401484fe Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 19 Dec 2014 12:04:03 -0800 Subject: Fix build error with Intel Compiler 15 on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the constructor is inline, the generated code needs access to the vtable, which gets emitted with the first virtual function (in QtGui), but somehow icl.exe can't find it in debug. Looking at the .obj files it generates and comparing to MSVC, it seems that: - both generate and export the inline constructor from Qt5Guid.dll - MSVC will call that constructor from qoffscreenintegration.obj - icl.exe will inline the constructor and requires a symbol not exported from Qt5Guid.dll I can't explain why (probably a compiler bug). Change-Id: I0ab9c078ae4fc794826025d68d364124c7247e80 Reviewed-by: Jørgen Lind --- src/gui/kernel/qplatformservices.cpp | 3 +++ src/gui/kernel/qplatformservices.h | 1 + 2 files changed, 4 insertions(+) (limited to 'src') diff --git a/src/gui/kernel/qplatformservices.cpp b/src/gui/kernel/qplatformservices.cpp index e11a1858f6..2188920c86 100644 --- a/src/gui/kernel/qplatformservices.cpp +++ b/src/gui/kernel/qplatformservices.cpp @@ -49,6 +49,9 @@ QT_BEGIN_NAMESPACE \brief The QPlatformServices provides the backend for desktop-related functionality. */ +QPlatformServices::QPlatformServices() +{ } + bool QPlatformServices::openUrl(const QUrl &url) { qWarning("This plugin does not support QPlatformServices::openUrl() for '%s'.", diff --git a/src/gui/kernel/qplatformservices.h b/src/gui/kernel/qplatformservices.h index 00a87d51f5..005748d18c 100644 --- a/src/gui/kernel/qplatformservices.h +++ b/src/gui/kernel/qplatformservices.h @@ -52,6 +52,7 @@ class QUrl; class Q_GUI_EXPORT QPlatformServices { public: + QPlatformServices(); virtual ~QPlatformServices() { } virtual bool openUrl(const QUrl &url); -- cgit v1.2.3 From a457bf3ff73627aa2c95f0482a838b14fd3233a0 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sat, 3 Jan 2015 19:06:38 +0200 Subject: Doc: Fixed date format doc bug in QDateTime/Qt namespace MM stands for month, SS is invalid mostly cherry picked from Qt4 commit 670f460fab6a386407c07281cf6417ccf6430970. Task-number: QTBUG-12236 Change-Id: I7af4be655d2d10f1befa1366abb48225c60d31dc Reviewed-by: Thiago Macieira --- src/corelib/global/qnamespace.qdoc | 2 +- src/corelib/tools/qdatetime.cpp | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 04055a3308..9e9a357272 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -592,7 +592,7 @@ string, "ddd MMM d yyyy". See QDate::toString() for more information. \value ISODate \l{ISO 8601} extended format: either \c{YYYY-MM-DD} for dates or - \c{YYYY-MM-DDTHH:MM:SS}, \c{YYYY-MM-DDTHH:MM:SSTZD} (e.g., 1997-07-16T19:20:30+01:00) + \c{YYYY-MM-DDTHH:mm:ss}, \c{YYYY-MM-DDTHH:mm:ssTZD} (e.g., 1997-07-16T19:20:30+01:00) for combined dates and times. \value SystemLocaleShortDate The \l{QLocale::ShortFormat}{short format} used diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 021eb5ae5d..d52dea8d4f 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -182,7 +182,7 @@ static void rfcDateImpl(const QString &s, QDate *dd = 0, QTime *dt = 0, int *utc int minOffset = 0; bool positiveOffset = false; - // Matches "Wdy, DD Mon YYYY HH:MM:SS ±hhmm" (Wdy, being optional) + // Matches "Wdy, DD Mon YYYY HH:mm:ss ±hhmm" (Wdy, being optional) QRegExp rex(QStringLiteral("^(?:[A-Z][a-z]+,)?[ \\t]*(\\d{1,2})[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d)(?::(\\d\\d))?)?[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?")); if (s.indexOf(rex) == 0) { if (dd) { @@ -203,7 +203,7 @@ static void rfcDateImpl(const QString &s, QDate *dd = 0, QTime *dt = 0, int *utc if (utcOffset) *utcOffset = ((hourOffset * 60 + minOffset) * (positiveOffset ? 60 : -60)); } else { - // Matches "Wdy Mon DD HH:MM:SS YYYY" + // Matches "Wdy Mon DD HH:mm:ss YYYY" QRegExp rex(QStringLiteral("^[A-Z][a-z]+[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d):(\\d\\d))?[ \\t]+(\\d\\d\\d\\d)[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?")); if (s.indexOf(rex) == 0) { if (dd) { @@ -233,7 +233,7 @@ static void rfcDateImpl(const QString &s, QDate *dd = 0, QTime *dt = 0, int *utc } #endif // QT_NO_DATESTRING -// Return offset in [+-]HH:MM format +// Return offset in [+-]HH:mm format // Qt::ISODate puts : between the hours and minutes, but Qt:TextDate does not static QString toOffsetString(Qt::DateFormat format, int offset) { @@ -248,7 +248,7 @@ static QString toOffsetString(Qt::DateFormat format, int offset) .arg((qAbs(offset) / 60) % 60, 2, 10, QLatin1Char('0')); } -// Parse offset in [+-]HH[[:]MM] format +// Parse offset in [+-]HH[[:]mm] format static int fromOffsetString(const QString &offsetString, bool *valid) { *valid = false; @@ -272,7 +272,7 @@ static int fromOffsetString(const QString &offsetString, bool *valid) // Split the hour and minute parts QStringList parts = offsetString.mid(1).split(QLatin1Char(':')); if (parts.count() == 1) { - // [+-]HHMM or [+-]HH format + // [+-]HHmm or [+-]HH format parts.append(parts.at(0).mid(2)); parts[0] = parts.at(0).left(2); } @@ -1598,12 +1598,12 @@ int QTime::msec() const Returns the time as a string. The \a format parameter determines the format of the string. - If \a format is Qt::TextDate, the string format is HH:MM:SS; + If \a format is Qt::TextDate, the string format is HH:mm:ss; e.g. 1 second before midnight would be "23:59:59". If \a format is Qt::ISODate, the string format corresponds to the ISO 8601 extended specification for representations of dates, - which is also HH:MM:SS. + which is also HH:mm:ss. If the \a format is Qt::SystemLocaleShortDate or Qt::SystemLocaleLongDate, the string format depends on the locale @@ -1925,13 +1925,13 @@ static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format, int msec = 0; if (size == 5) { - // HH:MM format + // HH:mm format second = 0; msec = 0; } else if (string.at(5) == QLatin1Char(',') || string.at(5) == QLatin1Char('.')) { if (format == Qt::TextDate) return QTime(); - // ISODate HH:MM.SSSSSS format + // ISODate HH:mm.ssssss format // We only want 5 digits worth of fraction of minute. This follows the existing // behavior that determines how milliseconds are read; 4 millisecond digits are // read and then rounded to 3. If we read at most 5 digits for fraction of minute, @@ -1951,7 +1951,7 @@ static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format, second = secondNoMs; msec = qMin(qRound(secondFraction * 1000.0), 999); } else { - // HH:MM:SS or HH:MM:SS.sssss + // HH:mm:ss or HH:mm:ss.zzz second = string.mid(6, 2).toInt(&ok); if (!ok) return QTime(); @@ -3535,7 +3535,7 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC) If the \a format is Qt::ISODate, the string format corresponds to the ISO 8601 extended specification for representations of - dates and times, taking the form YYYY-MM-DDTHH:MM:SS[Z|[+|-]HH:MM], + dates and times, taking the form YYYY-MM-DDTHH:mm:ss[Z|[+|-]HH:mm], depending on the timeSpec() of the QDateTime. If the timeSpec() is Qt::UTC, Z will be appended to the string; if the timeSpec() is Qt::OffsetFromUTC, the offset in hours and minutes from UTC will @@ -4421,7 +4421,7 @@ QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format) isoString = isoString.right(isoString.length() - 11); int offset = 0; - // Check end of string for Time Zone definition, either Z for UTC or [+-]HH:MM for Offset + // Check end of string for Time Zone definition, either Z for UTC or [+-]HH:mm for Offset if (isoString.endsWith(QLatin1Char('Z'))) { spec = Qt::UTC; isoString = isoString.left(isoString.size() - 1); -- cgit v1.2.3 From cf4b413fa4a81dbfaaaf50cb52f92ecc0d3c3f2a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 9 Dec 2014 14:16:33 -0800 Subject: Make QtDBus unit tests compile with runtime dbus-1 too There's a change in Qt 5.4.0 that makes Qt compile with its own set of D-Bus headers, which means QT_CFLAGS_DBUS may be empty. Thus, we can't compile or link if we're using the actual libdbus-1 API to build the test. This commit makes these unit tests use the same dynamic loading mechanism. Change-Id: I56b2a7320086ef88793f6552cb54ca6224010451 Reviewed-by: Simon Hausmann --- src/dbus/qdbus_symbols_p.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/dbus/qdbus_symbols_p.h b/src/dbus/qdbus_symbols_p.h index 88c51947ed..0785fea4b4 100644 --- a/src/dbus/qdbus_symbols_p.h +++ b/src/dbus/qdbus_symbols_p.h @@ -107,6 +107,9 @@ DEFINEFUNC(dbus_bool_t , dbus_connection_add_filter, (DBusConnection void *user_data, DBusFreeFunction free_data_function), (connection, function, user_data, free_data_function), return) +DEFINEFUNC(dbus_bool_t , dbus_connection_can_send_type, (DBusConnection *connection, + int type), + (connection, type), return) DEFINEFUNC(void , dbus_connection_close, (DBusConnection *connection), (connection), return) DEFINEFUNC(DBusDispatchStatus , dbus_connection_dispatch, (DBusConnection *connection), -- cgit v1.2.3 From 6796f2337ee31b4b4f07eaa54d868b999c39233a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 19 Dec 2014 11:07:47 +0100 Subject: Windows: Fix OS version determination for Windows >= 8 First, try to determine the version of kernel32.dll by using the version API. If that fails, loop using the version macros, taking the major version into account. Hangs in the minor version loop have been observed, potentially related to the major version. Task-number: QTBUG-43413 Change-Id: I982e78873510e7598c7cf839177e59812acd86f6 Reviewed-by: Joerg Bornemann --- src/corelib/global/qglobal.cpp | 78 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index ae3e86629e..997e804579 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -40,6 +40,8 @@ #include "qdir.h" #include "qdatetime.h" +#include + #ifndef QT_NO_QOBJECT #include #endif @@ -1865,6 +1867,70 @@ QT_BEGIN_INCLUDE_NAMESPACE QT_END_INCLUDE_NAMESPACE #ifndef Q_OS_WINRT + +# ifndef Q_OS_WINCE + +// Determine Windows versions >= 8 by querying the version of kernel32.dll. +static inline bool determineWinOsVersionPost8(OSVERSIONINFO *result) +{ + typedef WORD (WINAPI* PtrGetFileVersionInfoSizeW)(LPCWSTR, LPDWORD); + typedef BOOL (WINAPI* PtrVerQueryValueW)(LPCVOID, LPCWSTR, LPVOID, PUINT); + typedef BOOL (WINAPI* PtrGetFileVersionInfoW)(LPCWSTR, DWORD, DWORD, LPVOID); + + QSystemLibrary versionLib(QStringLiteral("version")); + if (!versionLib.load()) + return false; + PtrGetFileVersionInfoSizeW getFileVersionInfoSizeW = (PtrGetFileVersionInfoSizeW)versionLib.resolve("GetFileVersionInfoSizeW"); + PtrVerQueryValueW verQueryValueW = (PtrVerQueryValueW)versionLib.resolve("VerQueryValueW"); + PtrGetFileVersionInfoW getFileVersionInfoW = (PtrGetFileVersionInfoW)versionLib.resolve("GetFileVersionInfoW"); + if (!getFileVersionInfoSizeW || !verQueryValueW || !getFileVersionInfoW) + return false; + + const wchar_t kernel32Dll[] = L"kernel32.dll"; + DWORD handle; + const DWORD size = getFileVersionInfoSizeW(kernel32Dll, &handle); + if (!size) + return false; + QScopedArrayPointer versionInfo(new BYTE[size]); + if (!getFileVersionInfoW(kernel32Dll, handle, size, versionInfo.data())) + return false; + UINT uLen; + VS_FIXEDFILEINFO *fileInfo = Q_NULLPTR; + if (!verQueryValueW(versionInfo.data(), L"\\", (LPVOID *)&fileInfo, &uLen)) + return false; + const DWORD fileVersionMS = fileInfo->dwFileVersionMS; + const DWORD fileVersionLS = fileInfo->dwFileVersionLS; + result->dwMajorVersion = HIWORD(fileVersionMS); + result->dwMinorVersion = LOWORD(fileVersionMS); + result->dwBuildNumber = HIWORD(fileVersionLS); + return true; +} + +// Fallback for determining Windows versions >= 8 by looping using the +// version check macros. Note that it will return build number=0 to avoid +// inefficient looping. +static inline void determineWinOsVersionFallbackPost8(OSVERSIONINFO *result) +{ + result->dwBuildNumber = 0; + DWORDLONG conditionMask = 0; + VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL); + VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL); + OSVERSIONINFOEX checkVersion = { sizeof(OSVERSIONINFOEX), result->dwMajorVersion, 0, + result->dwBuildNumber, result->dwPlatformId, {'\0'}, 0, 0, 0, 0, 0 }; + for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMajorVersion) + result->dwMajorVersion = checkVersion.dwMajorVersion; + conditionMask = 0; + checkVersion.dwMajorVersion = result->dwMajorVersion; + checkVersion.dwMinorVersion = 0; + VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_EQUAL); + VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL); + VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL); + for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_MINORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMinorVersion) + result->dwMinorVersion = checkVersion.dwMinorVersion; +} + +# endif // !Q_OS_WINCE + static inline OSVERSIONINFO winOsVersion() { OSVERSIONINFO result = { sizeof(OSVERSIONINFO), 0, 0, 0, 0, {'\0'}}; @@ -1880,16 +1946,8 @@ static inline OSVERSIONINFO winOsVersion() # endif # ifndef Q_OS_WINCE if (result.dwMajorVersion == 6 && result.dwMinorVersion == 2) { - // This could be Windows 8.1 or higher. Note that as of Windows 9, - // the major version needs to be checked as well. - DWORDLONG conditionMask = 0; - VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL); - VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL); - VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL); - OSVERSIONINFOEX checkVersion = { sizeof(OSVERSIONINFOEX), result.dwMajorVersion, result.dwMinorVersion, - result.dwBuildNumber, result.dwPlatformId, {'\0'}, 0, 0, 0, 0, 0 }; - for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_MINORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMinorVersion) - result.dwMinorVersion = checkVersion.dwMinorVersion; + if (!determineWinOsVersionPost8(&result)) + determineWinOsVersionFallbackPost8(&result); } # endif // !Q_OS_WINCE return result; -- cgit v1.2.3 From 58fc02241a96b18a1062f2495d40dcdc047a7d5c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 6 Jan 2015 09:59:52 +0100 Subject: Windows: Release mouse capture when window is blocked by modal window. The capture needs to be cleared when for example a modal dialog is opened from a timer slot or similar while moving the window. Task-number: QTBUG-43308 Change-Id: Id0c01080d67d1057004a7f85b037dce5e220de42 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowswindow.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 7d67aa0d09..4df27faf81 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1770,6 +1770,8 @@ void QWindowsWindow::windowEvent(QEvent *event) case QEvent::WindowBlocked: // Blocked by another modal window. setEnabled(false); setFlag(BlockedByModal); + if (hasMouseCapture()) + ReleaseCapture(); break; case QEvent::WindowUnblocked: setEnabled(true); -- cgit v1.2.3 From 5517d1fde55ee3d4601b4a47543d846467b4d267 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 6 Jan 2015 12:31:59 +0100 Subject: Windows: Remove check for minimum/maximum size constraints. The warning was triggered when increasing the fixed size of a window. If there is a real violation of the size constraints, the below warning will show. Task-number: QTBUG-43420 Change-Id: I85d7d0a91d040aa3ddeff8c3d105351efd5e14a9 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowswindow.cpp | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 4df27faf81..6279b6f4af 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1307,21 +1307,7 @@ void QWindowsWindow::setGeometryDp(const QRect &rectIn) const QMargins margins = frameMarginsDp(); rect.moveTopLeft(rect.topLeft() + QPoint(margins.left(), margins.top())); } - const QSize oldSize = m_data.geometry.size(); m_data.geometry = rect; - const QSize newSize = rect.size(); - // Check on hint. - if (newSize != oldSize) { - const QWindowsGeometryHint hint(window(), m_data.customMargins); - if (!hint.validSize(newSize)) { - qWarning("%s: Attempt to set a size (%dx%d) violating the constraints" - "(%dx%d - %dx%d) on window %s/'%s'.", __FUNCTION__, - newSize.width(), newSize.height(), - hint.minimumSize.width(), hint.minimumSize.height(), - hint.maximumSize.width(), hint.maximumSize.height(), - window()->metaObject()->className(), qPrintable(window()->objectName())); - } - } if (m_data.hwnd) { // A ResizeEvent with resulting geometry will be sent. If we cannot // achieve that size (for example, window title minimal constraint), -- cgit v1.2.3 From bb16ceac6871a9096547f5170ff174e87a605437 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 5 Jan 2015 14:26:03 +0100 Subject: Prevent buffer overrun when getting the glyph images The change 35bc3dc45aacaf36a8bdfccc7627136cc2e5b185 moved some padding out of QTextureGlyphCache into the font engines directly, however this was not done for the DirectWrite font engine so it caused a buffer overrun. Task-number: QTBUG-41782 Change-Id: I4e643159036f06c5edd8a742dc6694d517a47826 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../platforms/windows/qwindowsfontenginedirectwrite.cpp | 17 +++++++++++++++-- .../platforms/windows/qwindowsfontenginedirectwrite.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp index 648f68bb19..ed512f78ca 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp @@ -515,8 +515,9 @@ QImage QWindowsFontEngineDirectWrite::imageForGlyph(glyph_t t, const QTransform &xform) { glyph_metrics_t metrics = QFontEngine::boundingBox(t, xform); - int width = (metrics.width + margin * 2 + 4).ceil().toInt() ; - int height = (metrics.height + margin * 2 + 4).ceil().toInt(); + // This needs to be kept in sync with alphaMapBoundingBox + int width = (metrics.width + margin * 2).ceil().toInt() ; + int height = (metrics.height + margin * 2).ceil().toInt(); UINT16 glyphIndex = t; FLOAT glyphAdvance = metrics.xoff.toReal(); @@ -699,6 +700,18 @@ QString QWindowsFontEngineDirectWrite::fontNameSubstitute(const QString &familyN return QSettings(QLatin1String(keyC), QSettings::NativeFormat).value(familyName, familyName).toString(); } +glyph_metrics_t QWindowsFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph, QFixed pos, const QTransform &matrix, GlyphFormat format) +{ + Q_UNUSED(pos); + int margin = 0; + if (format == QFontEngine::Format_A32 || format == QFontEngine::Format_ARGB) + margin = glyphMargin(QFontEngine::Format_A32); + glyph_metrics_t gm = QFontEngine::boundingBox(glyph, matrix); + gm.width += margin * 2; + gm.height += margin * 2; + return gm; +} + QT_END_NAMESPACE #endif // QT_NO_DIRECTWRITE diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h index 2addb90de3..e0466c138d 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h @@ -75,6 +75,7 @@ public: glyph_metrics_t boundingBox(const QGlyphLayout &glyphs); glyph_metrics_t boundingBox(glyph_t g); + glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, QFixed, const QTransform &matrix, GlyphFormat); QFixed ascent() const; QFixed descent() const; -- cgit v1.2.3 From e7210a4945b4fbc65c90285acc0e136ae2d80d95 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 5 Jan 2015 14:47:53 +0100 Subject: Remove redundant code The non client mouse events have the right information regarding the modifiers now so the old code covered with Q_WS_WIN can be removed. Change-Id: I3e4ebc0debdd66970b18233f189b5d9e880e40a9 Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qdockwidget.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 93e6131ab9..2bf8a37e7f 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -930,12 +930,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) initDrag(event->pos(), true); if (state == 0) break; -#ifdef Q_WS_WIN - // On Windows, NCA mouse events don't contain modifier info - state->ctrlDrag = GetKeyState(VK_CONTROL) & 0x8000; -#else state->ctrlDrag = event->modifiers() & Qt::ControlModifier; -#endif startDrag(); break; case QEvent::NonClientAreaMouseMove: -- cgit v1.2.3 From ea4dcc5931d455e4ee3e958ffa54a9f54ab022c8 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Mon, 5 Jan 2015 10:45:25 +0100 Subject: Fix crash on Mac OS if PAC URL contains non-URL legal chars macQueryInternal() was retrieving the PAC URL string as-entered by the user in the 'Proxies' tab of the system network settings dialog and passing it to CFURLCreateWithString(). CFURLCreateWithString() returns null if the input string contains non-URL legal chars or is empty. Change-Id: I9166d0433a62c7b2274b5435a7dea0a16997d10e Patch-By: Robert Knight Task-number: QTBUG-36787 Reviewed-by: Peter Hartmann Reviewed-by: Markus Goetz --- src/network/kernel/qnetworkproxy_mac.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/kernel/qnetworkproxy_mac.cpp b/src/network/kernel/qnetworkproxy_mac.cpp index 7d262467c3..81bce0c300 100644 --- a/src/network/kernel/qnetworkproxy_mac.cpp +++ b/src/network/kernel/qnetworkproxy_mac.cpp @@ -221,7 +221,11 @@ QList macQueryInternal(const QNetworkProxyQuery &query) int enabled; if (CFNumberGetValue(pacEnabled, kCFNumberIntType, &enabled) && enabled) { // PAC is enabled - CFStringRef cfPacLocation = (CFStringRef)CFDictionaryGetValue(dict, kSCPropNetProxiesProxyAutoConfigURLString); + // kSCPropNetProxiesProxyAutoConfigURLString returns the URL string + // as entered in the system proxy configuration dialog + CFStringRef pacLocationSetting = (CFStringRef)CFDictionaryGetValue(dict, kSCPropNetProxiesProxyAutoConfigURLString); + QCFType cfPacLocation = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, pacLocationSetting, NULL, NULL, + kCFStringEncodingUTF8); if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { QCFType pacData; -- cgit v1.2.3 From a83e4d1d9dd90d4563ce60f27dfb7802a780e33e Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Mon, 5 Jan 2015 11:42:52 +0100 Subject: Fix possible crash when passing an invalid PAC URL This commit checks whether CFURLCreateWithString() succeeded. It does not appear to be possible to enter an empty URL directly in the PAC configuration dialog but I can't rule out the possibility that it could find its way into the settings via some other means. Change-Id: I6c2053d385503bf0330f5ae9fb1ec36a473d425d Patch-By: Robert Knight Task-number: QTBUG-36787 Reviewed-by: Markus Goetz Reviewed-by: Peter Hartmann --- src/network/kernel/qnetworkproxy_mac.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/network/kernel/qnetworkproxy_mac.cpp b/src/network/kernel/qnetworkproxy_mac.cpp index 81bce0c300..6be032ed9b 100644 --- a/src/network/kernel/qnetworkproxy_mac.cpp +++ b/src/network/kernel/qnetworkproxy_mac.cpp @@ -230,6 +230,10 @@ QList macQueryInternal(const QNetworkProxyQuery &query) if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { QCFType pacData; QCFType pacUrl = CFURLCreateWithString(kCFAllocatorDefault, cfPacLocation, NULL); + if (!pacUrl) { + qWarning("Invalid PAC URL \"%s\"", qPrintable(QCFString::toQString(cfPacLocation))); + return result; + } SInt32 errorCode; if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, pacUrl, &pacData, NULL, NULL, &errorCode)) { QString pacLocation = QCFString::toQString(cfPacLocation); -- cgit v1.2.3 From 83bd9393e5564ea9168fda90c0f44456633a483a Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Mon, 5 Jan 2015 15:22:57 +0100 Subject: Fix crash if PAC script retrieval returns a null CFData instance The documentation for CFURLCreateDataAndPropertiesFromResource() does not make this clear but from looking at the CFNetwork implementation and a user stacktrace it appears that this function can return true but not set the data argument under certain circumstances. Change-Id: I48034a640d6f47a51cd5883bbafacad4bcbd0415 Task-number: QTBUG-36787 Patch-By: Robert Knight Reviewed-by: Markus Goetz Reviewed-by: Peter Hartmann --- src/network/kernel/qnetworkproxy_mac.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/kernel/qnetworkproxy_mac.cpp b/src/network/kernel/qnetworkproxy_mac.cpp index 6be032ed9b..a1ac349949 100644 --- a/src/network/kernel/qnetworkproxy_mac.cpp +++ b/src/network/kernel/qnetworkproxy_mac.cpp @@ -240,7 +240,10 @@ QList macQueryInternal(const QNetworkProxyQuery &query) qWarning("Unable to get the PAC script at \"%s\" (%s)", qPrintable(pacLocation), cfurlErrorDescription(errorCode)); return result; } - + if (!pacData) { + qWarning("\"%s\" returned an empty PAC script", qPrintable(QCFString::toQString(cfPacLocation))); + return result; + } QCFType pacScript = CFStringCreateFromExternalRepresentation(kCFAllocatorDefault, pacData, kCFStringEncodingISOLatin1); if (!pacScript) { // This should never happen, but the documentation says it may return NULL if there was a problem creating the object. -- cgit v1.2.3 From 8f9ced985727136dc7d1502b7212a54f65b8b113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 12 Dec 2014 15:14:04 +0100 Subject: iOS: Raise window level instead of hiding statusbar during VKB scroll MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hiding the statusbar using the normal iOS APIs result in QScreen reporting new availableGeometry, which is not what we want. The scroll of the screen is a purely visual effect, and shouldn't have any effect on observable Qt APIs besides the keyboard rect changing. Instead of actually hiding the statusbar, we achieve the same effect by raising the key window (and any other application windows, including the keyboard) to the level of the statusbar, effectively putting them above the statusbar. This still leaves popups and alert windows above the key window, as normal. Change-Id: Ib7694240ca86cfb9000de35bf0c49343ffb37e32 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosinputcontext.mm | 17 ++++++++++++++++- src/plugins/platforms/ios/qiosviewcontroller.mm | 8 +------- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index bbfc03667e..6e56f47954 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -503,7 +503,22 @@ void QIOSInputContext::scroll(int y) [rootView.layer addAnimation:animation forKey:@"AnimateSubLayerTransform"]; rootView.layer.sublayerTransform = translationTransform; - [rootView.qtViewController updateProperties]; + bool keyboardScrollIsActive = y != 0; + + // Raise all known windows to above the status-bar if we're scrolling the screen, + // while keeping the relative window level between the windows the same. + NSArray *applicationWindows = [[UIApplication sharedApplication] windows]; + static QHash originalWindowLevels; + for (UIWindow *window in applicationWindows) { + if (keyboardScrollIsActive && !originalWindowLevels.contains(window)) + originalWindowLevels.insert(window, window.windowLevel); + + UIWindowLevel windowLevelAdjustment = keyboardScrollIsActive ? UIWindowLevelStatusBar : 0; + window.windowLevel = originalWindowLevels.value(window) + windowLevelAdjustment; + + if (!keyboardScrollIsActive) + originalWindowLevels.remove(window); + } } completion:^(BOOL){ if (self) { diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index a2d81e3b6c..f678f7e807 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -281,14 +281,8 @@ // All decisions are based on the the top level window focusWindow = qt_window_private(focusWindow)->topLevelWindow(); - bool hasScrolledRootViewDueToVirtualKeyboard = - !CATransform3DIsIdentity(self.view.layer.sublayerTransform); - bool currentStatusBarVisibility = self.prefersStatusBarHidden; - self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen - || hasScrolledRootViewDueToVirtualKeyboard; - self.preferredStatusBarUpdateAnimation = hasScrolledRootViewDueToVirtualKeyboard ? - UIStatusBarAnimationFade : UIStatusBarAnimationNone; + self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen; if (self.prefersStatusBarHidden != currentStatusBarVisibility) { #if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0) -- cgit v1.2.3 From b0088967c3373b604d102384d97e1d56a9c0ac9e Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Fri, 5 Dec 2014 12:28:53 +0100 Subject: QCoreTextFontDatabase: release CTFontDescriptorRef references in dtor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QCoreTextFontDatabase::m_systemFontDescriptors owns the references to the underlying CTFontDescriptorRef objects. in order to avoid a leak, we should release them Change-Id: I8fc6c158908e0173696cd91058ac34efb3de01d5 Reviewed-by: Tor Arne Vestbø --- src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 9f2ff10a21..f447defbce 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -177,6 +177,8 @@ QCoreTextFontDatabase::QCoreTextFontDatabase() QCoreTextFontDatabase::~QCoreTextFontDatabase() { + foreach (CTFontDescriptorRef ref, m_systemFontDescriptors) + CFRelease(ref); } static CFArrayRef availableFamilyNames() -- cgit v1.2.3 From 099075427b05bbb7075854401da15afd474f18dc Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Tue, 16 Dec 2014 13:19:40 +0100 Subject: QCoreTextFontDatabase: close memory leak in themeFont MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if the CTFontDescriptorRef is already contained in m_systemFontDescriptors we leak a reference, unless we explicitly release it. Change-Id: I5b263aa52b4433e7e28cc01164098892cc9cd2ae Reviewed-by: Tor Arne Vestbø --- src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index f447defbce..5a6c5de0b4 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -828,7 +828,11 @@ QFont *QCoreTextFontDatabase::themeFont(QPlatformTheme::Font f) const CTFontDescriptorRef fontDesc = fontDescriptorFromTheme(f); FontDescription fd; getFontDescription(fontDesc, &fd); - m_systemFontDescriptors.insert(fontDesc); + + if (!m_systemFontDescriptors.contains(fontDesc)) + m_systemFontDescriptors.insert(fontDesc); + else + CFRelease(fontDesc); QFont *font = new QFont(fd.familyName, fd.pixelSize, fd.weight, fd.style == QFont::StyleItalic); return font; -- cgit v1.2.3 From 1daa7aff4d29f82a31c4d7d0172a119aaa43aaa3 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Thu, 11 Dec 2014 07:44:28 +0100 Subject: Remove extra ';' after QPrint namespace block The extra ';' causes a warning when gcc is used with -Wpedantic. Change-Id: I3d99aca6f160e46dbe2173106160474664e06b2c Reviewed-by: Friedemann Kleint --- src/printsupport/kernel/qprint_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/printsupport/kernel/qprint_p.h b/src/printsupport/kernel/qprint_p.h index 504a0d6e20..ebb165190e 100644 --- a/src/printsupport/kernel/qprint_p.h +++ b/src/printsupport/kernel/qprint_p.h @@ -143,7 +143,7 @@ namespace QPrint { QPrint::OutputBinId id; }; -}; +} struct InputSlotMap { QPrint::InputSlotId id; -- cgit v1.2.3 From d40b66a8ef98777c69ac293dac9a332f88832c23 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 7 Jan 2015 14:50:41 +0100 Subject: Fix use-after-free bug xcb_image_destroy() calls free on m_xcb_image and then few lines down we access member of m_xcb_image. Swap order of these two actions. Change-Id: I01fb43a066459cce462df6af22161c35cef524eb Task-number: QTBUG-43623 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbbackingstore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 0b9717759b..f4382c7b50 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -145,8 +145,6 @@ void QXcbShmImage::destroy() if (segmentSize && m_shm_info.shmaddr) Q_XCB_CALL(xcb_shm_detach(xcb_connection(), m_shm_info.shmseg)); - xcb_image_destroy(m_xcb_image); - if (segmentSize) { if (m_shm_info.shmaddr) { shmdt(m_shm_info.shmaddr); @@ -156,6 +154,8 @@ void QXcbShmImage::destroy() } } + xcb_image_destroy(m_xcb_image); + if (m_gc) Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc)); } -- cgit v1.2.3 From 72bc032ca8f7fc00900a9ca20bab8560ccf99727 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 24 Dec 2014 10:11:02 +1000 Subject: Refactor networkmanager QtBearer backend to use QDBusAbstractInterface. Using QDBusInterface causes introspection, which may not be permitted by some platforms. Change-Id: I953d27b9c0fc7c21d52fefeb8c7760a7235aed9d Reviewed-by: Alex Blasche --- .../networkmanager/qnetworkmanagerengine.cpp | 52 +- .../networkmanager/qnetworkmanagerservice.cpp | 556 +++++---------------- .../bearer/networkmanager/qnetworkmanagerservice.h | 88 +--- 3 files changed, 186 insertions(+), 510 deletions(-) (limited to 'src') diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index f0977b4735..f52b9d4b4d 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -125,7 +125,6 @@ void QNetworkManagerEngine::setupConfigurations() activeConnectionsList.insert(acPath.path(), activeConnection); connect(activeConnection, SIGNAL(propertiesChanged(QMap)), this, SLOT(activeConnectionPropertiesChanged(QMap))); - activeConnection->setConnections(); QStringList devices = activeConnection->devices(); if (!devices.isEmpty()) { @@ -180,7 +179,7 @@ void QNetworkManagerEngine::connectToId(const QString &id) NMDeviceType connectionType = connection->getType(); QString dbusDevicePath; - const QString settingsPath = connection->connectionInterface()->path(); + const QString settingsPath = connection->path(); QString specificPath = configuredAccessPoints.key(settingsPath); if (isConnectionActive(settingsPath)) @@ -277,7 +276,6 @@ void QNetworkManagerEngine::interfacePropertiesChanged(const QMap)), this, SLOT(activeConnectionPropertiesChanged(QMap))); - activeConnection->setConnections(); } const QString id = activeConnection->connection().path(); @@ -373,10 +371,10 @@ void QNetworkManagerEngine::deviceConnectionsChanged(const QStringList &connecti { QMutexLocker locker(&mutex); for (int i = 0; i < connections.count(); ++i) { - if (connectionsList.contains(connections.at(i)->connectionInterface()->path())) + if (connectionsList.contains(connections.at(i)->path())) continue; - const QString settingsPath = connections.at(i)->connectionInterface()->path(); + const QString settingsPath = connections.at(i)->path(); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(settingsPath); @@ -399,11 +397,10 @@ void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path) connect(iDevice,SIGNAL(connectionsChanged(QStringList)), this,SLOT(deviceConnectionsChanged(QStringList))); - iDevice->setConnections(); interfaceDevices.insert(path.path(),iDevice); if (iDevice->deviceType() == DEVICE_TYPE_WIFI) { QNetworkManagerInterfaceDeviceWireless *wirelessDevice = - new QNetworkManagerInterfaceDeviceWireless(iDevice->connectionInterface()->path(),this); + new QNetworkManagerInterfaceDeviceWireless(iDevice->path(),this); connect(wirelessDevice, SIGNAL(accessPointAdded(QString)), this, SLOT(newAccessPoint(QString))); @@ -417,9 +414,9 @@ void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path) if (iDevice->deviceType() == DEVICE_TYPE_ETHERNET) { QNetworkManagerInterfaceDeviceWired *wiredDevice = - new QNetworkManagerInterfaceDeviceWired(iDevice->connectionInterface()->path(),this); + new QNetworkManagerInterfaceDeviceWired(iDevice->path(),this); connect(wiredDevice,SIGNAL(carrierChanged(bool)),this,SLOT(wiredCarrierChanged(bool))); - wiredDevices.insert(iDevice->connectionInterface()->path(), wiredDevice); + wiredDevices.insert(iDevice->path(), wiredDevice); } } @@ -454,7 +451,7 @@ void QNetworkManagerEngine::wiredCarrierChanged(bool carrier) for (int i = 0; i < connections.count(); ++i) { QNetworkManagerSettingsConnection *connection = connections.at(i); if (connection->getType() == DEVICE_TYPE_ETHERNET - && settingsPath.path() == connection->connectionInterface()->path()) { + && settingsPath.path() == connection->path()) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(settingsPath.path()); @@ -486,9 +483,9 @@ void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path, } QNetworkManagerSettingsConnection *connection = - new QNetworkManagerSettingsConnection(settings->connectionInterface()->service(), + new QNetworkManagerSettingsConnection(settings->service(), path.path(),this); - const QString settingsPath = connection->connectionInterface()->path(); + const QString settingsPath = connection->path(); if (accessPointConfigurations.contains(settingsPath)) { return; } @@ -506,7 +503,7 @@ void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path, for (int i = 0; i < accessPoints.count(); ++i) { if (connection->getSsid() == accessPoints.at(i)->ssid()) { // remove the corresponding accesspoint from configurations - apPath = accessPoints.at(i)->connectionInterface()->path(); + apPath = accessPoints.at(i)->path(); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(apPath); if (ptr) { @@ -533,7 +530,7 @@ void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path, i.next(); if (i.value()->deviceType() == deviceType) { QNetworkManagerInterfaceDeviceWired *wiredDevice - = wiredDevices.value(i.value()->connectionInterface()->path()); + = wiredDevices.value(i.value()->path()); if (wiredDevice->carrier()) { cpPriv->state |= QNetworkConfiguration::Discovered; } @@ -564,7 +561,7 @@ bool QNetworkManagerEngine::isConnectionActive(const QString &settingsPath) QNetworkManagerSettingsConnection *settingsConnection = connectionFromId(settingsPath); if (settingsConnection->getType() == DEVICE_TYPE_MODEM) { - return isActiveContext(settingsConnection->connectionInterface()->path()); + return isActiveContext(settingsConnection->path()); } return false; @@ -611,7 +608,7 @@ void QNetworkManagerEngine::updateConnection() qobject_cast(sender()); if (!connection) return; - const QString settingsPath = connection->connectionInterface()->path(); + const QString settingsPath = connection->path(); QNetworkConfigurationPrivate *cpPriv = parseConnection(settingsPath, connection->getSettings()); @@ -682,20 +679,19 @@ void QNetworkManagerEngine::newAccessPoint(const QString &path) bool okToAdd = true; for (int i = 0; i < accessPoints.count(); ++i) { - if (accessPoints.at(i)->connectionInterface()->path() == path) { + if (accessPoints.at(i)->path() == path) { okToAdd = false; } } if (okToAdd) { accessPoints.append(accessPoint); - accessPoint->setConnections(); } // Check if configuration exists for connection. if (!accessPoint->ssid().isEmpty()) { for (int i = 0; i < connections.count(); ++i) { QNetworkManagerSettingsConnection *connection = connections.at(i); - const QString settingsPath = connection->connectionInterface()->path(); + const QString settingsPath = connection->path(); if (accessPoint->ssid() == connection->getSsid()) { if (!configuredAccessPoints.contains(path)) { @@ -741,18 +737,18 @@ void QNetworkManagerEngine::removeAccessPoint(const QString &path) QMutexLocker locker(&mutex); for (int i = 0; i < accessPoints.count(); ++i) { QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i); - if (accessPoint->connectionInterface()->path() == path) { + if (accessPoint->path() == path) { accessPoints.removeOne(accessPoint); - if (configuredAccessPoints.contains(accessPoint->connectionInterface()->path())) { + if (configuredAccessPoints.contains(accessPoint->path())) { // find connection and change state to Defined - configuredAccessPoints.remove(accessPoint->connectionInterface()->path()); + configuredAccessPoints.remove(accessPoint->path()); for (int i = 0; i < connections.count(); ++i) { QNetworkManagerSettingsConnection *connection = connections.at(i); if (accessPoint->ssid() == connection->getSsid()) {//might not have bssid yet - const QString settingsPath = connection->connectionInterface()->path(); + const QString settingsPath = connection->path(); const QString connectionId = settingsPath; QNetworkConfigurationPrivatePointer ptr = @@ -804,7 +800,7 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) { QNetworkManagerInterfaceDevice device(devicePath.path(),this); if (device.deviceType() == DEVICE_TYPE_ETHERNET) { - QNetworkManagerInterfaceDeviceWired *wiredDevice = wiredDevices.value(device.connectionInterface()->path()); + QNetworkManagerInterfaceDeviceWired *wiredDevice = wiredDevices.value(device.path()); if (wiredDevice->carrier()) { cpPriv->state |= QNetworkConfiguration::Discovered; break; @@ -819,10 +815,10 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri if (connectionSsid == accessPoints.at(i)->ssid() && map.value("802-11-wireless").value("seen-bssids").toStringList().contains(accessPoints.at(i)->hwAddress())) { cpPriv->state |= QNetworkConfiguration::Discovered; - if (!configuredAccessPoints.contains(accessPoints.at(i)->connectionInterface()->path())) { - configuredAccessPoints.insert(accessPoints.at(i)->connectionInterface()->path(),settingsPath); + if (!configuredAccessPoints.contains(accessPoints.at(i)->path())) { + configuredAccessPoints.insert(accessPoints.at(i)->path(),settingsPath); - const QString accessPointId = accessPoints.at(i)->connectionInterface()->path(); + const QString accessPointId = accessPoints.at(i)->path(); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(accessPointId); @@ -881,7 +877,7 @@ QNetworkManagerSettingsConnection *QNetworkManagerEngine::connectionFromId(const { for (int i = 0; i < connections.count(); ++i) { QNetworkManagerSettingsConnection *connection = connections.at(i); - if (id == connection->connectionInterface()->path()) + if (id == connection->path()) return connection; } diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp index 9f4ae55e78..16a7e475e0 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp @@ -47,32 +47,24 @@ #ifndef QT_NO_DBUS +#define DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties" + QT_BEGIN_NAMESPACE -class QNetworkManagerInterfacePrivate -{ -public: - QDBusInterface *connectionInterface; - bool valid; -}; QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent) - : QObject(parent) -{ - d = new QNetworkManagerInterfacePrivate(); - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - QLatin1String(NM_DBUS_PATH), - QLatin1String(NM_DBUS_INTERFACE), - QDBusConnection::systemBus(),parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + QLatin1String(NM_DBUS_PATH), + NM_DBUS_INTERFACE, + QDBusConnection::systemBus(),parent) +{ + if (!isValid()) { return; } - d->valid = true; - QDBusInterface managerPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), + PropertiesDBusInterface managerPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH), - QLatin1String("org.freedesktop.DBus.Properties"), + DBUS_PROPERTIES_INTERFACE, QDBusConnection::systemBus()); QList argumentList; argumentList << QLatin1String(NM_DBUS_INTERFACE); @@ -81,13 +73,17 @@ QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent) argumentList); if (!propsReply.isError()) { propertyMap = propsReply.value(); + } else { + qWarning() << Q_FUNC_INFO << "propsReply"< > nmReply - = d->connectionInterface->call(QLatin1String("GetDevices")); + = call(QLatin1String("GetDevices")); nmReply.waitForFinished(); if (!nmReply.isError()) { devicesPathList = nmReply.value(); + } else { + qWarning() << Q_FUNC_INFO <<"nmReply"<connectionInterface; - delete d; -} - -bool QNetworkManagerInterface::isValid() -{ - return d->valid; } bool QNetworkManagerInterface::setConnections() @@ -138,16 +127,11 @@ bool QNetworkManagerInterface::setConnections() return allOk; } -QDBusInterface *QNetworkManagerInterface::connectionInterface() const -{ - return d->connectionInterface; -} - QList QNetworkManagerInterface::getDevices() { if (devicesPathList.isEmpty()) { //qWarning() << "using blocking call!"; - QDBusReply > reply = d->connectionInterface->call(QLatin1String("GetDevices")); + QDBusReply > reply = call(QLatin1String("GetDevices")); devicesPathList = reply.value(); } return devicesPathList; @@ -157,7 +141,7 @@ void QNetworkManagerInterface::activateConnection(QDBusObjectPath connectionPath QDBusObjectPath devicePath, QDBusObjectPath specificObject) { - QDBusPendingCall pendingCall = d->connectionInterface->asyncCall(QLatin1String("ActivateConnection"), + QDBusPendingCall pendingCall = asyncCall(QLatin1String("ActivateConnection"), QVariant::fromValue(connectionPath), QVariant::fromValue(devicePath), QVariant::fromValue(specificObject)); @@ -167,9 +151,9 @@ void QNetworkManagerInterface::activateConnection(QDBusObjectPath connectionPath this, SIGNAL(activationFinished(QDBusPendingCallWatcher*))); } -void QNetworkManagerInterface::deactivateConnection(QDBusObjectPath connectionPath) const +void QNetworkManagerInterface::deactivateConnection(QDBusObjectPath connectionPath) { - d->connectionInterface->asyncCall(QLatin1String("DeactivateConnection"), QVariant::fromValue(connectionPath)); + asyncCall(QLatin1String("DeactivateConnection"), QVariant::fromValue(connectionPath)); } bool QNetworkManagerInterface::wirelessEnabled() const @@ -245,73 +229,38 @@ void QNetworkManagerInterface::propertiesSwap(QMap map) } } -class QNetworkManagerInterfaceAccessPointPrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - bool valid; -}; - QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent) - : QObject(parent) -{ - d = new QNetworkManagerInterfaceAccessPointPrivate(); - d->path = dbusPathName; - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT), - QDBusConnection::systemBus(),parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + dbusPathName, + NM_DBUS_INTERFACE_ACCESS_POINT, + QDBusConnection::systemBus(),parent) +{ + if (!isValid()) { return; } - QDBusInterface accessPointPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String("org.freedesktop.DBus.Properties"), + PropertiesDBusInterface *accessPointPropertiesInterface = new PropertiesDBusInterface(QLatin1String(NM_DBUS_SERVICE), + dbusPathName, + DBUS_PROPERTIES_INTERFACE, QDBusConnection::systemBus()); QList argumentList; argumentList << QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT); QDBusPendingReply propsReply - = accessPointPropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"), + = accessPointPropertiesInterface->callWithArgumentList(QDBus::Block,QLatin1String("GetAll"), argumentList); if (!propsReply.isError()) { propertyMap = propsReply.value(); } QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + dbusPathName, QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap))); - - d->valid = true; - } QNetworkManagerInterfaceAccessPoint::~QNetworkManagerInterfaceAccessPoint() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerInterfaceAccessPoint::isValid() -{ - return d->valid; -} - -bool QNetworkManagerInterfaceAccessPoint::setConnections() -{ - if (!isValid()) - return false; - - return true; -} - -QDBusInterface *QNetworkManagerInterfaceAccessPoint::connectionInterface() const -{ - return d->connectionInterface; } quint32 QNetworkManagerInterfaceAccessPoint::flags() const @@ -386,31 +335,19 @@ void QNetworkManagerInterfaceAccessPoint::propertiesSwap(QMap } } -class QNetworkManagerInterfaceDevicePrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - bool valid; -}; - QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent) - : QObject(parent) + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + deviceObjectPath, + NM_DBUS_INTERFACE_DEVICE, + QDBusConnection::systemBus(),parent) { - d = new QNetworkManagerInterfaceDevicePrivate(); - d->path = deviceObjectPath; - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_DEVICE), - QDBusConnection::systemBus(),parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + if (!isValid()) { return; } - QDBusInterface devicePropertiesInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String("org.freedesktop.DBus.Properties"), + PropertiesDBusInterface devicePropertiesInterface(QLatin1String(NM_DBUS_SERVICE), + deviceObjectPath, + DBUS_PROPERTIES_INTERFACE, QDBusConnection::systemBus(),parent); QList argumentList; @@ -424,35 +361,14 @@ QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &de } QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + deviceObjectPath, QLatin1String(NM_DBUS_INTERFACE_DEVICE), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap))); - d->valid = true; } QNetworkManagerInterfaceDevice::~QNetworkManagerInterfaceDevice() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerInterfaceDevice::isValid() -{ - return d->valid; -} - -bool QNetworkManagerInterfaceDevice::setConnections() -{ - if (!isValid()) - return false; - - return true; -} - -QDBusInterface *QNetworkManagerInterfaceDevice::connectionInterface() const -{ - return d->connectionInterface; } QString QNetworkManagerInterfaceDevice::udi() const @@ -519,31 +435,19 @@ void QNetworkManagerInterfaceDevice::propertiesSwap(QMap map) Q_EMIT propertiesChanged(map); } -class QNetworkManagerInterfaceDeviceWiredPrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - bool valid; -}; - QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath, QObject *parent) - : QObject(parent) -{ - d = new QNetworkManagerInterfaceDeviceWiredPrivate(); - d->path = ifaceDevicePath; - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED), - QDBusConnection::systemBus(), parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + ifaceDevicePath, + NM_DBUS_INTERFACE_DEVICE_WIRED, + QDBusConnection::systemBus(), parent) +{ + if (!isValid()) { return; } - QDBusInterface deviceWiredPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String("org.freedesktop.DBus.Properties"), - QDBusConnection::systemBus(),parent); + PropertiesDBusInterface deviceWiredPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), + ifaceDevicePath, + DBUS_PROPERTIES_INTERFACE, + QDBusConnection::systemBus(),parent); QList argumentList; argumentList << QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED); @@ -556,36 +460,14 @@ QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const Q } QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + ifaceDevicePath, QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap))); - - d->valid = true; } QNetworkManagerInterfaceDeviceWired::~QNetworkManagerInterfaceDeviceWired() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerInterfaceDeviceWired::isValid() -{ - - return d->valid; -} - -bool QNetworkManagerInterfaceDeviceWired::setConnections() -{ - if (!isValid()) - return false; - return true; -} - -QDBusInterface *QNetworkManagerInterfaceDeviceWired::connectionInterface() const -{ - return d->connectionInterface; } QString QNetworkManagerInterfaceDeviceWired::hwAddress() const @@ -639,39 +521,27 @@ void QNetworkManagerInterfaceDeviceWired::propertiesSwap(QMap Q_EMIT propertiesChanged(map); } -class QNetworkManagerInterfaceDeviceWirelessPrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - bool valid; -}; - QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath, QObject *parent) - : QObject(parent) -{ - d = new QNetworkManagerInterfaceDeviceWirelessPrivate(); - d->path = ifaceDevicePath; - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), - QDBusConnection::systemBus(), parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + ifaceDevicePath, + NM_DBUS_INTERFACE_DEVICE_WIRELESS, + QDBusConnection::systemBus(), parent) +{ + if (!isValid()) { return; } - + interfacePath = ifaceDevicePath; QDBusPendingReply > nmReply - = d->connectionInterface->call(QLatin1String("GetAccessPoints")); + = call(QLatin1String("GetAccessPoints")); if (!nmReply.isError()) { accessPointsList = nmReply.value(); } - QDBusInterface deviceWirelessPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String("org.freedesktop.DBus.Properties"), + PropertiesDBusInterface deviceWirelessPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), + interfacePath, + DBUS_PROPERTIES_INTERFACE, QDBusConnection::systemBus(),parent); QList argumentList; @@ -684,31 +554,21 @@ QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(c } QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + interfacePath, QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap))); QDBusPendingReply > reply - = d->connectionInterface->asyncCall(QLatin1String("GetAccessPoints")); + = asyncCall(QLatin1String("GetAccessPoints")); QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(reply); connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(accessPointsFinished(QDBusPendingCallWatcher*))); - - - d->valid = true; } QNetworkManagerInterfaceDeviceWireless::~QNetworkManagerInterfaceDeviceWireless() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerInterfaceDeviceWireless::isValid() -{ - return d->valid; } void QNetworkManagerInterfaceDeviceWireless::slotAccessPointAdded(QDBusObjectPath path) @@ -732,16 +592,16 @@ bool QNetworkManagerInterfaceDeviceWireless::setConnections() bool allOk = true; if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), - QLatin1String("AccessPointAdded"), - this, SLOT(slotAccessPointAdded(QDBusObjectPath)))) { + interfacePath, + QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), + QLatin1String("AccessPointAdded"), + this, SLOT(slotAccessPointAdded(QDBusObjectPath)))) { allOk = false; } if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + interfacePath, QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), QLatin1String("AccessPointRemoved"), this, SLOT(slotAccessPointRemoved(QDBusObjectPath)))) { @@ -749,7 +609,7 @@ bool QNetworkManagerInterfaceDeviceWireless::setConnections() } if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + interfacePath, QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), QLatin1String("ScanDone"), this, SLOT(scanIsDone()))) { @@ -771,17 +631,12 @@ void QNetworkManagerInterfaceDeviceWireless::accessPointsFinished(QDBusPendingCa } } -QDBusInterface *QNetworkManagerInterfaceDeviceWireless::connectionInterface() const -{ - return d->connectionInterface; -} - QList QNetworkManagerInterfaceDeviceWireless::getAccessPoints() { if (accessPointsList.isEmpty()) { //qWarning() << "Using blocking call!"; QDBusReply > reply - = d->connectionInterface->call(QLatin1String("GetAccessPoints")); + = call(QLatin1String("GetAccessPoints")); accessPointsList = reply.value(); } return accessPointsList; @@ -829,7 +684,7 @@ void QNetworkManagerInterfaceDeviceWireless::scanIsDone() void QNetworkManagerInterfaceDeviceWireless::requestScan() { - d->connectionInterface->asyncCall(QLatin1String("RequestScan")); + asyncCall(QLatin1String("RequestScan")); } void QNetworkManagerInterfaceDeviceWireless::propertiesSwap(QMap map) @@ -844,29 +699,17 @@ void QNetworkManagerInterfaceDeviceWireless::propertiesSwap(QMappath = ifaceDevicePath; - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM), - QDBusConnection::systemBus(), parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + ifaceDevicePath, + NM_DBUS_INTERFACE_DEVICE_MODEM, + QDBusConnection::systemBus(), parent) +{ + if (!isValid()) { return; } - QDBusInterface deviceModemPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, + PropertiesDBusInterface deviceModemPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), + ifaceDevicePath, QLatin1String("org.freedesktop.DBus.Properties"), QDBusConnection::systemBus(),parent); @@ -880,36 +723,14 @@ QNetworkManagerInterfaceDeviceModem::QNetworkManagerInterfaceDeviceModem(const Q } QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + ifaceDevicePath, QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap))); - d->valid = true; } QNetworkManagerInterfaceDeviceModem::~QNetworkManagerInterfaceDeviceModem() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerInterfaceDeviceModem::isValid() -{ - - return d->valid; -} - -bool QNetworkManagerInterfaceDeviceModem::setConnections() -{ - if (!isValid() ) - return false; - - return true; -} - -QDBusInterface *QNetworkManagerInterfaceDeviceModem::connectionInterface() const -{ - return d->connectionInterface; } QNetworkManagerInterfaceDeviceModem::ModemCapabilities QNetworkManagerInterfaceDeviceModem::modemCapabilities() const @@ -936,59 +757,39 @@ void QNetworkManagerInterfaceDeviceModem::propertiesSwap(QMap Q_EMIT propertiesChanged(map); } -class QNetworkManagerSettingsPrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - bool valid; -}; QNetworkManagerSettings::QNetworkManagerSettings(const QString &settingsService, QObject *parent) - : QObject(parent) -{ - d = new QNetworkManagerSettingsPrivate(); - d->path = settingsService; - d->connectionInterface = new QDBusInterface(settingsService, - QLatin1String(NM_DBUS_PATH_SETTINGS), - QLatin1String(NM_DBUS_IFACE_SETTINGS), - QDBusConnection::systemBus()); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(settingsService, + NM_DBUS_PATH_SETTINGS, + NM_DBUS_IFACE_SETTINGS, + QDBusConnection::systemBus(), parent) +{ + if (!isValid()) { return; } - + interfacePath = settingsService; QDBusPendingReply > nmReply - = d->connectionInterface->call(QLatin1String("ListConnections")); + = call(QLatin1String("ListConnections")); if (!nmReply.isError()) { connectionsList = nmReply.value(); } - - d->valid = true; } QNetworkManagerSettings::~QNetworkManagerSettings() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerSettings::isValid() -{ - return d->valid; } bool QNetworkManagerSettings::setConnections() { bool allOk = true; - - if (!QDBusConnection::systemBus().connect(d->path, + if (!QDBusConnection::systemBus().connect(interfacePath, QLatin1String(NM_DBUS_PATH_SETTINGS), QLatin1String(NM_DBUS_IFACE_SETTINGS), QLatin1String("NewConnection"), this, SIGNAL(newConnection(QDBusObjectPath)))) { allOk = false; + qWarning() << Q_FUNC_INFO << "NewConnection could not be connected"; } return allOk; @@ -999,7 +800,7 @@ QList QNetworkManagerSettings::listConnections() if (connectionsList.isEmpty()) { //qWarning() << "Using blocking call!"; QDBusReply > reply - = d->connectionInterface->call(QLatin1String("ListConnections")); + = call(QLatin1String("ListConnections")); connectionsList = reply.value(); } return connectionsList; @@ -1010,59 +811,30 @@ QString QNetworkManagerSettings::getConnectionByUuid(const QString &uuid) { QList argumentList; argumentList << QVariant::fromValue(uuid); - QDBusReply reply = d->connectionInterface->callWithArgumentList(QDBus::Block,QLatin1String("GetConnectionByUuid"), argumentList); + QDBusReply reply = callWithArgumentList(QDBus::Block,QLatin1String("GetConnectionByUuid"), argumentList); return reply.value().path(); } -QDBusInterface *QNetworkManagerSettings::connectionInterface() const -{ - return d->connectionInterface; -} - - -class QNetworkManagerSettingsConnectionPrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - QString service; - QNmSettingsMap settingsMap; - bool valid; -}; - QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent) - : QObject(parent) + : QDBusAbstractInterface(settingsService, + connectionObjectPath, + NM_DBUS_IFACE_SETTINGS_CONNECTION, + QDBusConnection::systemBus(), parent) { qDBusRegisterMetaType(); - d = new QNetworkManagerSettingsConnectionPrivate(); - d->path = connectionObjectPath; - d->service = settingsService; - d->connectionInterface = new QDBusInterface(settingsService, - d->path, - QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), - QDBusConnection::systemBus(), parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + if (!isValid()) { return; } - d->valid = true; - + interfacepath = connectionObjectPath; QDBusPendingReply nmReply - = d->connectionInterface->call(QLatin1String("GetSettings")); + = call(QLatin1String("GetSettings")); if (!nmReply.isError()) { - d->settingsMap = nmReply.value(); + settingsMap = nmReply.value(); } } QNetworkManagerSettingsConnection::~QNetworkManagerSettingsConnection() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerSettingsConnection::isValid() -{ - return d->valid; } bool QNetworkManagerSettingsConnection::setConnections() @@ -1072,16 +844,16 @@ bool QNetworkManagerSettingsConnection::setConnections() QDBusConnection dbusConnection = QDBusConnection::systemBus(); bool allOk = true; - if (!dbusConnection.connect(d->service, - d->path, + if (!dbusConnection.connect(service(), + interfacepath, QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Updated"), this, SIGNAL(updated()))) { allOk = false; } - if (!dbusConnection.connect(d->service, - d->path, + if (!dbusConnection.connect(service(), + interfacepath, QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Removed"), this, SIGNAL(slotSettingsRemoved()))) { @@ -1092,28 +864,23 @@ bool QNetworkManagerSettingsConnection::setConnections() void QNetworkManagerSettingsConnection::slotSettingsRemoved() { - Q_EMIT removed(d->path); -} - -QDBusInterface *QNetworkManagerSettingsConnection::connectionInterface() const -{ - return d->connectionInterface; + Q_EMIT removed(interfacepath); } QNmSettingsMap QNetworkManagerSettingsConnection::getSettings() { - if (d->settingsMap.isEmpty()) { + if (settingsMap.isEmpty()) { //qWarning() << "Using blocking call!"; - QDBusReply reply = d->connectionInterface->call(QLatin1String("GetSettings")); - d->settingsMap = reply.value(); + QDBusReply reply = call(QLatin1String("GetSettings")); + settingsMap = reply.value(); } - return d->settingsMap; + return settingsMap; } NMDeviceType QNetworkManagerSettingsConnection::getType() { const QString devType = - d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("type")).toString(); + settingsMap.value(QLatin1String("connection")).value(QLatin1String("type")).toString(); if (devType == QLatin1String("802-3-ethernet")) return DEVICE_TYPE_ETHERNET; @@ -1128,7 +895,7 @@ NMDeviceType QNetworkManagerSettingsConnection::getType() bool QNetworkManagerSettingsConnection::isAutoConnect() { const QVariant autoConnect = - d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("autoconnect")); + settingsMap.value(QLatin1String("connection")).value(QLatin1String("autoconnect")); // NetworkManager default is to auto connect if (!autoConnect.isValid()) @@ -1139,27 +906,27 @@ bool QNetworkManagerSettingsConnection::isAutoConnect() quint64 QNetworkManagerSettingsConnection::getTimestamp() { - return d->settingsMap.value(QLatin1String("connection")) + return settingsMap.value(QLatin1String("connection")) .value(QLatin1String("timestamp")).toUInt(); } QString QNetworkManagerSettingsConnection::getId() { - return d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("id")).toString(); + return settingsMap.value(QLatin1String("connection")).value(QLatin1String("id")).toString(); } QString QNetworkManagerSettingsConnection::getUuid() { - const QString id = d->settingsMap.value(QLatin1String("connection")) + const QString id = settingsMap.value(QLatin1String("connection")) .value(QLatin1String("uuid")).toString(); // is no uuid, return the connection path - return id.isEmpty() ? d->connectionInterface->path() : id; + return id.isEmpty() ? path() : id; } QString QNetworkManagerSettingsConnection::getSsid() { - return d->settingsMap.value(QLatin1String("802-11-wireless")) + return settingsMap.value(QLatin1String("802-11-wireless")) .value(QLatin1String("ssid")).toString(); } @@ -1168,10 +935,10 @@ QString QNetworkManagerSettingsConnection::getMacAddress() NMDeviceType type = getType(); if (type == DEVICE_TYPE_ETHERNET) { - return d->settingsMap.value(QLatin1String("802-3-ethernet")) + return settingsMap.value(QLatin1String("802-3-ethernet")) .value(QLatin1String("mac-address")).toString(); } else if (type == DEVICE_TYPE_WIFI) { - return d->settingsMap.value(QLatin1String("802-11-wireless")) + return settingsMap.value(QLatin1String("802-11-wireless")) .value(QLatin1String("mac-address")).toString(); } else { return QString(); @@ -1181,36 +948,24 @@ QString QNetworkManagerSettingsConnection::getMacAddress() QStringList QNetworkManagerSettingsConnection::getSeenBssids() { if (getType() == DEVICE_TYPE_WIFI) { - return d->settingsMap.value(QLatin1String("802-11-wireless")) + return settingsMap.value(QLatin1String("802-11-wireless")) .value(QLatin1String("seen-bssids")).toStringList(); } else { return QStringList(); } } -class QNetworkManagerConnectionActivePrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - bool valid; -}; - QNetworkManagerConnectionActive::QNetworkManagerConnectionActive(const QString &activeConnectionObjectPath, QObject *parent) - : QObject(parent) -{ - d = new QNetworkManagerConnectionActivePrivate(); - d->path = activeConnectionObjectPath; - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION), - QDBusConnection::systemBus(), parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + activeConnectionObjectPath, + NM_DBUS_INTERFACE_ACTIVE_CONNECTION, + QDBusConnection::systemBus(), parent) +{ + if (!isValid()) { return; } - QDBusInterface connectionActivePropertiesInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, + PropertiesDBusInterface connectionActivePropertiesInterface(QLatin1String(NM_DBUS_SERVICE), + activeConnectionObjectPath, QLatin1String("org.freedesktop.DBus.Properties"), QDBusConnection::systemBus()); @@ -1228,35 +983,14 @@ QNetworkManagerConnectionActive::QNetworkManagerConnectionActive(const QString & } QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + activeConnectionObjectPath, QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap))); - d->valid = true; } QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerConnectionActive::isValid() -{ - return d->valid; -} - -bool QNetworkManagerConnectionActive::setConnections() -{ - if (!isValid()) - return false; - - return true; -} - -QDBusInterface *QNetworkManagerConnectionActive::connectionInterface() const -{ - return d->connectionInterface; } QDBusObjectPath QNetworkManagerConnectionActive::connection() const @@ -1327,44 +1061,24 @@ void QNetworkManagerConnectionActive::propertiesSwap(QMap map) } } -class QNetworkManagerIp4ConfigPrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - bool valid; -}; - QNetworkManagerIp4Config::QNetworkManagerIp4Config( const QString &deviceObjectPath, QObject *parent) - : QObject(parent) -{ - d = new QNetworkManagerIp4ConfigPrivate(); - d->path = deviceObjectPath; - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_IP4_CONFIG), - QDBusConnection::systemBus(), parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + deviceObjectPath, + NM_DBUS_INTERFACE_IP4_CONFIG, + QDBusConnection::systemBus(), parent) +{ + if (!isValid()) { return; } - d->valid = true; } QNetworkManagerIp4Config::~QNetworkManagerIp4Config() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerIp4Config::isValid() -{ - return d->valid; } QStringList QNetworkManagerIp4Config::domains() const { - return d->connectionInterface->property("Domains").toStringList(); + return property("Domains").toStringList(); } QT_END_NAMESPACE diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h index e645159d71..f945532603 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h @@ -55,6 +55,7 @@ #include #include #include +#include #include #ifndef QT_NO_DBUS @@ -128,8 +129,7 @@ Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ServerThing)) QT_BEGIN_NAMESPACE -class QNetworkManagerInterfacePrivate; -class QNetworkManagerInterface : public QObject +class QNetworkManagerInterface : public QDBusAbstractInterface { Q_OBJECT @@ -151,10 +151,9 @@ public: QList getDevices(); void activateConnection(QDBusObjectPath connection,QDBusObjectPath device, QDBusObjectPath specificObject); - void deactivateConnection(QDBusObjectPath connectionPath) const; + void deactivateConnection(QDBusObjectPath connectionPath); QDBusObjectPath path() const; - QDBusInterface *connectionInterface() const; bool wirelessEnabled() const; bool wirelessHardwareEnabled() const; @@ -162,7 +161,6 @@ public: NMState state(); QString version() const; bool setConnections(); - bool isValid(); Q_SIGNALS: void deviceAdded(QDBusObjectPath); @@ -177,14 +175,12 @@ private Q_SLOTS: void propertiesSwap(QMap); private: - QNetworkManagerInterfacePrivate *d; QVariantMap propertyMap; QList devicesPathList; }; -class QNetworkManagerInterfaceAccessPointPrivate; -class QNetworkManagerInterfaceAccessPoint : public QObject +class QNetworkManagerInterfaceAccessPoint : public QDBusAbstractInterface { Q_OBJECT @@ -229,8 +225,6 @@ public: explicit QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = 0); ~QNetworkManagerInterfaceAccessPoint(); - QDBusInterface *connectionInterface() const; - quint32 flags() const; quint32 wpaFlags() const; quint32 rsnFlags() const; @@ -240,8 +234,7 @@ public: quint32 mode() const; quint32 maxBitrate() const; quint32 strength() const; - bool setConnections(); - bool isValid(); + // bool setConnections(); Q_SIGNALS: void propertiesChanged(QMap ); @@ -251,12 +244,10 @@ private Q_SLOTS: void propertiesSwap(QMap); private: - QNetworkManagerInterfaceAccessPointPrivate *d; QVariantMap propertyMap; }; -class QNetworkManagerInterfaceDevicePrivate; -class QNetworkManagerInterfaceDevice : public QObject +class QNetworkManagerInterfaceDevice : public QDBusAbstractInterface { Q_OBJECT @@ -267,14 +258,11 @@ public: QString udi() const; QString networkInterface() const; - QDBusInterface *connectionInterface() const; quint32 ip4Address() const; quint32 state() const; quint32 deviceType() const; QDBusObjectPath ip4config() const; - bool setConnections(); - bool isValid(); Q_SIGNALS: void stateChanged(const QString &, quint32); @@ -284,12 +272,10 @@ Q_SIGNALS: private Q_SLOTS: void propertiesSwap(QMap); private: - QNetworkManagerInterfaceDevicePrivate *d; QVariantMap propertyMap; }; -class QNetworkManagerInterfaceDeviceWiredPrivate; -class QNetworkManagerInterfaceDeviceWired : public QObject +class QNetworkManagerInterfaceDeviceWired : public QDBusAbstractInterface { Q_OBJECT @@ -299,12 +285,9 @@ public: QObject *parent = 0); ~QNetworkManagerInterfaceDeviceWired(); - QDBusInterface *connectionInterface() const; QString hwAddress() const; quint32 speed() const; bool carrier() const; - bool setConnections(); - bool isValid(); QStringList availableConnections(); Q_SIGNALS: @@ -316,12 +299,10 @@ private Q_SLOTS: void propertiesSwap(QMap); private: - QNetworkManagerInterfaceDeviceWiredPrivate *d; QVariantMap propertyMap; }; -class QNetworkManagerInterfaceDeviceWirelessPrivate; -class QNetworkManagerInterfaceDeviceWireless : public QObject +class QNetworkManagerInterfaceDeviceWireless : public QDBusAbstractInterface { Q_OBJECT @@ -343,7 +324,6 @@ public: QDBusObjectPath path() const; QList getAccessPoints(); - QDBusInterface *connectionInterface() const; QString hwAddress() const; quint32 mode() const; @@ -351,7 +331,6 @@ public: QDBusObjectPath activeAccessPoint() const; quint32 wirelessCapabilities() const; bool setConnections(); - bool isValid(); void requestScan(); Q_SIGNALS: @@ -372,13 +351,12 @@ private Q_SLOTS: void accessPointsFinished(QDBusPendingCallWatcher *watcher); private: - QNetworkManagerInterfaceDeviceWirelessPrivate *d; QVariantMap propertyMap; QList accessPointsList; + QString interfacePath; }; -class QNetworkManagerInterfaceDeviceModemPrivate; -class QNetworkManagerInterfaceDeviceModem : public QObject +class QNetworkManagerInterfaceDeviceModem : public QDBusAbstractInterface { Q_OBJECT @@ -397,12 +375,6 @@ public: QObject *parent = 0); ~QNetworkManagerInterfaceDeviceModem(); - QDBusObjectPath path() const; - QDBusInterface *connectionInterface() const; - - bool setConnections(); - bool isValid(); - ModemCapabilities modemCapabilities() const; ModemCapabilities currentCapabilities() const; @@ -414,14 +386,12 @@ private Q_SLOTS: void propertiesSwap(QMap); private: - QNetworkManagerInterfaceDeviceModemPrivate *d; QVariantMap propertyMap; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkManagerInterfaceDeviceModem::ModemCapabilities) -class QNetworkManagerSettingsPrivate; -class QNetworkManagerSettings : public QObject +class QNetworkManagerSettings : public QDBusAbstractInterface { Q_OBJECT @@ -430,22 +400,19 @@ public: explicit QNetworkManagerSettings(const QString &settingsService, QObject *parent = 0); ~QNetworkManagerSettings(); - QDBusInterface *connectionInterface() const; QList listConnections(); QString getConnectionByUuid(const QString &uuid); bool setConnections(); - bool isValid(); Q_SIGNALS: void newConnection(QDBusObjectPath); void connectionsListReady(); private: - QNetworkManagerSettingsPrivate *d; QList connectionsList; + QString interfacePath; }; -class QNetworkManagerSettingsConnectionPrivate; -class QNetworkManagerSettingsConnection : public QObject +class QNetworkManagerSettingsConnection : public QDBusAbstractInterface { Q_OBJECT @@ -454,7 +421,6 @@ public: QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent = 0); ~QNetworkManagerSettingsConnection(); - QDBusInterface *connectionInterface() const; QNmSettingsMap getSettings(); bool setConnections(); NMDeviceType getType(); @@ -465,7 +431,6 @@ public: QString getSsid(); QString getMacAddress(); QStringList getSeenBssids(); - bool isValid(); Q_SIGNALS: void updated(); @@ -474,13 +439,12 @@ Q_SIGNALS: private Q_SLOTS: void slotSettingsRemoved(); - private: - QNetworkManagerSettingsConnectionPrivate *d; + QNmSettingsMap settingsMap; + QString interfacepath; }; -class QNetworkManagerConnectionActivePrivate; -class QNetworkManagerConnectionActive : public QObject +class QNetworkManagerConnectionActive : public QDBusAbstractInterface { Q_OBJECT @@ -495,15 +459,12 @@ public: explicit QNetworkManagerConnectionActive(const QString &dbusPathName, QObject *parent = 0); ~ QNetworkManagerConnectionActive(); - QDBusInterface *connectionInterface() const; QDBusObjectPath connection() const; QDBusObjectPath specificObject() const; QStringList devices() const; quint32 state() const; bool defaultRoute() const; bool default6Route() const; - bool setConnections(); - bool isValid(); Q_SIGNALS: @@ -514,12 +475,10 @@ private Q_SLOTS: void propertiesSwap(QMap); private: - QNetworkManagerConnectionActivePrivate *d; QVariantMap propertyMap; }; -class QNetworkManagerIp4ConfigPrivate; -class QNetworkManagerIp4Config : public QObject +class QNetworkManagerIp4Config : public QDBusAbstractInterface { Q_OBJECT @@ -528,10 +487,17 @@ public: ~QNetworkManagerIp4Config(); QStringList domains() const; - bool isValid(); +}; - private: - QNetworkManagerIp4ConfigPrivate *d; +class PropertiesDBusInterface : public QDBusAbstractInterface +{ +public: + PropertiesDBusInterface(const QString &service, const QString &path, + const QString &interface, const QDBusConnection &connection, + QObject *parent = 0) + : QDBusAbstractInterface(service, path, interface.toLatin1().data(), connection, parent) + {} + ~PropertiesDBusInterface() = default; }; QT_END_NAMESPACE -- cgit v1.2.3 From da6a706eb31f1505edfaeefefc1adfb65ea6d893 Mon Sep 17 00:00:00 2001 From: Ashish Kulkarni Date: Sun, 21 Dec 2014 06:36:24 +0530 Subject: fix error when cross-compiling with --system-zlib This is broken since 1f461ac45bfa8887261510a95fb33a346d68eaba, where Z_PREFIX was defined to namespace the bundled zlib symbols. The bundled zlib is used by bootstrap.pro when cross-compiling which uses the namespaced symbols. This breaks linking of rcc when --system-zlib is used, as it will try to link to compress2 instead of z_compress2. To fix this, the aliases are pulled in via zconf.h and the bundled zlib is prepended to the INCLUDEPATH (i.e. before the system zlib). Change-Id: Iec76cbdead40f888e2ac6a887ec8f3b7bc7db501 Reviewed-by: Oswald Buddenhagen --- src/3rdparty/zlib.pri | 2 +- src/corelib/tools/qbytearray.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty/zlib.pri b/src/3rdparty/zlib.pri index a7073d5c3a..868d1c71bb 100644 --- a/src/3rdparty/zlib.pri +++ b/src/3rdparty/zlib.pri @@ -1,5 +1,5 @@ wince*: DEFINES += NO_ERRNO_H -INCLUDEPATH += $$PWD/zlib +INCLUDEPATH = $$PWD/zlib $$INCLUDEPATH SOURCES+= \ $$PWD/zlib/adler32.c \ $$PWD/zlib/compress.c \ diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index d8b2efbef3..a3c1cc3907 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -43,6 +43,7 @@ #include #ifndef QT_NO_COMPRESS +#include #include #endif #include -- cgit v1.2.3 From e6699afbee77b853773579d29d78a1ade2a4ab2c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 7 Jan 2015 15:19:07 +0100 Subject: Fix physical DPI and size for rotated screens on X11 Rotated screens would use the unrotated physical geometry, causing the calculated physical DPI to be completely wrong. In RandR, the output does not rotate, so the physical size is always for the unrotated display. The transformation is done on the crtc. http://www.x.org/releases/X11R7.6/doc/randrproto/randrproto.txt Task-number: QTBUG-43688 Change-Id: Ifde192fcc99a37d0bfd6d57b4cdeac124a054ca3 Reviewed-by: Friedemann Kleint Reviewed-by: Shawn Rutledge Reviewed-by: Uli Schlachter --- src/plugins/platforms/xcb/qxcbscreen.cpp | 22 +++++++++++++++++++++- src/plugins/platforms/xcb/qxcbscreen.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 8bdedba8ac..73f27c7117 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -53,7 +53,7 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr, , m_screen(scr) , m_crtc(output ? output->crtc : 0) , m_outputName(outputName) - , m_sizeMillimeters(output ? QSize(output->mm_width, output->mm_height) : QSize()) + , m_outputSizeMillimeters(output ? QSize(output->mm_width, output->mm_height) : QSize()) , m_virtualSize(scr->width_in_pixels, scr->height_in_pixels) , m_virtualSizeMillimeters(scr->width_in_millimeters, scr->height_in_millimeters) , m_orientation(Qt::PrimaryOrientation) @@ -71,6 +71,7 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr, updateGeometry(output ? output->timestamp : 0); updateRefreshRate(); + const int dpr = int(devicePixelRatio()); // On VNC, it can be that physical size is unknown while // virtual size is known (probably back-calculated from DPI and resolution) @@ -93,6 +94,7 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr, qDebug(" virtual height.: %lf", m_virtualSizeMillimeters.height()); qDebug(" virtual geom...: %d x %d", m_virtualSize.width(), m_virtualSize.height()); qDebug(" avail virt geom: %d x %d +%d +%d", m_availableGeometry.width(), m_availableGeometry.height(), m_availableGeometry.x(), m_availableGeometry.y()); + qDebug(" orientation....: %d", m_orientation); qDebug(" pixel ratio....: %d", m_devicePixelRatio); qDebug(" depth..........: %d", screen()->root_depth); qDebug(" white pixel....: %x", screen()->white_pixel); @@ -413,6 +415,24 @@ void QXcbScreen::updateGeometry(xcb_timestamp_t timestamp) if (crtc) { xGeometry = QRect(crtc->x, crtc->y, crtc->width, crtc->height); xAvailableGeometry = xGeometry; + switch (crtc->rotation) { + case XCB_RANDR_ROTATION_ROTATE_0: // xrandr --rotate normal + m_orientation = Qt::LandscapeOrientation; + m_sizeMillimeters = m_outputSizeMillimeters; + break; + case XCB_RANDR_ROTATION_ROTATE_90: // xrandr --rotate left + m_orientation = Qt::PortraitOrientation; + m_sizeMillimeters = m_outputSizeMillimeters.transposed(); + break; + case XCB_RANDR_ROTATION_ROTATE_180: // xrandr --rotate inverted + m_orientation = Qt::InvertedLandscapeOrientation; + m_sizeMillimeters = m_outputSizeMillimeters; + break; + case XCB_RANDR_ROTATION_ROTATE_270: // xrandr --rotate right + m_orientation = Qt::InvertedPortraitOrientation; + m_sizeMillimeters = m_outputSizeMillimeters.transposed(); + break; + } free(crtc); } } diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index ca0aee2cc4..b9ee331104 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -111,6 +111,7 @@ private: xcb_screen_t *m_screen; xcb_randr_crtc_t m_crtc; QString m_outputName; + QSizeF m_outputSizeMillimeters; QSizeF m_sizeMillimeters; QRect m_geometry; QRect m_availableGeometry; -- cgit v1.2.3 From d62cd6508a54fbc7950b669c1bc966663d7c10b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 7 Jan 2015 13:44:34 +0100 Subject: iOS: Move implementation details of QIOSViewController to class extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I602d8f1c9f20d3bfed4db3405460021146b546d8 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosviewcontroller.h | 10 ++++------ src/plugins/platforms/ios/qiosviewcontroller.mm | 6 ++++++ 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiosviewcontroller.h b/src/plugins/platforms/ios/qiosviewcontroller.h index 586edd589d..684e06e030 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.h +++ b/src/plugins/platforms/ios/qiosviewcontroller.h @@ -35,15 +35,13 @@ class QIOSScreen; -@interface QIOSViewController : UIViewController { - QIOSScreen *m_screen; -} +@interface QIOSViewController : UIViewController + +- (id)initWithQIOSScreen:(QIOSScreen *)screen; +- (void)updateProperties; -@property (nonatomic, assign) BOOL changingOrientation; @property (nonatomic, assign) BOOL prefersStatusBarHidden; @property (nonatomic, assign) UIStatusBarAnimation preferredStatusBarUpdateAnimation; -- (id)initWithQIOSScreen:(QIOSScreen *)screen; -- (void)updateProperties; @end diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index f678f7e807..8f59d41509 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -119,6 +119,12 @@ // ------------------------------------------------------------------------- +@interface QIOSViewController () { + QIOSScreen *m_screen; +} +@property (nonatomic, assign) BOOL changingOrientation; +@end + @implementation QIOSViewController - (id)initWithQIOSScreen:(QIOSScreen *)screen -- cgit v1.2.3 From 5c5f43e95b8f56d2bdf34cf5c11aae9d5102f9c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Thu, 8 Jan 2015 11:31:27 +0000 Subject: docs: Explain the limitations of QWidget::grabMouse() on Windows Because carbon is dead, I merged both OSX and Windows in the same note. Change-Id: I5d43c5fce30e187f63a1e3e5af688c344eb80d28 Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qwidget.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index c362530264..c99e15b9b8 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -12392,10 +12392,9 @@ static void releaseMouseGrabOfWidget(QWidget *widget) \note Only visible widgets can grab mouse input. If isVisible() returns \c false for a widget, that widget cannot call grabMouse(). - \note \b{(Mac OS X developers)} For \e Cocoa, calling - grabMouse() on a widget only works when the mouse is inside the - frame of that widget. For \e Carbon, it works outside the widget's - frame as well, like for Windows and X11. + \note On Windows, grabMouse() only works when the mouse is inside a window + owned by the process. + On OS X, grabMouse() only works when the mouse is inside the frame of that widget. \sa releaseMouse(), grabKeyboard(), releaseKeyboard() */ @@ -12416,7 +12415,7 @@ void QWidget::grabMouse() \warning Grabbing the mouse might lock the terminal. - \note \b{(Mac OS X developers)} See the note in QWidget::grabMouse(). + \note See the note in QWidget::grabMouse(). \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor() */ -- cgit v1.2.3 From 95cb745e002c38e821b385e90d954adf73363e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 11 Dec 2013 14:37:19 +0100 Subject: iOS: Fix QWindow::reportContentOrientationChange on iOS6+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On iOS 6 and above, [UIViewController supportedInterfaceOrientations] needs to return 0 for [UIApplication setStatusBarOrientation] to work. This means once you report a content orientation other than the primary orientation, you'll disable auto-rotation. Reporting the orientation as Qt::PrimaryOrientation restores the auto-rotation behavior. Change-Id: I1b8c765c507728fdbc5b828e0b4215324014e221 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosscreen.mm | 17 +++++ src/plugins/platforms/ios/qiosviewcontroller.h | 4 ++ src/plugins/platforms/ios/qiosviewcontroller.mm | 93 +++++++++++++++++++++---- src/plugins/platforms/ios/qioswindow.mm | 19 +++-- 4 files changed, 116 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index 4af2a4965f..712bf0098b 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -46,6 +46,7 @@ #include #include "qiosapplicationdelegate.h" #include "qiosviewcontroller.h" +#include "quiview.h" #include @@ -244,6 +245,22 @@ void QIOSScreen::updateProperties() m_geometry = fromCGRect([rootView convertRect:m_uiScreen.bounds fromView:m_uiWindow]).toRect(); m_availableGeometry = fromCGRect([rootView convertRect:m_uiScreen.applicationFrame fromView:m_uiWindow]).toRect(); + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_8_0 && ![m_uiWindow.rootViewController shouldAutorotate]) { + // Setting the statusbar orientation (content orientation) on iOS8+ will result in the UIScreen + // updating its geometry and available geometry, which in the case of content orientation is not + // what we want. We want to reflect the screen geometry based on the locked orientation, and + // adjust the available geometry based on the repositioned status bar for the current status + // bar orientation. + + Qt::ScreenOrientation lockedOrientation = toQtScreenOrientation(UIDeviceOrientation(rootView.qtViewController.lockedOrientation)); + Qt::ScreenOrientation contenOrientation = toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation)); + + QTransform transform = screen()->transformBetween(lockedOrientation, contenOrientation, m_geometry).inverted(); + + m_geometry = transform.mapRect(m_geometry); + m_availableGeometry = transform.mapRect(m_availableGeometry); + } + if (m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry) { const qreal millimetersPerInch = 25.4; m_physicalSize = QSizeF(m_geometry.size()) / m_unscaledDpi * millimetersPerInch; diff --git a/src/plugins/platforms/ios/qiosviewcontroller.h b/src/plugins/platforms/ios/qiosviewcontroller.h index 684e06e030..df7ce0ff4a 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.h +++ b/src/plugins/platforms/ios/qiosviewcontroller.h @@ -40,6 +40,10 @@ class QIOSScreen; - (id)initWithQIOSScreen:(QIOSScreen *)screen; - (void)updateProperties; +@property (nonatomic, assign) UIInterfaceOrientation lockedOrientation; + +// UIViewController +@property (nonatomic, assign) BOOL shouldAutorotate; @property (nonatomic, assign) BOOL prefersStatusBarHidden; @property (nonatomic, assign) UIStatusBarAnimation preferredStatusBarUpdateAnimation; diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index 8f59d41509..0afd2bf8ba 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -153,6 +153,7 @@ #endif self.changingOrientation = NO; + self.shouldAutorotate = [super shouldAutorotate]; // Status bar may be initially hidden at startup through Info.plist self.prefersStatusBarHidden = infoPlistValue(@"UIStatusBarHidden", false); @@ -179,6 +180,10 @@ [center addObserver:self selector:@selector(willChangeStatusBarFrame:) name:UIApplicationWillChangeStatusBarFrameNotification object:[UIApplication sharedApplication]]; + + [center addObserver:self selector:@selector(didChangeStatusBarOrientation:) + name:UIApplicationDidChangeStatusBarOrientationNotification + object:[UIApplication sharedApplication]]; } - (void)viewDidUnload @@ -189,19 +194,16 @@ // ------------------------------------------------------------------------- --(BOOL)shouldAutorotate -{ - // Until a proper orientation and rotation API is in place, we always auto rotate. - // If auto rotation is not wanted, you would need to switch it off manually from Info.plist. - return YES; -} - #if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_6_0) -(NSUInteger)supportedInterfaceOrientations { - // We need to tell iOS that we support all orientations in order to set - // status bar orientation when application content orientation changes. - return UIInterfaceOrientationMaskAll; + // As documented by Apple in the iOS 6.0 release notes, setStatusBarOrientation:animated: + // only works if the supportedInterfaceOrientations of the view controller is 0, making + // us responsible for ensuring that the status bar orientation is consistent. We enter + // this mode when auto-rotation is disabled due to an explicit content orientation being + // set on the focus window. Note that this is counter to what the documentation for + // supportedInterfaceOrientations says, which states that the method should not return 0. + return [self shouldAutorotate] ? UIInterfaceOrientationMaskAll : 0; } #endif @@ -209,7 +211,7 @@ -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { Q_UNUSED(interfaceOrientation); - return YES; + return [self shouldAutorotate]; } #endif @@ -256,6 +258,22 @@ }]; } +- (void)didChangeStatusBarOrientation:(NSNotification *)notification +{ + Q_UNUSED(notification); + + if (self.view.window.screen != [UIScreen mainScreen]) + return; + + // If the statusbar changes orientation due to auto-rotation we don't care, + // there will be re-layout anyways. Only if the statusbar changes due to + // reportContentOrientation, we need to update the window layout. + if (self.changingOrientation) + return; + + [self.view setNeedsLayout]; +} + - (void)viewWillLayoutSubviews { if (!QCoreApplication::instance()) @@ -287,6 +305,8 @@ // All decisions are based on the the top level window focusWindow = qt_window_private(focusWindow)->topLevelWindow(); + UIApplication *uiApplication = [UIApplication sharedApplication]; + bool currentStatusBarVisibility = self.prefersStatusBarHidden; self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen; @@ -297,13 +317,60 @@ } else #endif { - [[UIApplication sharedApplication] - setStatusBarHidden:self.prefersStatusBarHidden + [uiApplication setStatusBarHidden:self.prefersStatusBarHidden withAnimation:self.preferredStatusBarUpdateAnimation]; } [self.view setNeedsLayout]; } + + + // -------------- Content orientation --------------- + + static BOOL kAnimateContentOrientationChanges = YES; + + Qt::ScreenOrientation contentOrientation = focusWindow->contentOrientation(); + if (contentOrientation != Qt::PrimaryOrientation) { + // An explicit content orientation has been reported for the focus window, + // so we keep the status bar in sync with content orientation. This will ensure + // that the task bar (and associated gestures) are also rotated accordingly. + + if (self.shouldAutorotate) { + // We are moving from Qt::PrimaryOrientation to an explicit orientation, + // so we need to store the current statusbar orientation, as we need it + // later when mapping screen coordinates for QScreen and for returning + // to Qt::PrimaryOrientation. + self.lockedOrientation = uiApplication.statusBarOrientation; + + // Calling setStatusBarOrientation only has an effect when auto-rotation is + // disabled, which makes sense when there's an explicit content orientation. + self.shouldAutorotate = NO; + } + + [uiApplication setStatusBarOrientation: + UIInterfaceOrientation(fromQtScreenOrientation(contentOrientation)) + animated:kAnimateContentOrientationChanges]; + + } else { + // The content orientation is set to Qt::PrimaryOrientation, meaning + // that auto-rotation should be enabled. But we may be coming out of + // a state of locked orientation, which needs some cleanup before we + // can enable auto-rotation again. + if (!self.shouldAutorotate) { + // First we need to restore the statusbar to what it was at the + // time of locking the orientation, otherwise iOS will be very + // confused when it starts doing auto-rotation again. + [uiApplication setStatusBarOrientation: + UIInterfaceOrientation(self.lockedOrientation) + animated:kAnimateContentOrientationChanges]; + + // Then we can re-enable auto-rotation + self.shouldAutorotate = YES; + + // And finally let iOS rotate the root view to match the device orientation + [UIViewController attemptRotationToDeviceOrientation]; + } + } } #if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0) diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 480062e4de..6c4614408d 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -75,6 +75,15 @@ QIOSWindow::QIOSWindow(QWindow *window) setWindowState(window->windowState()); setOpacity(window->opacity()); + + Qt::ScreenOrientation initialOrientation = window->contentOrientation(); + if (initialOrientation != Qt::PrimaryOrientation) { + // Start up in portrait, then apply possible content orientation, + // as per Apple's documentation. + dispatch_async(dispatch_get_main_queue(), ^{ + handleContentOrientationChange(initialOrientation); + }); + } } QIOSWindow::~QIOSWindow() @@ -322,10 +331,12 @@ void QIOSWindow::updateWindowLevel() void QIOSWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation) { - // Keep the status bar in sync with content orientation. This will ensure - // that the task bar (and associated gestures) are aligned correctly: - UIInterfaceOrientation uiOrientation = UIInterfaceOrientation(fromQtScreenOrientation(orientation)); - [[UIApplication sharedApplication] setStatusBarOrientation:uiOrientation animated:NO]; + // Update the QWindow representation straight away, so that + // we can update the statusbar orientation based on the new + // content orientation. + qt_window_private(window())->contentOrientation = orientation; + + [m_view.qtViewController updateProperties]; } void QIOSWindow::applicationStateChanged(Qt::ApplicationState) -- cgit v1.2.3 From 56a82e87e654fa9e77bee8956e94e08a77941e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 7 Jan 2015 15:14:17 +0100 Subject: iOS: Prevent recursion when updating/syncing QIOSViewController properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I22f1eaa892cba23c498ae210a9a483e468268581 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosviewcontroller.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index 0afd2bf8ba..01bc84ae68 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -41,6 +41,8 @@ #import "qiosviewcontroller.h" +#include + #include #include #include @@ -121,6 +123,7 @@ @interface QIOSViewController () { QIOSScreen *m_screen; + BOOL m_updatingProperties; } @property (nonatomic, assign) BOOL changingOrientation; @end @@ -289,6 +292,15 @@ if (!isQtApplication()) return; + // Prevent recursion caused by updating the status bar appearance (position + // or visibility), which in turn may cause a layout of our subviews, and + // a reset of window-states, which themselves affect the view controller + // properties such as the statusbar visibilty. + if (m_updatingProperties) + return; + + QScopedValueRollback updateRollback(m_updatingProperties, YES); + QWindow *focusWindow = QGuiApplication::focusWindow(); // If we don't have a focus window we leave the statusbar -- cgit v1.2.3 From 8f095d67a0a28d28b463e80a398041989ccdeb88 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 9 Dec 2014 17:04:38 +0100 Subject: Fix glyph runs painted badly with perspective transform MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A mismatch between requiresPretransformedGlyphPositions and shouldDrawCachedGlyphs in QRasterPaintEngine will cause the text position to be transformed twice when using drawGlyphRun on a QPainter with a perspective transform. Since this case falls back to drawing text as paths there is no reason to require any special treatment. Change-Id: Ib1c14aee4cc6774dd8feadc5748f0b0ee59633b9 Reviewed-by: Tor Arne Vestbø Reviewed-by: Gunnar Sletta --- src/gui/painting/qpaintengineex.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 0c3ea37b29..f5e6f7cca6 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -1075,9 +1075,9 @@ void QPaintEngineEx::drawStaticTextItem(QStaticTextItem *staticTextItem) } } -bool QPaintEngineEx::requiresPretransformedGlyphPositions(QFontEngine *, const QTransform &t) const +bool QPaintEngineEx::requiresPretransformedGlyphPositions(QFontEngine *, const QTransform &) const { - return t.type() >= QTransform::TxProject; + return false; } bool QPaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const -- cgit v1.2.3 From 6e217f067800541ccb9596cf03d52093b2909385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Tue, 6 Jan 2015 18:13:27 +0000 Subject: QColorDialog: Don't loose focus while color picking On Windows mouse grabbing doesn't work across processes, which means we're interacting with other windows when picking colors. Workaround that by having a transparent 1x1 window below the cursor at all times so we catch the mouse click. Clicking before the window is below the cursor won't happen because our timer interval is 30ms, so it's quite fast. It's hacky but it's what we can do for a feature which was very broken on Windows. Task-number: QTBUG-43663 Change-Id: I295378e033ddc6d9c2230335f0953a727c21e1dd Reviewed-by: Friedemann Kleint --- src/widgets/dialogs/qcolordialog.cpp | 24 +++++++++++++++++++----- src/widgets/dialogs/qcolordialog_p.h | 6 ++++-- 2 files changed, 23 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 882bb999fb..b133c49b5e 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -1579,12 +1579,17 @@ void QColorDialogPrivate::_q_pickScreenColor() q->grabMouse(); #endif -#ifdef Q_OS_WIN +#ifdef Q_OS_WIN32 // excludes WinCE and WinRT // On Windows mouse tracking doesn't work over other processes's windows updateTimer->start(30); + + // HACK: Because mouse grabbing doesn't work across processes, we have to have a dummy, + // invisible window to catch the mouse click, otherwise we will click whatever we clicked + // and loose focus. + dummyTransparentWindow.show(); #endif q->grabKeyboard(); - /* With setMouseTracking(true) the desired color can be more precisedly picked up, + /* With setMouseTracking(true) the desired color can be more precisely picked up, * and continuously pushing the mouse button is not necessary. */ q->setMouseTracking(true); @@ -1606,8 +1611,9 @@ void QColorDialogPrivate::releaseColorPicking() cp->setCrossVisible(true); q->removeEventFilter(colorPickingEventFilter); q->releaseMouse(); -#ifdef Q_OS_WIN +#ifdef Q_OS_WIN32 updateTimer->stop(); + dummyTransparentWindow.setVisible(false); #endif q->releaseKeyboard(); q->setMouseTracking(false); @@ -1635,6 +1641,10 @@ void QColorDialogPrivate::init(const QColor &initial) #ifdef Q_WS_MAC delegate = 0; #endif +#ifdef Q_OS_WIN32 + dummyTransparentWindow.resize(1, 1); + dummyTransparentWindow.setFlags(Qt::Tool | Qt::FramelessWindowHint); +#endif q->setCurrentColor(initial); } @@ -1791,7 +1801,7 @@ void QColorDialogPrivate::initWidgets() cancel = buttons->addButton(QDialogButtonBox::Cancel); QObject::connect(cancel, SIGNAL(clicked()), q, SLOT(reject())); -#ifdef Q_OS_WIN +#ifdef Q_OS_WIN32 updateTimer = new QTimer(q); QObject::connect(updateTimer, SIGNAL(timeout()), q, SLOT(_q_updateColorPicking())); #endif @@ -2219,8 +2229,12 @@ void QColorDialogPrivate::_q_updateColorPicking() return; lastGlobalPos = newGlobalPos; - if (!q->rect().contains(q->mapFromGlobal(newGlobalPos))) // Inside the dialog mouse tracking works, handleColorPickingMouseMove will be called + if (!q->rect().contains(q->mapFromGlobal(newGlobalPos))) { // Inside the dialog mouse tracking works, handleColorPickingMouseMove will be called updateColorPicking(newGlobalPos); +#ifdef Q_OS_WIN32 + dummyTransparentWindow.setPosition(newGlobalPos); +#endif + } #endif // ! QT_NO_CURSOR } diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h index 2b501522f5..9182b510f1 100644 --- a/src/widgets/dialogs/qcolordialog_p.h +++ b/src/widgets/dialogs/qcolordialog_p.h @@ -49,6 +49,7 @@ #include "private/qdialog_p.h" #include "qcolordialog.h" #include "qsharedpointer.h" +#include "qwindow.h" #ifndef QT_NO_COLORDIALOG @@ -77,7 +78,7 @@ public: }; QColorDialogPrivate() : options(new QColorDialogOptions) -#ifdef Q_OS_WIN +#ifdef Q_OS_WIN32 , updateTimer(0) #endif {} @@ -143,8 +144,9 @@ public: QPointer receiverToDisconnectOnClose; QByteArray memberToDisconnectOnClose; -#ifdef Q_OS_WIN +#ifdef Q_OS_WIN32 QTimer *updateTimer; + QWindow dummyTransparentWindow; #endif #ifdef Q_WS_MAC -- cgit v1.2.3 From 26547c0275a25d19ddbc53edd71b277f71c4de59 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 1 Dec 2014 19:17:05 +0100 Subject: remove nonsensical conditional we are in an #else of #ifndef QT_BOOTSTRAPPED here already. Change-Id: I02c4ff2959490110c21ad1016c664b7ddcfea7c0 Reviewed-by: Thiago Macieira --- src/corelib/global/qlibraryinfo.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 7ca0aa7f0b..1f8de2e05d 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -128,9 +128,7 @@ QLibrarySettings::QLibrarySettings() settings.reset(0); #else } else { -#ifdef QT_BOOTSTRAPPED haveEffectiveSourcePaths = false; -#endif haveEffectivePaths = false; havePaths = false; #endif -- cgit v1.2.3 From 44f8f2084b36960fd5e04636604b2e3416e8c947 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 1 Dec 2014 19:19:05 +0100 Subject: de-duplicate and comment EffectivePaths presence detection Change-Id: Ibf9731c216df84c9e17ebd699d8349cc716ff3cc Reviewed-by: Thiago Macieira --- src/corelib/global/qlibraryinfo.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 1f8de2e05d..4f9f54cde8 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -116,10 +116,11 @@ QLibrarySettings::QLibrarySettings() QStringList children = settings->childGroups(); #ifdef QT_BOOTSTRAPPED haveEffectiveSourcePaths = children.contains(QLatin1String("EffectiveSourcePaths")); - haveEffectivePaths = haveEffectiveSourcePaths || children.contains(QLatin1String("EffectivePaths")); #else - haveEffectivePaths = children.contains(QLatin1String("EffectivePaths")); + // EffectiveSourcePaths is for the Qt build only, so needs no backwards compat trickery. + bool haveEffectiveSourcePaths = false; #endif + haveEffectivePaths = haveEffectiveSourcePaths || children.contains(QLatin1String("EffectivePaths")); // Backwards compat: an existing but empty file is claimed to contain the Paths section. havePaths = (!haveEffectivePaths && !children.contains(QLatin1String(platformsSection))) || children.contains(QLatin1String("Paths")); -- cgit v1.2.3 From b25cfdce468c59305113b06c31473cbfaec1c139 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 7 Jan 2015 14:20:34 -0800 Subject: Fix compilation with MSVC 2010 2013 and 2015 compile this fine. I didn't test 2012. I wouldn't have fixed if the objective weren't to enable QtDBus by default on all architectures: since it is, we can't have Qt fail to compile from sources on MSVC 2010. qdbus_symbols.cpp(92) : fatal error C1001: An internal error has occurred in the compiler Change-Id: I42b930bc37c4e478a66725d83c8a73836fbf567c Reviewed-by: Friedemann Kleint Reviewed-by: Simon Hausmann --- src/dbus/qdbus_symbols.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp index e475a23f48..67643098d9 100644 --- a/src/dbus/qdbus_symbols.cpp +++ b/src/dbus/qdbus_symbols.cpp @@ -86,9 +86,9 @@ bool qdbus_loadLibDBus() static int majorversions[] = { 3, 2, -1 }; const QString baseNames[] = { #ifdef Q_OS_WIN - QStringLiteral("dbus-1"), + QLatin1String("dbus-1"), #endif - QStringLiteral("libdbus-1") + QLatin1String("libdbus-1") }; lib->unload(); -- cgit v1.2.3 From 05d39ec9c0428696d3d523e6b024df59d456fc59 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 24 Dec 2014 12:28:38 -0200 Subject: Optimize QHostAddress::operator== for SpecialAddress There's no need to allocate memory for the special address. Change-Id: I5f3760565807731ab595e91fc934c21d10df212a Reviewed-by: Richard J. Moore --- src/network/kernel/qhostaddress.cpp | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 10fdf2f97d..b68f6adfff 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -778,18 +778,34 @@ bool QHostAddress::operator==(const QHostAddress &other) const bool QHostAddress::operator ==(SpecialAddress other) const { QT_ENSURE_PARSED(this); - QHostAddress otherAddress(other); - QT_ENSURE_PARSED(&otherAddress); + switch (other) { + case Null: + return d->protocol == QAbstractSocket::UnknownNetworkLayerProtocol; - if (d->protocol == QAbstractSocket::IPv4Protocol) - return otherAddress.d->protocol == QAbstractSocket::IPv4Protocol && d->a == otherAddress.d->a; - if (d->protocol == QAbstractSocket::IPv6Protocol) { - return otherAddress.d->protocol == QAbstractSocket::IPv6Protocol - && memcmp(&d->a6, &otherAddress.d->a6, sizeof(Q_IPV6ADDR)) == 0; + case Broadcast: + return d->protocol == QAbstractSocket::IPv4Protocol && d->a == INADDR_BROADCAST; + + case LocalHost: + return d->protocol == QAbstractSocket::IPv4Protocol && d->a == INADDR_LOOPBACK; + + case Any: + return d->protocol == QAbstractSocket::AnyIPProtocol; + + case AnyIPv4: + return d->protocol == QAbstractSocket::IPv4Protocol && d->a == INADDR_ANY; + + case LocalHostIPv6: + case AnyIPv6: + if (d->protocol == QAbstractSocket::IPv6Protocol) { + Q_IPV6ADDR ip6 = { { 0 } }; + ip6[15] = quint8(other == LocalHostIPv6); // 1 for localhost, 0 for any + return memcmp(&d->a6, &ip6, sizeof ip6) == 0; + } + return false; } - if (d->protocol == QAbstractSocket::AnyIPProtocol) - return other == QHostAddress::Any; - return int(other) == int(Null); + + Q_UNREACHABLE(); + return false; } /*! -- cgit v1.2.3 From a0737f65a62a5d72f15f5f1196b86f16605d936b Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 8 Jan 2015 17:11:43 +0200 Subject: Fixes for surface creation/destruction - After reset a surface we must call makeCurrent before we are usign swapBuffers. - No need to set the surface in QPA when surfaceCreated are called in QtSurface.java, some time the OpenGL surface is not fully initialized at this stage. Is better to wait for surfaceChanged which is always fired at least once. - DO NOT reset m_surfaceId to 1 when there is no surface. The problem is that if we have one surface and when we distory it we don't (need to) wait for its surfaceChanged/surfaceDestroyed notifications, and if we create another one quicly it will have the same id (1). Task-number: QTBUG-39712 Change-Id: I2aa31e5b59d81ef3b03624d4636a4381eea6d543 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../jar/src/org/qtproject/qt5/android/QtSurface.java | 2 -- src/plugins/platforms/android/androidjnimain.cpp | 2 -- .../android/qandroidplatformopenglcontext.cpp | 6 ++++-- .../android/qandroidplatformopenglwindow.cpp | 20 ++++++++++++-------- .../platforms/android/qandroidplatformopenglwindow.h | 4 ++-- .../platforms/android/qandroidplatformscreen.cpp | 2 +- 6 files changed, 19 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java b/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java index 34fc31b222..516671739e 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java @@ -45,7 +45,6 @@ package org.qtproject.qt5.android; import android.app.Activity; import android.content.Context; import android.graphics.PixelFormat; -import android.util.Log; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.SurfaceHolder; @@ -87,7 +86,6 @@ public class QtSurface extends SurfaceView implements SurfaceHolder.Callback @Override public void surfaceCreated(SurfaceHolder holder) { - QtNative.setSurface(getId(), holder.getSurface(), getWidth(), getHeight()); } @Override diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index d1e78dfe5d..1c157c79c3 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -376,8 +376,6 @@ namespace QtAndroid const auto &it = m_surfaces.find(surfaceId); if (it != m_surfaces.end()) m_surfaces.remove(surfaceId); - if (m_surfaces.isEmpty()) - m_surfaceId = 1; QJNIEnvironmentPrivate env; if (!env) diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp index 5781f0d7c6..4c38178343 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp +++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp @@ -50,8 +50,10 @@ QAndroidPlatformOpenGLContext::QAndroidPlatformOpenGLContext(const QSurfaceForma void QAndroidPlatformOpenGLContext::swapBuffers(QPlatformSurface *surface) { - if (surface->surface()->surfaceClass() == QSurface::Window) - static_cast(surface)->checkNativeSurface(eglConfig()); + if (surface->surface()->surfaceClass() == QSurface::Window && + static_cast(surface)->checkNativeSurface(eglConfig())) { + QEGLPlatformContext::makeCurrent(surface); + } QEGLPlatformContext::swapBuffers(surface); } diff --git a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp index 8dc8e84f0a..de7f1f6990 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp @@ -138,19 +138,19 @@ EGLSurface QAndroidPlatformOpenGLWindow::eglSurface(EGLConfig config) return m_eglSurface; } -void QAndroidPlatformOpenGLWindow::checkNativeSurface(EGLConfig config) +bool QAndroidPlatformOpenGLWindow::checkNativeSurface(EGLConfig config) { QMutexLocker lock(&m_surfaceMutex); if (m_nativeSurfaceId == -1 || !m_androidSurfaceObject.isValid()) - return; + return false; // makeCurrent is NOT needed. createEgl(config); - // we've create another surface, the window should be repainted QRect availableGeometry = screen()->availableGeometry(); if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0) QWindowSystemInterface::handleExposeEvent(window(), QRegion(QRect(QPoint(), geometry().size()))); + return true; // makeCurrent is needed! } void QAndroidPlatformOpenGLWindow::applicationStateChanged(Qt::ApplicationState state) @@ -209,15 +209,19 @@ void QAndroidPlatformOpenGLWindow::surfaceChanged(JNIEnv *jniEnv, jobject surfac Q_UNUSED(jniEnv); Q_UNUSED(w); Q_UNUSED(h); + lockSurface(); m_androidSurfaceObject = surface; - m_surfaceWaitCondition.wakeOne(); + if (surface) // wait until we have a valid surface to draw into + m_surfaceWaitCondition.wakeOne(); unlockSurface(); - // repaint the window - QRect availableGeometry = screen()->availableGeometry(); - if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0) - QWindowSystemInterface::handleExposeEvent(window(), QRegion(QRect(QPoint(), geometry().size()))); + if (surface) { + // repaint the window, when we have a valid surface + QRect availableGeometry = screen()->availableGeometry(); + if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0) + QWindowSystemInterface::handleExposeEvent(window(), QRegion(QRect(QPoint(), geometry().size()))); + } } QT_END_NAMESPACE diff --git a/src/plugins/platforms/android/qandroidplatformopenglwindow.h b/src/plugins/platforms/android/qandroidplatformopenglwindow.h index 71787edee1..6d6548fc6a 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglwindow.h +++ b/src/plugins/platforms/android/qandroidplatformopenglwindow.h @@ -54,7 +54,7 @@ public: EGLSurface eglSurface(EGLConfig config); QSurfaceFormat format() const; - void checkNativeSurface(EGLConfig config); + bool checkNativeSurface(EGLConfig config); void applicationStateChanged(Qt::ApplicationState); @@ -66,7 +66,7 @@ protected: void clearEgl(); private: - EGLDisplay m_eglDisplay; + EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; EGLSurface m_eglSurface = EGL_NO_SURFACE; EGLNativeWindowType m_nativeWindow = nullptr; diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp index b70f936be1..092ade2e4a 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.cpp +++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp @@ -391,7 +391,7 @@ Qt::ScreenOrientation QAndroidPlatformScreen::nativeOrientation() const void QAndroidPlatformScreen::surfaceChanged(JNIEnv *env, jobject surface, int w, int h) { lockSurface(); - if (surface && w && h) { + if (surface && w > 0 && h > 0) { releaseSurface(); m_nativeSurface = ANativeWindow_fromSurface(env, surface); QMetaObject::invokeMethod(this, "setDirty", Qt::QueuedConnection, Q_ARG(QRect, QRect(0, 0, w, h))); -- cgit v1.2.3 From 2924279c235e9cb12b58b0f3ae0b139f8ac5ac2c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 24 Dec 2014 16:29:30 -0200 Subject: Don't unnecessariy set localAddress in QNativeSocketEngine's nativeBind The outer QNativeSocketEngine::bind() function will call fetchConnectionParameters() as soon as nativeBind() returns, so don't bother copying localAddress. Change-Id: Ice13e507ccb9c575a7d3bdf0b41394f35230b746 Reviewed-by: Richard J. Moore --- src/network/socket/qnativesocketengine_unix.cpp | 3 --- src/network/socket/qnativesocketengine_win.cpp | 3 --- 2 files changed, 6 deletions(-) (limited to 'src') diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index ad170e187c..eed1b70025 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -567,9 +567,6 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &address, quint16 return false; } - localPort = port; - localAddress = address; - #if defined (QNATIVESOCKETENGINE_DEBUG) qDebug("QNativeSocketEnginePrivate::nativeBind(%s, %i) == true", address.toString().toLatin1().constData(), port); diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index f5943d657f..184add15c3 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -852,9 +852,6 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &a, quint16 port) return false; } - localPort = port; - localAddress = address; - #if defined (QNATIVESOCKETENGINE_DEBUG) qDebug("QNativeSocketEnginePrivate::nativeBind(%s, %i) == true", address.toString().toLatin1().constData(), port); -- cgit v1.2.3 From fb166648936410f791ae6e600756d255b4a50545 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 1 Jan 2015 22:06:18 -0200 Subject: Fix memory leaks with QDBusServer Two serious mistakes: - we need to call dbus_server_free_data_slot as many times as we call dbus_server_allocate_data_slot - we need to delete the d pointer... The changes to the unit tests are simply to cause the used peer connections to be removed so they don't show up in valgrind. Change-Id: I9fd1ada5503db9ba481806c09116874ee81f450d Reviewed-by: Alex Blasche --- src/dbus/qdbus_symbols_p.h | 2 ++ src/dbus/qdbusintegrator.cpp | 9 ++++++--- src/dbus/qdbusserver.cpp | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/dbus/qdbus_symbols_p.h b/src/dbus/qdbus_symbols_p.h index 0785fea4b4..4bec3af490 100644 --- a/src/dbus/qdbus_symbols_p.h +++ b/src/dbus/qdbus_symbols_p.h @@ -323,6 +323,8 @@ DEFINEFUNC(void , dbus_pending_call_unref, (DBusPendingCall /* dbus-server.h */ DEFINEFUNC(dbus_bool_t , dbus_server_allocate_data_slot, (dbus_int32_t *slot_p), (slot_p), return) +DEFINEFUNC(void , dbus_server_free_data_slot, (dbus_int32_t *slot_p), + (slot_p), return) DEFINEFUNC(void , dbus_server_disconnect, (DBusServer *server), (server), ) DEFINEFUNC(char* , dbus_server_get_address, (DBusServer *server), diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index dd92602dce..698fb1b46c 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -66,6 +66,9 @@ QT_BEGIN_NAMESPACE +// used with dbus_server_allocate_data_slot +static dbus_int32_t server_slot = -1; + static QBasicAtomicInt isDebugging = Q_BASIC_ATOMIC_INITIALIZER(-1); #define qDBusDebug if (::isDebugging == 0); else qDebug @@ -1084,8 +1087,10 @@ void QDBusConnectionPrivate::closeConnection() mode = InvalidMode; // prevent reentrancy baseService.clear(); - if (server) + if (server) { q_dbus_server_disconnect(server); + q_dbus_server_free_data_slot(&server_slot); + } if (oldMode == ClientMode || oldMode == PeerMode) { if (connection) { @@ -1651,8 +1656,6 @@ void QDBusConnectionPrivate::handleSignal(const QDBusMessage& msg) handleSignal(key, msg); // third try } -static dbus_int32_t server_slot = -1; - void QDBusConnectionPrivate::setServer(DBusServer *s, const QDBusErrorInternal &error) { mode = ServerMode; diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp index b2c76a8750..3fec7c9111 100644 --- a/src/dbus/qdbusserver.cpp +++ b/src/dbus/qdbusserver.cpp @@ -110,6 +110,7 @@ QDBusServer::~QDBusServer() } d->serverConnectionNames.clear(); } + d->deleteLater(); } /*! -- cgit v1.2.3 From 3ba1b989a6c7e22e8f0b92c59c5bbb52cdcab638 Mon Sep 17 00:00:00 2001 From: Tomasz Olszak Date: Fri, 9 Jan 2015 22:20:02 +0100 Subject: xcb: build fix when XCB_USE_XLIB is not defined. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When XCB_USE_XLIB was not defined QXcbXSettings still used XIproto.h. This change removes XIProto.h dependency and leaves QXcbXSettings uninitialized when XCB_USE_XLIB is not defined. QXcbXSettings::initialize() is already used in other parts of code e.g. qxcbcursor.cpp. Change-Id: I48eb82e39c5c091b41e8ec19e742a21d41de2610 Reviewed-by: Jørgen Lind --- src/plugins/platforms/xcb/qxcbxsettings.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbxsettings.cpp b/src/plugins/platforms/xcb/qxcbxsettings.cpp index 13d42832db..a1dadb0e54 100644 --- a/src/plugins/platforms/xcb/qxcbxsettings.cpp +++ b/src/plugins/platforms/xcb/qxcbxsettings.cpp @@ -36,7 +36,9 @@ #include #include +#ifdef XCB_USE_XLIB #include +#endif //XCB_USE_XLIB QT_BEGIN_NAMESPACE /* Implementation of http://standards.freedesktop.org/xsettings-spec/xsettings-0.5.html */ @@ -138,6 +140,7 @@ public: return value + 4 - remainder; } +#ifdef XCB_USE_XLIB void populateSettings(const QByteArray &xSettings) { if (xSettings.length() < 12) @@ -212,6 +215,7 @@ public: } } +#endif //XCB_USE_XLIB QXcbScreen *screen; xcb_window_t x_settings_window; @@ -258,8 +262,10 @@ QXcbXSettings::QXcbXSettings(QXcbScreen *screen) const uint32_t event_mask[] = { XCB_EVENT_MASK_STRUCTURE_NOTIFY|XCB_EVENT_MASK_PROPERTY_CHANGE }; xcb_change_window_attributes(screen->xcb_connection(),d_ptr->x_settings_window,event,event_mask); +#ifdef XCB_USE_XLIB d_ptr->populateSettings(d_ptr->getSettings()); d_ptr->initialized = true; +#endif //XCB_USE_XLIB } QXcbXSettings::~QXcbXSettings() @@ -279,7 +285,9 @@ void QXcbXSettings::handlePropertyNotifyEvent(const xcb_property_notify_event_t Q_D(QXcbXSettings); if (event->window != d->x_settings_window) return; +#ifdef XCB_USE_XLIB d->populateSettings(d->getSettings()); +#endif //XCB_USE_XLIB } void QXcbXSettings::registerCallbackForProperty(const QByteArray &property, QXcbXSettings::PropertyChangeFunc func, void *handle) -- cgit v1.2.3 From 075ae987c48ce732e6a22c1eba71023fa0ea1775 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 7 Jan 2015 15:44:12 +0100 Subject: X11 devicePixelRatio screen mapping fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix screen detection and window geometry when screens have different displayPixelRatios. We must use the native coordinate system to figure out which screen a window belongs to. Also, when a window moves to a screen with a different devicePixelRatio, we must recalculate the Qt geometry. Task-number: QTBUG-43713 Change-Id: I93063e37354ff88f3c8a13320b76dfb272e43a9c Reviewed-by: Jørgen Lind --- src/plugins/platforms/xcb/qxcbscreen.cpp | 5 ++++- src/plugins/platforms/xcb/qxcbscreen.h | 2 ++ src/plugins/platforms/xcb/qxcbwindow.cpp | 29 +++++++++++++++++++++++++++-- src/plugins/platforms/xcb/qxcbwindow.h | 2 ++ 4 files changed, 35 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 73f27c7117..f8d68c68f0 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -77,8 +77,10 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr, // virtual size is known (probably back-calculated from DPI and resolution) if (m_sizeMillimeters.isEmpty()) m_sizeMillimeters = m_virtualSizeMillimeters; - if (m_geometry.isEmpty()) + if (m_geometry.isEmpty()) { m_geometry = QRect(QPoint(), m_virtualSize/dpr); + m_nativeGeometry = QRect(QPoint(), m_virtualSize); + } if (m_availableGeometry.isEmpty()) m_availableGeometry = m_geometry; @@ -461,6 +463,7 @@ void QXcbScreen::updateGeometry(xcb_timestamp_t timestamp) m_devicePixelRatio = qRound(dpi/96); const int dpr = int(devicePixelRatio()); // we may override m_devicePixelRatio m_geometry = QRect(xGeometry.topLeft()/dpr, xGeometry.size()/dpr); + m_nativeGeometry = QRect(xGeometry.topLeft(), xGeometry.size()); m_availableGeometry = QRect(xAvailableGeometry.topLeft()/dpr, xAvailableGeometry.size()/dpr); QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry); diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index b9ee331104..4675b12d9c 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -62,6 +62,7 @@ public: QWindow *topLevelAt(const QPoint &point) const; QRect geometry() const { return m_geometry; } + QRect nativeGeometry() const { return m_nativeGeometry; } QRect availableGeometry() const {return m_availableGeometry;} int depth() const { return m_screen->root_depth; } QImage::Format format() const; @@ -114,6 +115,7 @@ private: QSizeF m_outputSizeMillimeters; QSizeF m_sizeMillimeters; QRect m_geometry; + QRect m_nativeGeometry; QRect m_availableGeometry; QSize m_virtualSize; QSizeF m_virtualSizeMillimeters; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index e1ccc3f086..590e296f61 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1831,6 +1831,23 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even } } +// Temporary workaround for bug in QPlatformScreen::screenForNativeGeometry +// we need the native geometries to detect our screen, but that's not +// available in cross-platform code. Will be fixed properly when highDPI +// support is refactored to expose the native coordinate system. + +QPlatformScreen *QXcbWindow::screenForNativeGeometry(const QRect &newGeometry) const +{ + QXcbScreen *currentScreen = static_cast(screen()); + if (!parent() && !currentScreen->nativeGeometry().intersects(newGeometry)) { + Q_FOREACH (QPlatformScreen* screen, currentScreen->virtualSiblings()) { + if (static_cast(screen)->nativeGeometry().intersects(newGeometry)) + return screen; + } + } + return currentScreen; +} + void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event) { bool fromSendEvent = (event->response_type & 0x80); @@ -1847,15 +1864,23 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * } } - QRect rect = mapFromNative(QRect(pos, QSize(event->width, event->height)), int(devicePixelRatio())); + const int dpr = devicePixelRatio(); + const QRect nativeRect = QRect(pos, QSize(event->width, event->height)); + const QRect rect = mapFromNative(nativeRect, dpr); QPlatformWindow::setGeometry(rect); QWindowSystemInterface::handleGeometryChange(window(), rect); - QPlatformScreen *newScreen = screenForGeometry(rect); + QPlatformScreen *newScreen = screenForNativeGeometry(nativeRect); if (newScreen != m_screen) { m_screen = static_cast(newScreen); QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); + int newDpr = devicePixelRatio(); + if (newDpr != dpr) { + QRect newRect = mapFromNative(nativeRect, newDpr); + QPlatformWindow::setGeometry(newRect); + QWindowSystemInterface::handleGeometryChange(window(), newRect); + } } m_configureNotifyPending = false; diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 12d20d004d..254421e57d 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -154,6 +154,8 @@ public: qreal devicePixelRatio() const; + QPlatformScreen *screenForNativeGeometry(const QRect &newGeometry) const; + public Q_SLOTS: void updateSyncRequestCounter(); -- cgit v1.2.3 From 3f0b8a9f198cd1e0e8ae9150561f93fb1b931b7e Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 8 Jan 2015 13:55:32 +0100 Subject: Multi-screen DPI support for X11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calculate the logical DPI independently per screen, but only when auto dpr is enabled. Using a constant DPI value for all screens, based on the combined geometry is arguably incorrect, but changing this now will cause pixel-size fonts to behave visibly different from point-size fonts when moving the window to a different screen. However, with QT_DEVICE_PIXEL_RATIO=auto, the pixel size fonts are already changing when the devicePixelRatio changes. Without this change, the point-size fonts will *not* adapt, which is a clear bug. Task-number: QTBUG-43713 Change-Id: I3e71618f9d55b7828ccd70b69a7b7ce656c69d65 Reviewed-by: Friedemann Kleint Reviewed-by: Jørgen Lind Reviewed-by: Simon Hausmann Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbscreen.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index f8d68c68f0..6559a0bdba 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -317,8 +317,14 @@ QDpi QXcbScreen::logicalDpi() const if (m_forcedDpi > 0) return QDpi(m_forcedDpi/dpr, m_forcedDpi/dpr); - return QDpi(Q_MM_PER_INCH * m_virtualSize.width() / m_virtualSizeMillimeters.width() / dpr, - Q_MM_PER_INCH * m_virtualSize.height() / m_virtualSizeMillimeters.height() / dpr); + static const bool auto_dpr = qgetenv("QT_DEVICE_PIXEL_RATIO").toLower() == "auto"; + if (auto_dpr) { + return QDpi(Q_MM_PER_INCH * m_geometry.width() / m_sizeMillimeters.width(), + Q_MM_PER_INCH * m_geometry.height() / m_sizeMillimeters.height()); + } else { + return QDpi(Q_MM_PER_INCH * m_virtualSize.width() / m_virtualSizeMillimeters.width() / dpr, + Q_MM_PER_INCH * m_virtualSize.height() / m_virtualSizeMillimeters.height() / dpr); + } } -- cgit v1.2.3 From 34ce66cd89ea1c618d8f63dd2d9b95aed0a81b11 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Fri, 2 Jan 2015 12:56:18 +0100 Subject: Doc: link issue D-Bus Viewer Moved doc D-Bus Viewer from qdbusviewer.cpp to qtdbus-index.qdoc Doc moved from qttools to qtbase Task-number: QTBUG-43537 Change-Id: I718781a8f5029f64fea0f2be241b4d584cc8bfce Reviewed-by: Martin Smith --- src/dbus/doc/src/qtdbus-index.qdoc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/dbus/doc/src/qtdbus-index.qdoc b/src/dbus/doc/src/qtdbus-index.qdoc index 2249924ada..d534ea9140 100644 --- a/src/dbus/doc/src/qtdbus-index.qdoc +++ b/src/dbus/doc/src/qtdbus-index.qdoc @@ -212,5 +212,22 @@ \li \l{Qt D-Bus XML compiler (qdbusxml2cpp)} \li \l{Qt D-Bus C++ Classes} \li \l{Qt D-Bus Examples} + \li \l{D-Bus Viewer} \endlist */ + +/*! + \page qdbusviewer.html + \title D-Bus Viewer + \keyword qdbusviewer + + The Qt D-Bus Viewer is a tool that lets you introspect D-Bus objects and messages. You can + choose between the system bus and the session bus. Click on any service on the list + on the left side to see all the exported objects. + + You can invoke methods by double-clicking on them. If a method takes one or more IN parameters, + a property editor opens. + + Right-click on a signal to connect to it. All emitted signals including their parameters + are output in the message view on the lower side of the window. +*/ -- cgit v1.2.3 From 13ecde3b7af364be2db466029f796f3cb6310685 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 13 Jan 2015 12:53:04 +0100 Subject: iOS: guard text responder from clearing selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When programatically setting a text selection on iOS, we call [UITextInputDelegate selectionWillChange] to report the change. If auto correction is enabled, UIKit will then reset the current tracking, and for some reason tell us to clear the selection. This is contradictory to us saying the the selection is about to change, and will cause an unwanted recursion back to Qt. Since there seems to be no way to stop UIKit from doing this, this patch will instead add a guard that refuses to change the selection recursively while processing a selection change from Qt. Task-number: QTBUG-43716 Change-Id: Id487a57cdda55d7e2d09c3efc14c7f03f566f15a Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiostextresponder.h | 1 + src/plugins/platforms/ios/qiostextresponder.mm | 11 +++++++++++ 2 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiostextresponder.h b/src/plugins/platforms/ios/qiostextresponder.h index 118ab8958a..21b61bf8da 100644 --- a/src/plugins/platforms/ios/qiostextresponder.h +++ b/src/plugins/platforms/ios/qiostextresponder.h @@ -51,6 +51,7 @@ class QIOSInputContext; QIOSInputContext *m_inputContext; QString m_markedText; BOOL m_inSendEventToFocusObject; + BOOL m_inSelectionChange; } - (id)initWithInputContext:(QIOSInputContext *)context; diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index bebc7577f8..15fade0838 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -171,6 +171,7 @@ return self; m_inSendEventToFocusObject = NO; + m_inSelectionChange = NO; m_inputContext = inputContext; QVariantMap platformData = [self imValue:Qt::ImPlatformData].toMap(); @@ -302,6 +303,7 @@ return; if (updatedProperties & (Qt::ImCursorPosition | Qt::ImAnchorPosition)) { + QScopedValueRollback rollback(m_inSelectionChange, true); [self.inputDelegate selectionWillChange:self]; [self.inputDelegate selectionDidChange:self]; } @@ -349,6 +351,15 @@ - (void)setSelectedTextRange:(UITextRange *)range { + if (m_inSelectionChange) { + // After [UITextInputDelegate selectionWillChange], UIKit will cancel + // any ongoing auto correction (if enabled) and ask us to set an empty selection. + // This is contradictory to our current attempt to set a selection, so we ignore + // the callback. UIKit will be re-notified of the new selection after + // [UITextInputDelegate selectionDidChange]. + return; + } + QUITextRange *r = static_cast(range); QList attrs; attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, r.range.location, r.range.length, 0); -- cgit v1.2.3 From c3590c76775c889fde13dc155c2a31508db612e9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 14 Jan 2015 15:34:45 -0800 Subject: Update doc saying QDateTime::setTime with invalid time sets to midnight QDateTimePrivate::setDateTime has a comment saying this is intentional, so document it. Task-number: QTBUG-43704 Change-Id: Ic5d393bfd36e48a193fcffff13b965409eaf7be9 Reviewed-by: Martin Smith --- src/corelib/tools/qdatetime.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index d52dea8d4f..082b721e82 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3296,8 +3296,8 @@ bool QDateTime::isDaylightTime() const } /*! - Sets the date part of this datetime to \a date. - If no time is set, it is set to midnight. + Sets the date part of this datetime to \a date. If no time is set yet, it + is set to midnight. If \a date is invalid, this QDateTime becomes invalid. \sa date(), setTime(), setTimeSpec() */ @@ -3309,7 +3309,14 @@ void QDateTime::setDate(const QDate &date) } /*! - Sets the time part of this datetime to \a time. + Sets the time part of this datetime to \a time. If \a time is not valid, + this function sets it to midnight. Therefore, it's possible to clear any + set time in a QDateTime by setting it to a default QTime: + + \code + QDateTime dt = QDateTime::currentDateTime(); + dt.setTime(QTime()); + \endcode \sa time(), setDate(), setTimeSpec() */ -- cgit v1.2.3 From 241d32bfe3638b0e92e8e1dd1ae75411fe1aa6c7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 15 Jan 2015 14:45:46 +0100 Subject: Fix inlining order of functions in qpathclipper_p.h. When compiling tst_qpathclipper with MinGW: In file included from QtGui/private/qpathclipper_p.h:1:0, from tst_qpathclipper.cpp:33: src/gui/painting/qpathclipper_p.h:469:29: warning: 'static QPathEdge::Traversal QWingedEdge::flip(QPathEdge::Traversal)' redeclared without dllimport attribute after being referenced with dll linkage inline QPathEdge::Traversal QWingedEdge::flip(QPathEdge::Traversal traversal) ^ qpathclipper_p.h:474:29: warning: 'static QPathEdge::Direction QWingedEdge::flip(QPathEdge::Direction)' redeclared without dllimport attribute after being referenced with dll linkage inline QPathEdge::Direction QWingedEdge::flip(QPathEdge::Direction direction) Change-Id: I38feb07d693768285c1d405b3fc92a58c3309547 Reviewed-by: Gunnar Sletta --- src/gui/painting/qpathclipper_p.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qpathclipper_p.h b/src/gui/painting/qpathclipper_p.h index 5475503f22..5fc8bbaf09 100644 --- a/src/gui/painting/qpathclipper_p.h +++ b/src/gui/painting/qpathclipper_p.h @@ -414,22 +414,6 @@ inline void QPathSegments::addIntersection(int index, const Intersection &inters } } -inline void QWingedEdge::TraversalStatus::flipDirection() -{ - direction = QWingedEdge::flip(direction); -} - -inline void QWingedEdge::TraversalStatus::flipTraversal() -{ - traversal = QWingedEdge::flip(traversal); -} - -inline void QWingedEdge::TraversalStatus::flip() -{ - flipDirection(); - flipTraversal(); -} - inline int QWingedEdge::edgeCount() const { return m_edges.size(); @@ -471,11 +455,27 @@ inline QPathEdge::Traversal QWingedEdge::flip(QPathEdge::Traversal traversal) return traversal == QPathEdge::RightTraversal ? QPathEdge::LeftTraversal : QPathEdge::RightTraversal; } +inline void QWingedEdge::TraversalStatus::flipTraversal() +{ + traversal = QWingedEdge::flip(traversal); +} + inline QPathEdge::Direction QWingedEdge::flip(QPathEdge::Direction direction) { return direction == QPathEdge::Forward ? QPathEdge::Backward : QPathEdge::Forward; } +inline void QWingedEdge::TraversalStatus::flipDirection() +{ + direction = QWingedEdge::flip(direction); +} + +inline void QWingedEdge::TraversalStatus::flip() +{ + flipDirection(); + flipTraversal(); +} + QT_END_NAMESPACE #endif // QPATHCLIPPER_P_H -- cgit v1.2.3 From ccb5978c6d45569e590bba527255fafbcb840d08 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 3 Dec 2014 14:08:39 +0100 Subject: Fix namespacing of QNSViewMouseMoveHelper Task-number: QTBUG-43061 Change-Id: Ied8cdf49c34ef155b0f0bbc7e547b7c01bcd1d11 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.h | 4 ++-- src/plugins/platforms/cocoa/qnsview.mm | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 8d8df13dc3..fa71ab4086 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -48,7 +48,7 @@ class QCocoaBackingStore; class QCocoaGLContext; QT_END_NAMESPACE -Q_FORWARD_DECLARE_OBJC_CLASS(QNSViewMouseMoveHelper); +Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); @interface QT_MANGLE_NAMESPACE(QNSView) : NSView { QImage m_backingStore; @@ -72,7 +72,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QNSViewMouseMoveHelper); bool m_shouldSetGLContextinDrawRect; #endif NSString *m_inputSource; - QNSViewMouseMoveHelper *m_mouseMoveHelper; + QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) *m_mouseMoveHelper; bool m_resendKeyEvent; } diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 699340795d..771b464805 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -83,7 +83,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; - (CGFloat)deviceDeltaZ; @end -@interface QNSViewMouseMoveHelper : NSObject +@interface QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) : NSObject { QNSView *view; } @@ -97,7 +97,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; @end -@implementation QNSViewMouseMoveHelper +@implementation QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) - (id)initWithView:(QNSView *)theView { @@ -158,7 +158,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; currentCustomDragTypes = 0; m_sendUpAsRightButton = false; m_inputSource = 0; - m_mouseMoveHelper = [[QNSViewMouseMoveHelper alloc] initWithView:self]; + m_mouseMoveHelper = [[QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) alloc] initWithView:self]; m_resendKeyEvent = false; if (!touchDevice) { -- cgit v1.2.3 From 988f1b2e5745646cf1bd7f9f65507356ff2ba12e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 6 Jan 2015 16:21:41 +0100 Subject: Windows: Use DND effect chosen in DragEnter/Move for Drop. The value of pdwEffect passed to IOleDropTarget::Drop() is always the one with which the drag was initiated. Task-number: QTBUG-43466 Change-Id: I045fef634b55d4f113b393aa0ad4aa15d37db372 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowsdrag.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index fce60c3169..d3eb049269 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -626,7 +626,7 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, const QPlatformDropQtResponse response = QWindowSystemInterface::handleDrop(m_window, windowsDrag->dropData(), m_lastPoint / QWindowsScaling::factor(), - translateToQDragDropActions(*pdwEffect)); + translateToQDragDropActions(m_chosenEffect)); if (response.isAccepted()) { const Qt::DropAction action = response.acceptedAction(); -- cgit v1.2.3 From c1d08afd31074a2733057ed6620735ef2f4dd8c6 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 12 Jan 2015 10:14:44 +0100 Subject: Fix constantly growing window bug with devicePixelRatio Rectangles need to be mapped differently depending on what they are used for. Expose events need to cover the entire geometry, so they must be rounded up, potentially increasing the size. If we use the same conversion for window geometries, it is possible to end up with a feedback loop if the window reacts to the new size. Task-number: QTBUG-43743 Change-Id: I7881cc77bf2148fed2ae743c4226617a61197434 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbwindow.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 590e296f61..4fd71f1635 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -151,7 +151,7 @@ static inline QRect mapToNative(const QRect &qtRect, int dpr) return QRect(qtRect.x() * dpr, qtRect.y() * dpr, qtRect.width() * dpr, qtRect.height() * dpr); } -// When converting native rects to Qt rects: round top/left towards the origin and +// When mapping expose events to Qt rects: round top/left towards the origin and // bottom/right away from the origin, making sure that we cover the whole widget static inline QPoint dpr_floor(const QPoint &p, int dpr) @@ -164,11 +164,15 @@ static inline QPoint dpr_ceil(const QPoint &p, int dpr) return QPoint((p.x() + dpr - 1) / dpr, (p.y() + dpr - 1) / dpr); } -static inline QRect mapFromNative(const QRect &xRect, int dpr) +static inline QRect mapExposeFromNative(const QRect &xRect, int dpr) { return QRect(dpr_floor(xRect.topLeft(), dpr), dpr_ceil(xRect.bottomRight(), dpr)); } +static inline QRect mapGeometryFromNative(const QRect &xRect, int dpr) +{ + return QRect(xRect.topLeft() / dpr, xRect.bottomRight() / dpr); +} // Returns \c true if we should set WM_TRANSIENT_FOR on \a w static inline bool isTransient(const QWindow *w) @@ -1718,7 +1722,7 @@ public: return false; if (expose->count == 0) m_pending = false; - *m_region |= mapFromNative(QRect(expose->x, expose->y, expose->width, expose->height), m_dpr); + *m_region |= mapExposeFromNative(QRect(expose->x, expose->y, expose->width, expose->height), m_dpr); return true; } @@ -1746,7 +1750,7 @@ void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event) { const int dpr = int(devicePixelRatio()); QRect x_rect(event->x, event->y, event->width, event->height); - QRect rect = mapFromNative(x_rect, dpr); + QRect rect = mapExposeFromNative(x_rect, dpr); if (m_exposeRegion.isEmpty()) m_exposeRegion = rect; @@ -1866,7 +1870,7 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * const int dpr = devicePixelRatio(); const QRect nativeRect = QRect(pos, QSize(event->width, event->height)); - const QRect rect = mapFromNative(nativeRect, dpr); + const QRect rect = mapGeometryFromNative(nativeRect, dpr); QPlatformWindow::setGeometry(rect); QWindowSystemInterface::handleGeometryChange(window(), rect); @@ -1877,7 +1881,7 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); int newDpr = devicePixelRatio(); if (newDpr != dpr) { - QRect newRect = mapFromNative(nativeRect, newDpr); + QRect newRect = mapGeometryFromNative(nativeRect, newDpr); QPlatformWindow::setGeometry(newRect); QWindowSystemInterface::handleGeometryChange(window(), newRect); } -- cgit v1.2.3 From a8a00f646b57b5a7ca2cf8603311888ff6ff09f8 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 13 Jan 2015 12:45:28 +0100 Subject: Turn off font hinting when we do high DPI scaling Font hinting depends on the specific pixel size, and ends up very wrong when the painter is scaled. Change-Id: I2007ec7e7ad8d52358d76e88e030ea4df7e91455 Task-number: QTBUG-43809 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../fontdatabases/fontconfig/qfontconfigdatabase.cpp | 5 +++++ src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 6 +++++- src/plugins/platforms/xcb/qxcbnativeinterface.h | 3 ++- src/plugins/platforms/xcb/qxcbscreen.cpp | 7 +++++++ src/plugins/platforms/xcb/qxcbscreen.h | 2 ++ 5 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 5dec1d0915..27ff33be86 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -521,6 +521,11 @@ QFontEngine::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hintin break; } + if (QGuiApplication::platformNativeInterface()->nativeResourceForScreen("nofonthinting", + QGuiApplication::primaryScreen())) { + return QFontEngine::HintNone; + } + if (useXftConf) { void *hintStyleResource = QGuiApplication::platformNativeInterface()->nativeResourceForScreen("hintstyle", diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 3058b29f2d..31dedd40a2 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -78,7 +78,8 @@ static int resourceType(const QByteArray &key) QByteArrayLiteral("startupid"), QByteArrayLiteral("traywindow"), QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen"), QByteArrayLiteral("rootwindow"), - QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingEnabled") + QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingEnabled"), + QByteArrayLiteral("nofonthinting") }; const QByteArray *end = names + sizeof(names) / sizeof(names[0]); const QByteArray *result = std::find(names, end, key); @@ -283,6 +284,9 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q case GetTimestamp: result = getTimestamp(xcbScreen); break; + case NoFontHinting: + result = xcbScreen->noFontHinting() ? this : 0; //qboolptr... + break; default: break; } diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h index b667f1a372..330dd008c4 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.h +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h @@ -67,7 +67,8 @@ public: X11Screen, RootWindow, ScreenSubpixelType, - ScreenAntialiasingEnabled + ScreenAntialiasingEnabled, + NoFontHinting }; QXcbNativeInterface(); diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 6559a0bdba..7136455754 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -62,6 +62,7 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr, , m_forcedDpi(-1) , m_devicePixelRatio(1) , m_hintStyle(QFontEngine::HintStyle(-1)) + , m_noFontHinting(false) , m_subpixelType(QFontEngine::SubpixelAntialiasingType(-1)) , m_antialiasingEnabled(-1) , m_xSettings(0) @@ -86,6 +87,12 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr, readXResources(); + // disable font hinting when we do UI scaling + static bool dpr_scaling_enabled = (qgetenv("QT_DEVICE_PIXEL_RATIO").toInt() > 1 + || qgetenv("QT_DEVICE_PIXEL_RATIO").toLower() == "auto"); + if (dpr_scaling_enabled) + m_noFontHinting = true; + #ifdef Q_XCB_DEBUG qDebug(); qDebug("Screen output %s of xcb screen %d:", m_outputName.toUtf8().constData(), m_number); diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index 4675b12d9c..e9ab2edaa0 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -98,6 +98,7 @@ public: void readXResources(); QFontEngine::HintStyle hintStyle() const { return m_hintStyle; } + bool noFontHinting() const { return m_noFontHinting; } QFontEngine::SubpixelAntialiasingType subpixelType() const { return m_subpixelType; } int antialiasingEnabled() const { return m_antialiasingEnabled; } @@ -132,6 +133,7 @@ private: int m_forcedDpi; int m_devicePixelRatio; QFontEngine::HintStyle m_hintStyle; + bool m_noFontHinting; QFontEngine::SubpixelAntialiasingType m_subpixelType; int m_antialiasingEnabled; QXcbXSettings *m_xSettings; -- cgit v1.2.3 From 24238e6a3188062521ce7ed6d8d5468751a28d97 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Thu, 4 Dec 2014 15:14:18 +0100 Subject: Doc: link issues in corelib Task-number: QTBUG-43115 Change-Id: Ia80802e698f16730698e9a90102f549fb35f9305 Reviewed-by: Martin Smith --- src/corelib/doc/src/external-resources.qdoc | 11 +++++++++++ src/corelib/kernel/qobject.cpp | 10 +++++----- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/doc/src/external-resources.qdoc b/src/corelib/doc/src/external-resources.qdoc index a4f1b8723a..03af1d81bf 100644 --- a/src/corelib/doc/src/external-resources.qdoc +++ b/src/corelib/doc/src/external-resources.qdoc @@ -55,3 +55,14 @@ \externalpage http://www.iana.org/assignments/character-sets/character-sets.xml \title IANA character-sets encoding file */ + +/*! + \externalpage http://doc-snapshot.qt-project.org/qt5-5.4/qtdesigner-manual.html + \title Using a Designer UI File in Your Application +*/ + +/*! + \externalpage http://doc-snapshot.qt-project.org/qt5-5.4/designer-widget-mode.html#the-property-editor + \title Qt Designer's Widget Editing Mode#The Property Editor +*/ +*/ diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 492031d7fe..a1a04b3ce5 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2741,9 +2741,9 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign You can check if the QMetaObject::Connection is valid by casting it to a bool. This function works in the same way as - connect(const QObject *sender, const char *signal, + \c {connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, - Qt::ConnectionType type) + Qt::ConnectionType type)} but it uses QMetaMethod to specify signal and method. \sa connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) @@ -2996,7 +2996,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal, otherwise returns \c false. This function provides the same possibilities like - disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) + \c {disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) } but uses QMetaMethod to represent the signal and the method to be disconnected. Additionally this function returnsfalse and no signals and slots disconnected @@ -4110,7 +4110,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) { This macro associates extra information to the class, which is available using QObject::metaObject(). Qt makes only limited use of this feature, in - the \l{Active Qt}, \l{Qt D-Bus} and \l{Qt QML} modules. + the \l{Active Qt}, \l{Qt D-Bus} and \l{Qt QML module}{Qt QML}. The extra information takes the form of a \a Name string and a \a Value literal string. @@ -4122,7 +4122,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) { \sa QMetaObject::classInfo() \sa QAxFactory \sa {Using Qt D-Bus Adaptors} - \sa {Extending QML - Default Property Example} + \sa {Extending QML} */ /*! -- cgit v1.2.3 From 871560d45c1e4ad5c70c9d6b77cad8d3b15a4103 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Tue, 23 Dec 2014 13:39:24 +0100 Subject: Doc: define target voor function qsnprintf() Task-number: QTBUG-43537 Change-Id: I76c511891a1a07eca77da399d23097e76047f824 Reviewed-by: Martin Smith --- src/corelib/tools/qvsnprintf.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/corelib/tools/qvsnprintf.cpp b/src/corelib/tools/qvsnprintf.cpp index cf595b8f31..be92e20fac 100644 --- a/src/corelib/tools/qvsnprintf.cpp +++ b/src/corelib/tools/qvsnprintf.cpp @@ -97,6 +97,7 @@ int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap) #endif /*! + \target bytearray-qsnprintf \relates QByteArray A portable snprintf() function, calls qvsnprintf. -- cgit v1.2.3 From 576cf413bb126e0350a2d8d79267496d7619e6c2 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Tue, 6 Jan 2015 12:55:58 +0100 Subject: Doc: verb "to layout" changed to "to lay out" Task-number: QTBUG-43657 Change-Id: I574186253ee423cc380ec3c6f274f1caa2a6aa2a Reviewed-by: Martin Smith --- src/gui/text/qfontmetrics.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index 9610482145..e010dd62ae 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -647,7 +647,7 @@ int QFontMetrics::charWidth(const QString &text, int pos) const e.g. for italicized fonts, and that the width of the returned rectangle might be different than what the width() method returns. - If you want to know the advance width of the string (to layout + If you want to know the advance width of the string (to lay out a set of strings next to each other), use width() instead. Newline characters are processed as normal characters, \e not as @@ -817,7 +817,7 @@ QSize QFontMetrics::size(int flags, const QString &text, int tabStops, int *tabA e.g. for italicized fonts, and that the width of the returned rectangle might be different than what the width() method returns. - If you want to know the advance width of the string (to layout + If you want to know the advance width of the string (to lay out a set of strings next to each other), use width() instead. Newline characters are processed as normal characters, \e not as @@ -1432,7 +1432,7 @@ qreal QFontMetricsF::width(QChar ch) const e.g. for italicized fonts, and that the width of the returned rectangle might be different than what the width() method returns. - If you want to know the advance width of the string (to layout + If you want to know the advance width of the string (to lay out a set of strings next to each other), use width() instead. Newline characters are processed as normal characters, \e not as @@ -1606,7 +1606,7 @@ QSizeF QFontMetricsF::size(int flags, const QString &text, int tabStops, int *ta e.g. for italicized fonts, and that the width of the returned rectangle might be different than what the width() method returns. - If you want to know the advance width of the string (to layout + If you want to know the advance width of the string (to lay out a set of strings next to each other), use width() instead. Newline characters are processed as normal characters, \e not as -- cgit v1.2.3 From c28718b88b0cfc712a5177f04475813045c45119 Mon Sep 17 00:00:00 2001 From: Eric Lemanissier Date: Fri, 16 Jan 2015 11:44:59 +0100 Subject: Correction on bound values in case of repeated QSqlQuery::execBatch Until now, QSqlQuery::execBatch did not call resetBindCount, which lead the next call to QSqlQuery::addBindValue to start at non zero index. This is problematic in case of a prepared query which is called several times. Task-number: QTBUG-43874 Change-Id: I1a0f46e39b74d9538009967fd98a269e05aac6f2 Reviewed-by: Mark Brand --- src/sql/kernel/qsqlquery.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp index 98e262a7e2..2808587d96 100644 --- a/src/sql/kernel/qsqlquery.cpp +++ b/src/sql/kernel/qsqlquery.cpp @@ -1060,6 +1060,7 @@ bool QSqlQuery::exec() */ bool QSqlQuery::execBatch(BatchExecutionMode mode) { + d->sqlResult->resetBindCount(); return d->sqlResult->execBatch(mode == ValuesAsColumns); } -- cgit v1.2.3 From 593e3f2fbb324f076e4d3f05b269f21f8c3ca403 Mon Sep 17 00:00:00 2001 From: Marcel Krems Date: Tue, 9 Dec 2014 14:58:26 +0100 Subject: Update printer metrics after resolution change. [ChangeLog][QtPrintSupport] Fixed QPrinter::{width,height} return values when the resolution is changed in the print dialog. Task-number: QTBUG-43124 Change-Id: Ib805907affed4b1ffb48e6b1ff89f7a79ab3e329 Reviewed-by: Andy Shaw --- src/printsupport/kernel/qprintengine_win.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index 4e0a3e0795..69f74ef775 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -931,6 +931,8 @@ void QWin32PrintEnginePrivate::initHDC() default: break; } + + updateMetrics(); } void QWin32PrintEnginePrivate::release() -- cgit v1.2.3 From 5239ba95e8d68a96b2783793576490f119fb5700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 15 Jan 2015 23:42:25 +0100 Subject: Add missing AppDataLocation case This amends commit f3bc9f5c. Change-Id: I69b1a5080e7ac92b8a39746d814da77b17c271c2 Task-number: QTBUG-43868 Reviewed-by: Friedemann Kleint --- src/corelib/io/qstandardpaths_mac.mm | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/corelib/io/qstandardpaths_mac.mm b/src/corelib/io/qstandardpaths_mac.mm index 01d1c01f78..13b864600e 100644 --- a/src/corelib/io/qstandardpaths_mac.mm +++ b/src/corelib/io/qstandardpaths_mac.mm @@ -167,6 +167,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) case TempLocation: return QDir::tempPath(); case GenericDataLocation: + case AppDataLocation: case AppLocalDataLocation: case GenericCacheLocation: case CacheLocation: -- cgit v1.2.3 From b2cff0b4bf93bc85b9b76098e8e8ff2fdaf83198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 14 Jan 2015 14:20:04 +0100 Subject: Fix stylesheet crash. Style sheets that refer to the progress bar (like "QProgressDialog[maximum='0']{}") may dereference a null-pointer during the styleHint() call in QProgressDialogPrivate::init() since the progress bar has not been created yet. Move the creation of the progress bar closer to the top of init(), before the styleHint() call. Change-Id: I31c3c1c346430fc9fe86b0977403dea0c0dc5e90 Task-number: QTBUG-43830 Reviewed-by: Andras Becsi --- src/widgets/dialogs/qprogressdialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index 01ca398a14..371949e768 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -108,10 +108,10 @@ void QProgressDialogPrivate::init(const QString &labelText, const QString &cance { Q_Q(QProgressDialog); label = new QLabel(labelText, q); - int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q); - label->setAlignment(Qt::Alignment(align)); bar = new QProgressBar(q); bar->setRange(min, max); + int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q); + label->setAlignment(Qt::Alignment(align)); autoClose = true; autoReset = true; forceHide = false; -- cgit v1.2.3 From be5b04fd3782cc17bebef5ad9ffd302b8a1edef4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 15 Jan 2015 09:39:24 -0800 Subject: Move enabling of C++11 Unicode Strings with ICC from 12.1 to 14.0 The support in 12.1 and 13.x appears to be incomplete. Move it to the official supported version https://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler Note: this commit will cause a conflict in 5.5 against 99357e32a0e29c73ed721d6d31da66635e6586ca Task-number: QTBUG-43864 Change-Id: Ic5d393bfd36e48a193fcffff13b9a07106e96795 Reviewed-by: Marc Mutz --- src/corelib/global/qcompilerdetection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 3f813e163b..7effb24130 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -533,7 +533,6 @@ # define Q_COMPILER_AUTO_FUNCTION # define Q_COMPILER_NULLPTR # define Q_COMPILER_TEMPLATE_ALIAS -# define Q_COMPILER_UNICODE_STRINGS # define Q_COMPILER_VARIADIC_TEMPLATES # endif # if __INTEL_COMPILER >= 1300 @@ -554,6 +553,7 @@ # define Q_COMPILER_RANGE_FOR # define Q_COMPILER_RAW_STRINGS # define Q_COMPILER_REF_QUALIFIERS +# define Q_COMPILER_UNICODE_STRINGS # define Q_COMPILER_UNRESTRICTED_UNIONS # endif # if __INTEL_COMPILER >= 1500 -- cgit v1.2.3 From ec9bc843d8a5c18459f3669c6e22acac2077df67 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 14 Jan 2015 11:02:28 -0800 Subject: Fix compilation with Apple Clang 425 This version was based on Clang mainline between releases 3.1 and 3.2, which means it has part of 3.2 features but not all. One of the missing features is __builtin_bswap16. Change-Id: Ic5d393bfd36e48a193fcffff13b95664c7f664de Reviewed-by: Shawn Rutledge --- src/corelib/global/qendian.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 7c643f7592..0e383c18d2 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -272,9 +272,15 @@ template <> inline qint8 qFromBigEndian(const uchar *src) */ template T qbswap(T source); +#ifdef __has_builtin +# define QT_HAS_BUILTIN(x) __has_builtin(x) +#else +# define QT_HAS_BUILTIN(x) 0 +#endif + // GCC 4.3 implemented all the intrinsics, but the 16-bit one only got implemented in 4.8; // Clang 2.6 implemented the 32- and 64-bit but waited until 3.2 to implement the 16-bit one -#if (defined(Q_CC_GNU) && Q_CC_GNU >= 403) || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 206) +#if (defined(Q_CC_GNU) && Q_CC_GNU >= 403) || QT_HAS_BUILTIN(__builtin_bswap32) template <> inline quint64 qbswap(quint64 source) { return __builtin_bswap64(source); @@ -306,7 +312,7 @@ template <> inline quint32 qbswap(quint32 source) | ((source & 0xff000000) >> 24); } #endif // GCC & Clang intrinsics -#if (defined(Q_CC_GNU) && Q_CC_GNU >= 408) || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 302) +#if (defined(Q_CC_GNU) && Q_CC_GNU >= 408) || QT_HAS_BUILTIN(__builtin_bswap16) template <> inline quint16 qbswap(quint16 source) { return __builtin_bswap16(source); @@ -320,6 +326,8 @@ template <> inline quint16 qbswap(quint16 source) } #endif // GCC & Clang intrinsics +#undef QT_HAS_BUILTIN + // signed specializations template <> inline qint64 qbswap(qint64 source) { -- cgit v1.2.3 From 20480070a60469017770257b6c574c5707cda58b Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Thu, 15 Jan 2015 09:45:07 +0100 Subject: Autotest: Selftests fail in UTC timezone Selftests for testlib fail when executed in UTC timezone because local and UTC are the same, but expected to be different. A custom timezone is used instead. Debug output of qCompare does only handle local and non-local timezones, using new Qt5 features allows to show the correct timezone in format string. Change-Id: I753884a12370952b7b62a90d62896db4f2d3d1b4 Reviewed-by: Jason McDonald --- src/testlib/qtest.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index 6298262958..995d653118 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -91,8 +91,7 @@ template<> inline char *toString(const QDate &date) template<> inline char *toString(const QDateTime &dateTime) { return dateTime.isValid() - ? qstrdup(qPrintable(dateTime.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")) + - (dateTime.timeSpec() == Qt::LocalTime ? QLatin1String("[local time]") : QLatin1String("[UTC]")))) + ? qstrdup(qPrintable(dateTime.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz[t]")))) : qstrdup("Invalid QDateTime"); } #endif // QT_NO_DATESTRING -- cgit v1.2.3 From 7fc8c560e21e7175b1fe33c988f3f30e4b326efe Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 29 Dec 2014 16:37:55 +0100 Subject: Fix QPrinter::setPaperSize regression when using QPrinter::DevicePixel The QPageSize-based refactoring led to casting DevicePixel to a QPageSize::Unit value of 6 (out of bounds). And then the switch in qt_nameForCustomSize would leave the string empty, leading to "QString::arg: Argument missing: , 672" warnings. Change-Id: I85e97174cc8ead9beccaaa3ded6edfad80f8e360 Reviewed-by: Friedemann Kleint Reviewed-by: Andy Shaw --- src/printsupport/kernel/qprinter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index 437a68e609..8ed2732c1e 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -1224,7 +1224,10 @@ void QPrinter::setPageSize(PageSize newPageSize) void QPrinter::setPaperSize(const QSizeF &paperSize, QPrinter::Unit unit) { - setPageSize(QPageSize(paperSize, QPageSize::Unit(unit))); + if (unit == QPrinter::DevicePixel) + setPageSize(QPageSize(paperSize * qt_pixelMultiplier(resolution()), QPageSize::Point)); + else + setPageSize(QPageSize(paperSize, QPageSize::Unit(unit))); } /*! -- cgit v1.2.3 From b18e6396bde2931a302b8fa5910268e23590c8a8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 18 Jan 2015 13:34:59 +0100 Subject: QBenchmarkResult: fix uninitialized value This manifested itself in a UBSan report about loading a non-enumerated value from an enumeration variable: src/testlib/qbenchmark_p.h:95:7: runtime error: load of value 11091, which is not a valid value for type 'QBenchmarkMetric' (or similar). The chosen value is simply QTest::QBenchmarkMetric(0). Change-Id: I8492a871a71d89fa6f7902d38f9eecee4b060646 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/testlib/qbenchmark_p.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/testlib/qbenchmark_p.h b/src/testlib/qbenchmark_p.h index 889798e862..5bf3760f66 100644 --- a/src/testlib/qbenchmark_p.h +++ b/src/testlib/qbenchmark_p.h @@ -105,6 +105,7 @@ public: QBenchmarkResult() : value(-1) , iterations(-1) + , metric(QTest::FramesPerSecond) , setByMacro(true) , valid(false) { } -- cgit v1.2.3 From 390ea21873cf229447c2dcaea85a40e472fab03c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 18 Jan 2015 13:43:37 +0100 Subject: QByteArrayMatcher: fix undefined shift The REHASH macro is used in qFindByteArray() with a char argument. Applying the shift operator promotes (a) to int. The check in REHASH, however, checks for the shift being permissible for _unsigned_ ints. Since hashHaystack is a uint, too, rectify by casting (a) to uint prior to shifting. Found by UBSan: src/corelib/tools/qbytearraymatcher.cpp:314:72: runtime error: left shift of 34 by 30 places cannot be represented in type 'int' Change-Id: Id09c037d570ca70b49f87ad22bed31bbb7dcc7fb Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qbytearraymatcher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qbytearraymatcher.cpp b/src/corelib/tools/qbytearraymatcher.cpp index f14d941c27..82f012be66 100644 --- a/src/corelib/tools/qbytearraymatcher.cpp +++ b/src/corelib/tools/qbytearraymatcher.cpp @@ -256,7 +256,7 @@ static int qFindByteArrayBoyerMoore( #define REHASH(a) \ if (sl_minus_1 < sizeof(uint) * CHAR_BIT) \ - hashHaystack -= (a) << sl_minus_1; \ + hashHaystack -= uint(a) << sl_minus_1; \ hashHaystack <<= 1 /*! -- cgit v1.2.3 From 62a96dbb53d77d6cd7320c6fc8d33ee9c4add0fe Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 18 Jan 2015 21:57:20 +0100 Subject: QTextFormat: fix undefined behavior Left-shifting of negative values is undefined ([expr.shift]/2). Since hashValue is a uint already, rectify by casting it->key to uint prior to shifting. Found by UBSan. Change-Id: I94a5311f5a4492f514f595b8fb79726df1e7d0de Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/text/qtextformat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index cecfd85df1..ecd87188e7 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -319,7 +319,7 @@ uint QTextFormatPrivate::recalcHash() const { hashValue = 0; for (QVector::ConstIterator it = props.constBegin(); it != props.constEnd(); ++it) - hashValue += (it->key << 16) + variantHash(it->value); + hashValue += (static_cast(it->key) << 16) + variantHash(it->value); hashDirty = false; -- cgit v1.2.3 From b69c2e86de99cb2ac9bcd2e33ae77c960cfbc57a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 19 Jan 2015 01:26:56 +0100 Subject: QFreeList: fix undefined behavior Signed integer overflow is undefined behavior ([expr]/4), but unsigned arithmetic doesn't overflow, so isn't ([basic.fundamental]/4, footnote there). So, use unsigned arithmetic for the loop-around serial number generation in incrementserial(). While we're at it, also use it for the masking operation in the same function. Found by UBSan. Change-Id: I500fae9d80fd3f6e39d06e79a53d271b82ea8df8 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qfreelist_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h index bfb03fb723..189140016c 100644 --- a/src/corelib/tools/qfreelist_p.h +++ b/src/corelib/tools/qfreelist_p.h @@ -171,7 +171,7 @@ class QFreeList // take the current serial number from \a o, increment it, and store it in \a n static inline int incrementserial(int o, int n) { - return (n & ConstantsType::IndexMask) | ((o + ConstantsType::SerialCounter) & ConstantsType::SerialMask); + return int((uint(n) & ConstantsType::IndexMask) | ((uint(o) + ConstantsType::SerialCounter) & ConstantsType::SerialMask)); } // the blocks -- cgit v1.2.3 From 17cce246487ca8a9b2d1999bfdbbb3b368b44177 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 14 Jan 2015 20:35:21 +0100 Subject: Only call ShowWindow() once when going from FullScreen to Maximized Since going from FullScreen to Maximized is taken care of inside the FullScreen block then we don't want to call ShowWindow() again in the Maximized block. Therefore the Maximized block is moved so it is only invoked if it is not coming or going to fullscreen. As the minimized case is not accounted for in FullScreen that is left as is in its own if block. Task-number: QTBUG-43849 Change-Id: I3141347e072c50b2a4475098d7b8ee0b207578a7 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowswindow.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 6279b6f4af..e7061dbfde 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1620,17 +1620,6 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState) setFlag(FrameDirty); - if ((oldState == Qt::WindowMaximized) != (newState == Qt::WindowMaximized)) { - if (visible && !(newState == Qt::WindowMinimized)) { - setFlag(WithinMaximize); - if (newState == Qt::WindowFullScreen) - setFlag(MaximizeToFullScreen); - ShowWindow(m_data.hwnd, (newState == Qt::WindowMaximized) ? SW_MAXIMIZE : SW_SHOWNOACTIVATE); - clearFlag(WithinMaximize); - clearFlag(MaximizeToFullScreen); - } - } - if ((oldState == Qt::WindowFullScreen) != (newState == Qt::WindowFullScreen)) { #ifdef Q_OS_WINCE HWND handle = FindWindow(L"HHTaskBar", L""); @@ -1710,6 +1699,15 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState) m_savedStyle = 0; m_savedFrameGeometry = QRect(); } + } else if ((oldState == Qt::WindowMaximized) != (newState == Qt::WindowMaximized)) { + if (visible && !(newState == Qt::WindowMinimized)) { + setFlag(WithinMaximize); + if (newState == Qt::WindowFullScreen) + setFlag(MaximizeToFullScreen); + ShowWindow(m_data.hwnd, (newState == Qt::WindowMaximized) ? SW_MAXIMIZE : SW_SHOWNOACTIVATE); + clearFlag(WithinMaximize); + clearFlag(MaximizeToFullScreen); + } } if ((oldState == Qt::WindowMinimized) != (newState == Qt::WindowMinimized)) { -- cgit v1.2.3 From 730d07df831435d41d40152d5ecec5dea2658042 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 12 Jan 2015 21:08:13 +0100 Subject: Account for pixmap's device pixel ratio when calculating the label size When determining the size of the QPushButton's label then the device pixel ratio of the pixmap used to represent the icon needs to be taken into consideration so it is rendered correctly. Change-Id: If32760b120d7a749a51e2c30592d621c0e63dace Reviewed-by: Pierre Rossi Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/styles/qstylesheetstyle.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index e9f20de842..3d9ba6b490 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3397,8 +3397,10 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q state = QIcon::On; QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state); - int labelWidth = pixmap.width(); - int labelHeight = pixmap.height(); + int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio(); + int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio(); + int labelWidth = pixmapWidth; + int labelHeight = pixmapHeight; int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint() int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width(); if (!button->text.isEmpty()) @@ -3407,15 +3409,15 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q //Determine label alignment: if (textAlignment & Qt::AlignLeft) { /*left*/ iconRect = QRect(textRect.x(), textRect.y() + (textRect.height() - labelHeight) / 2, - pixmap.width(), pixmap.height()); + pixmapWidth, pixmapHeight); } else if (textAlignment & Qt::AlignHCenter) { /* center */ iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2, textRect.y() + (textRect.height() - labelHeight) / 2, - pixmap.width(), pixmap.height()); + pixmapWidth, pixmapHeight); } else { /*right*/ iconRect = QRect(textRect.x() + textRect.width() - labelWidth, textRect.y() + (textRect.height() - labelHeight) / 2, - pixmap.width(), pixmap.height()); + pixmapWidth, pixmapHeight); } iconRect = visualRect(button->direction, textRect, iconRect); -- cgit v1.2.3 From 7c9497ad6ae9cb4b596bc76c70077577d97fe3cb Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 12 Jan 2015 20:58:53 +0100 Subject: Respect the hotspot passed in for the cursor When the hotspot is set to be QPoint(0,0) then QPoint will see this as being a null QPoint. However, it is a valid position as far as the hot spot for the cursor is concerned, so we default to QPoint(-1,-1) instead and check for that. Task-number: QTBUG-43787 Change-Id: Ibf6253033016c4b556b8a2a79c89819a4d5825cb Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowscursor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index d10c7fdb20..9a42b7712d 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -126,13 +126,15 @@ HCURSOR QWindowsCursor::createPixmapCursor(const QPixmap &pixmap, const QPoint & // Create a cursor from image and mask of the format QImage::Format_Mono. static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits, - QPoint hotSpot = QPoint(), + QPoint hotSpot = QPoint(-1, -1), bool invb = false, bool invm = false) { const int width = bbits.width(); const int height = bbits.height(); - if (hotSpot.isNull()) - hotSpot = QPoint(width / 2, height / 2); + if (hotSpot.x() < 0) + hotSpot.setX(width / 2); + if (hotSpot.y() < 0) + hotSpot.setY(height / 2); const int n = qMax(1, width / 8); #if !defined(Q_OS_WINCE) QScopedArrayPointer xBits(new uchar[height * n]); -- cgit v1.2.3 From 890ae41d0601d20505df2f955a99d0238bf4f59e Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Wed, 7 Jan 2015 16:16:23 +0100 Subject: Fix a crash in QPlainTextEdit::documentChanged The layout for an invalid block is very likely to be null, it shouldn't be accessed without checking the block's validity first. We can make the check a bit more conservative and simply check that the block isn't empty. Change-Id: Ic1459a6168b1b8ce36e9c6d019dc28653676efbe Task-number: QTBUG-43562 Reviewed-by: Simon Hausmann --- src/widgets/widgets/qplaintextedit.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 72a556db7c..e56fd111e5 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -288,8 +288,7 @@ void QPlainTextDocumentLayout::documentChanged(int from, int charsRemoved, int c if (changeStartBlock == changeEndBlock && newBlockCount == d->blockCount) { QTextBlock block = changeStartBlock; - int blockLineCount = block.layout()->lineCount(); - if (block.isValid() && blockLineCount) { + if (block.isValid() && block.length()) { QRectF oldBr = blockBoundingRect(block); layoutBlock(block); QRectF newBr = blockBoundingRect(block); -- cgit v1.2.3 From 0f5b970894718c2c38f0e3e805c4a497e8c89c65 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Sun, 18 Jan 2015 20:34:48 +0800 Subject: Doc: Remove references to QOpenGLContext::destroy() This function is private. Task-number: QTBUG-35907 Change-Id: I370c0bfd8fda11c68ee76ee42967f117a81b381c Reviewed-by: Sean Harmer --- src/gui/kernel/qopenglcontext.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 5918f30660..b663afabbc 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -518,8 +518,9 @@ void QOpenGLContext::setScreen(QScreen *screen) in addition. Therefore \a handle is variant containing a platform-specific value type. These classes can be found in the QtPlatformHeaders module. - When create() is called with native handles set, the handles' ownership are - not taken, meaning that \c destroy() will not destroy the native context. + When create() is called with native handles set, QOpenGLContext does not + take ownership of the handles, so destroying the QOpenGLContext does not + destroy the native context. \note Some frameworks track the current context and surfaces internally. Making the adopted QOpenGLContext current via Qt will have no effect on such @@ -582,8 +583,8 @@ QVariant QOpenGLContext::nativeHandle() const Returns \c true if the native context was successfully created and is ready to be used with makeCurrent(), swapBuffers(), etc. - \note If the context is already created, this function will first call - \c destroy(), and then create a new OpenGL context. + \note If the context already exists, this function destroys the existing + context first, and then creates a new one. \sa makeCurrent(), format() */ @@ -605,6 +606,8 @@ bool QOpenGLContext::create() } /*! + \internal + Destroy the underlying platform context associated with this context. If any other context is directly or indirectly sharing resources with this @@ -658,8 +661,7 @@ void QOpenGLContext::destroy() /*! Destroys the QOpenGLContext object. - This implicitly calls \c destroy(), so if this is the current context for the - thread, doneCurrent() is also called. + If this is the current context for the thread, doneCurrent() is also called. */ QOpenGLContext::~QOpenGLContext() { -- cgit v1.2.3 From c49641a117356662aea31d8b4e7fdf4055cc0b4f Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Fri, 2 Jan 2015 20:06:08 +0800 Subject: Doc: Fix typos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I29d5576902a5d1ea25558e980081952d9157f7f0 Reviewed-by: Topi Reiniö --- src/corelib/thread/qthread.cpp | 4 ++-- src/corelib/tools/qbytearray.cpp | 2 +- src/corelib/tools/qmargins.cpp | 2 +- src/corelib/xml/qxmlstream.cpp | 4 ++-- src/gui/doc/snippets/code/src_gui_image_qpixmap.cpp | 2 +- src/network/access/qnetworkreply.cpp | 2 +- src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc | 2 +- src/widgets/doc/src/widgets-and-layouts/layout.qdoc | 2 +- src/widgets/kernel/qwidget.cpp | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 3caad7c4b2..933fd06afa 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -178,7 +178,7 @@ QThreadPrivate::~QThreadPrivate() event loop by calling exec() and runs a Qt event loop inside the thread. You can use worker objects by moving them to the thread using - QObject::moveToThread. + QObject::moveToThread(). \snippet code/src_corelib_thread_qthread.cpp worker @@ -256,7 +256,7 @@ QThreadPrivate::~QThreadPrivate() \l{Mandelbrot Example}, as that is the name of the QThread subclass). Note that this is currently not available with release builds on Windows. - \sa {Thread Support in Qt}, QThreadStorage, {Synchronizing Threads} + \sa {Thread Support in Qt}, QThreadStorage, {Synchronizing Threads}, {Mandelbrot Example}, {Semaphores Example}, {Wait Conditions Example} */ diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index a3c1cc3907..bd0215902c 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -3945,7 +3945,7 @@ QByteArray QByteArray::fromRawData(const char *data, int size) copies of it exist that have not been modified. This function can be used instead of fromRawData() to re-use - existings QByteArray objects to save memory re-allocations. + existing QByteArray objects to save memory re-allocations. \sa fromRawData(), data(), constData() */ diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp index 419551aaca..265e44bfcf 100644 --- a/src/corelib/tools/qmargins.cpp +++ b/src/corelib/tools/qmargins.cpp @@ -484,7 +484,7 @@ QDebug operator<<(QDebug dbg, const QMargins &m) { /*! \fn bool QMarginsF::isNull() const - Returns \c true if all margins are is 0; otherwise returns + Returns \c true if all margins are 0; otherwise returns false. */ diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index 94f6a8bcde..e4ee71f0b1 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -726,7 +726,7 @@ static const short QXmlStreamReader_tokenTypeString_indices[] = { /*! \property QXmlStreamReader::namespaceProcessing - the namespace-processing flag of the stream reader + The namespace-processing flag of the stream reader This property controls whether or not the stream reader processes namespaces. If enabled, the reader processes namespaces, otherwise @@ -3315,7 +3315,7 @@ QTextCodec *QXmlStreamWriter::codec() const /*! \property QXmlStreamWriter::autoFormatting \since 4.4 - the auto-formatting flag of the stream writer + The auto-formatting flag of the stream writer This property controls whether or not the stream writer automatically formats the generated XML data. If enabled, the diff --git a/src/gui/doc/snippets/code/src_gui_image_qpixmap.cpp b/src/gui/doc/snippets/code/src_gui_image_qpixmap.cpp index f43bba1324..a691c24ce0 100644 --- a/src/gui/doc/snippets/code/src_gui_image_qpixmap.cpp +++ b/src/gui/doc/snippets/code/src_gui_image_qpixmap.cpp @@ -48,7 +48,7 @@ static const char * const start_xpm[]={ //! [1] QPixmap myPixmap; -myPixmap->setMask(myPixmap->createHeuristicMask()); +myPixmap.setMask(myPixmap.createHeuristicMask()); //! [1] //! [2] diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp index 18ff05fcd7..fe9564a91c 100644 --- a/src/network/access/qnetworkreply.cpp +++ b/src/network/access/qnetworkreply.cpp @@ -605,7 +605,7 @@ QList QNetworkReply::rawHeaderList() const /*! Returns the attribute associated with the code \a code. If the - attribute has not been set, it returns an invalid QVariant (type QMetaType::Unknown). + attribute has not been set, it returns an invalid QVariant (type QMetaType::UnknownType). You can expect the default values listed in QNetworkRequest::Attribute to be applied to the values returned by diff --git a/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc b/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc index 446b441675..9f5ef59e94 100644 --- a/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc +++ b/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc @@ -805,7 +805,7 @@ {QWidget::addAction}(). \endquotation - If you don't include the function name with the \b{\\overlaod} + If you don't include the function name with the \b{\\overload} command, then instead of the "This function overloads..." line with the link to the documentation for the primary version, you get the old standard line: diff --git a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc index f581df4cb3..7e2e79fc5d 100644 --- a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc @@ -219,7 +219,7 @@ \section1 Custom Widgets in Layouts When you make your own widget class, you should also communicate its layout - properties. If the widget has a one of Qt's layouts, this is already taken + properties. If the widget uses one of Qt's layouts, this is already taken care of. If the widget does not have any child widgets, or uses manual layout, you can change the behavior of the widget using any or all of the following mechanisms: diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index c99e15b9b8..453a7ca537 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -7235,7 +7235,7 @@ QByteArray QWidget::saveGeometry() const /*! \since 4.2 - Restores the geometry and state top-level widgets stored in the + Restores the geometry and state of top-level widgets stored in the byte array \a geometry. Returns \c true on success; otherwise returns \c false. -- cgit v1.2.3 From c243dd564397fedbe3d2221da72d7ce207eebade Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Wed, 14 Jan 2015 16:27:10 +0100 Subject: QIncrementalSleepTimer: Use QElapsedTimer instead of QTime Since the former is monotonic and we need a monotonic timer here. Change-Id: I34325da4fe0317e12f64629a6eef6a80990c3e1a Reviewed-by: Daniel Teske Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/io/qwindowspipewriter_p.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h index 47b7744e81..6035993500 100644 --- a/src/corelib/io/qwindowspipewriter_p.h +++ b/src/corelib/io/qwindowspipewriter_p.h @@ -45,7 +45,7 @@ // We mean it. // -#include +#include #include #include #include @@ -83,7 +83,7 @@ public: { if (totalTimeOut == -1) return SLEEPMAX; - return qMax(totalTimeOut - timer.elapsed(), 0); + return qMax(int(totalTimeOut - timer.elapsed()), 0); } bool hasTimedOut() const @@ -99,7 +99,7 @@ public: } private: - QTime timer; + QElapsedTimer timer; int totalTimeOut; int nextSleep; }; -- cgit v1.2.3 From 0310cef332e8d9b034affc43e945f37c7ca4bee5 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 3 Dec 2014 11:22:24 +0100 Subject: FusionStyle: Don't try to draw null pixmaps We have the same check for null already for PE_IndicatorHeaderArrow which actually uses the same pixmap. If the file is not found the pixmap will be null and the code dividing by its width or height will thrown an arithmetic exception. Task-number: QTBUG-43067 Change-Id: I13a5ee9f21f4189b7bbcfd57a6f5b52113de834d Reviewed-by: Oswald Buddenhagen Reviewed-by: J-P Nurmi --- src/widgets/styles/qfusionstyle.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index ed7b4ab3b6..cf2f3ea26b 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -514,6 +514,9 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, break; } arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, rotation); + if (arrow.isNull()) + break; + QRect rect = option->rect; QRect arrowRect; int imageMax = qMin(arrow.height(), arrow.width()); -- cgit v1.2.3 From 553a3661c1272b9616900a0e97e101492d468a25 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 16 Jan 2015 21:08:22 +0100 Subject: Bump version Change-Id: I250fa893cdf831d03f9217b5dc0a5aa2f9a6a6b5 Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index cb8bd15d8d..dade7fc6ec 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -37,11 +37,11 @@ #include -#define QT_VERSION_STR "5.4.1" +#define QT_VERSION_STR "5.4.2" /* QT_VERSION is (major << 16) + (minor << 8) + patch. */ -#define QT_VERSION 0x050401 +#define QT_VERSION 0x050402 /* can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) */ -- cgit v1.2.3