From 8cb263eeaffa2948477a8b3a1c8512f94ec9bb0b Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 9 Sep 2009 13:58:16 +0200 Subject: QHttpNetworkConnection autotest: include zlib dir test was not building Reviewed-by: Trust Me --- tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro index bc750c5..43284b3 100644 --- a/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro +++ b/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro @@ -1,4 +1,5 @@ load(qttest_p4) SOURCES += tst_qhttpnetworkconnection.cpp +INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/zlib QT = core network -- cgit v0.12 From d6993e7d88750a55d62bf5acbe7e7d03069dfbdf Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 9 Sep 2009 14:27:18 +0200 Subject: Avoid garbled output on Windows for non-ascii-compatible text In the Windows print engine, we try to send a text item as a raw string of characters to the printer driver if this is possible. This is to facilitate using PDF-printers as much as possible, allowing them to save the text in the document so for searching etc. We can only safely do this if all the characters in the string are ASCII-compatible, i.e. in the 7 bit range, since this is the only part of the set which is guaranteed to be compatible across code pages. Task-number: 180655 Reviewed-by: Trond --- src/gui/painting/qprintengine_win.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/painting/qprintengine_win.cpp b/src/gui/painting/qprintengine_win.cpp index d239581..96e8cff 100644 --- a/src/gui/painting/qprintengine_win.cpp +++ b/src/gui/painting/qprintengine_win.cpp @@ -400,11 +400,11 @@ void QWin32PrintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem return ; } - // We only want to convert the glyphs to text if the entire string is latin1 - bool latin1String = true; + // We only want to convert the glyphs to text if the entire string is compatible with ASCII + bool convertToText = true; for (int i=0; i < ti.num_chars; ++i) { - if (ti.chars[i].unicode() >= 0x100) { - latin1String = false; + if (ti.chars[i].unicode() >= 0x80) { + convertToText = false; break; } } @@ -414,7 +414,7 @@ void QWin32PrintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem SelectObject(d->hdc, CreatePen(PS_SOLID, 1, cf)); SetTextColor(d->hdc, cf); - draw_text_item_win(p, ti, d->hdc, latin1String, d->matrix, d->devPaperRect.topLeft()); + draw_text_item_win(p, ti, d->hdc, convertToText, d->matrix, d->devPaperRect.topLeft()); DeleteObject(SelectObject(d->hdc,GetStockObject(HOLLOW_BRUSH))); DeleteObject(SelectObject(d->hdc,GetStockObject(BLACK_PEN))); } -- cgit v0.12 From 0d1677a6e42aee1d9700cc57f053da59879ba3fb Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 9 Sep 2009 14:42:05 +0200 Subject: tst_qhostinfo: Backported some 4.6 fixes, increased timeout --- tests/auto/qhostinfo/tst_qhostinfo.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp index c632eb7..1fd805a 100644 --- a/tests/auto/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp @@ -214,10 +214,7 @@ void tst_QHostInfo::lookupIPv4_data() QTest::newRow("empty") << "" << "" << int(QHostInfo::HostNotFound); - QTest::newRow("lupinella_00") << "l" << lupinellaIp << int(QHostInfo::NoError); - QTest::newRow("lupinella_01") << "lupinella" << lupinellaIp << int(QHostInfo::NoError); - QTest::newRow("lupinella_02") << "lupinella.troll.no" << lupinellaIp << int(QHostInfo::NoError); - QTest::newRow("lupinella_03") << "lupinella.trolltech.com" << lupinellaIp << int(QHostInfo::NoError); + QTest::newRow("single_ip4") << "lupinella.troll.no" << lupinellaIp << int(QHostInfo::NoError); QTest::newRow("multiple_ip4") << "multi.dev.troll.no" << "1.2.3.4 1.2.3.5 10.3.3.31" << int(QHostInfo::NoError); QTest::newRow("literal_ip4") << lupinellaIp << lupinellaIp << int(QHostInfo::NoError); QTest::newRow("notfound") << "this-name-does-not-exist-hopefully." << "" << int(QHostInfo::HostNotFound); @@ -235,7 +232,7 @@ void tst_QHostInfo::lookupIPv4() lookupDone = false; QHostInfo::lookupHost(hostname, this, SLOT(resultsReady(const QHostInfo&))); - QTestEventLoop::instance().enterLoop(3); + QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(lookupDone); @@ -305,8 +302,8 @@ void tst_QHostInfo::reverseLookup_data() // ### Use internal DNS instead. Discussed with Andreas. //QTest::newRow("classical.hexago.com") << QString("2001:5c0:0:2::24") << QStringList(QString("classical.hexago.com")) << 0; - QTest::newRow("www.cisco.com") << QString("198.133.219.25") << QStringList(QString("origin-www.cisco.com")) << 0; - QTest::newRow("bogusexample.doenstexist.org") << QString("1::2::3::4") << QStringList() << 1; + QTest::newRow("origin.cisco.com") << QString("12.159.148.94") << QStringList(QString("origin.cisco.com")) << 0; + QTest::newRow("bogus-name") << QString("1::2::3::4") << QStringList() << 1; } void tst_QHostInfo::reverseLookup() -- cgit v0.12 From e5bb1e69a0c3165f92edebf9152dfd41bdab712f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 9 Sep 2009 15:51:47 +0200 Subject: Autotest: fix the test for NUL in SAN. It was missing "www". Reviewed-by: Marius Bugge Monsen --- tests/auto/qsslcertificate/tst_qsslcertificate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index 2f0c3a4..f41803c 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -761,7 +761,7 @@ void tst_QSslCertificate::nulInSan() QVERIFY(!dnssan.isEmpty()); QVERIFY(dnssan != "www.bank.com"); - static const char realSAN[] = "www.bank.com\0.badguy.com"; + static const char realSAN[] = "www.bank.com\0www.badguy.com"; QCOMPARE(dnssan, QString::fromLatin1(realSAN, sizeof realSAN - 1)); } -- cgit v0.12 From a77cc371917f7cda40e823b530693d38b85e666b Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 9 Sep 2009 16:55:13 +0200 Subject: Doc: Note that Netscape plugins are only available on desktop platforms. Reviewed-by: Takumi Asaki Also-applied-as: 3f257dcf8c8ca812d60d4a6a4c2cd2da96bba526 --- src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc index 06305e0..6ad2183 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc +++ b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc @@ -94,14 +94,18 @@ \section1 Netscape Plugin Support + \note Netscape plugin support is only available on desktop platforms. + Since WebKit supports the Netscape Plugin API, Qt applications can display - Web pages that embed common plugins, as long as the user has the appropriate - binary files for those plugins installed. + Web pages that embed common plugins on platforms for which those plugins + are available. To enable plugin support, the user must have the appropriate + binary files for those plugins installed and the \l{QWebSettings::PluginsEnabled} + attribute must be enabled for the application. The following locations are searched for plugins: \table - \header \o Linux/Unix \o Windows + \header \o Linux/Unix (X11) \o Windows \row \o{1,3} \list \o \c{.mozilla/plugins} in the user's home directory -- cgit v0.12 From b19372c11549bc1f88b3e59fa94745645503b8e6 Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 1 Sep 2009 13:08:02 +1000 Subject: Fixes determination of end of odbc string on deficient driver Ported this fix backwards from 4.6 to 4.5 Adds some cleanups (using QVarLengthArray), and reverting to the initial and correct calculation (when the driver doesn't deem fit to return SQL_NO_DATA). --- src/sql/drivers/odbc/qsql_odbc.cpp | 12 ++++---- tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 41 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index ae522ee..a5c713d 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -314,12 +314,12 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni colSize *= 2; // a tiny bit faster, since it saves a SQLGetData() call } } - char* buf = new char[colSize]; + QVarLengthArray buf(colSize); while (true) { r = SQLGetData(hStmt, column+1, unicode ? SQL_C_WCHAR : SQL_C_CHAR, - (SQLPOINTER)buf, + (SQLPOINTER)buf.data(), colSize, &lengthIndicator); if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) { @@ -334,11 +334,12 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni // colSize-1: remove 0 termination when there is more data to fetch int rSize = (r == SQL_SUCCESS_WITH_INFO) ? (unicode ? colSize-2 : colSize-1) : lengthIndicator; if (unicode) { - fieldVal += QString((QChar*) buf, rSize / 2); + fieldVal += QString((const QChar*) buf.constData(), rSize / 2); } else { - fieldVal += QString::fromAscii(buf, rSize); + fieldVal += QString::fromAscii(buf.constData(), rSize); } - if (lengthIndicator - fieldVal.size() <= 0) { + memset(buf.data(), 0, colSize); + if (lengthIndicator < colSize) { // workaround for Drivermanagers that don't return SQL_NO_DATA break; } @@ -350,7 +351,6 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni break; } } - delete[] buf; return fieldVal; } diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index 782bff8..9ca48f5 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -180,6 +180,8 @@ private slots: void odbc_uintfield(); void odbc_bindBoolean_data() { generic_data("QODBC"); } void odbc_bindBoolean(); + void odbc_testqGetString_data() { generic_data("QODBC"); } + void odbc_testqGetString(); void oci_serverDetach_data() { generic_data("QOCI"); } void oci_serverDetach(); // For task 154518 @@ -347,6 +349,7 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db) << qTableName("numericfields") << qTableName("qtest_ibaseblobs") << qTableName("qtestBindBool") + << qTableName("testqGetString") << qTableName("qtest_sqlguid") << qTableName("uint_table") << qTableName("uint_test") @@ -2005,6 +2008,44 @@ void tst_QSqlDatabase::odbc_bindBoolean() QCOMPARE(q.value(1).toBool(), false); } +void tst_QSqlDatabase::odbc_testqGetString() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlQuery q(db); + QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(65538))")); + + QString largeString; + largeString.fill('A', 65536); + + // Bind and insert + QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("testqGetString") + " VALUES(?, ?)")); + q.bindValue(0, 1); + q.bindValue(1, largeString); + QVERIFY_SQL(q, exec()); + q.bindValue(0, 2); + q.bindValue(1, largeString+QLatin1Char('B')); + QVERIFY_SQL(q, exec()); + q.bindValue(0, 3); + q.bindValue(1, largeString+QLatin1Char('B')+QLatin1Char('C')); + QVERIFY_SQL(q, exec()); + + // Retrive + QVERIFY_SQL(q, exec("SELECT id, vcvalue FROM " + qTableName("testqGetString") + " ORDER BY id")); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 1); + QCOMPARE(q.value(1).toString().length(), 65536); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 2); + QCOMPARE(q.value(1).toString().length(), 65537); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 3); + QCOMPARE(q.value(1).toString().length(), 65538); +} + + void tst_QSqlDatabase::mysql_multiselect() { QFETCH(QString, dbName); -- cgit v0.12 From df4033a1f7ef0786fba6d4d2027e38a2fffd1e27 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 9 Sep 2009 13:37:09 +1000 Subject: Fixes autotest for MS SQL Server Merging fix back into 4.5 tree --- tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index 9ca48f5..a3a4712 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -2015,7 +2015,10 @@ void tst_QSqlDatabase::odbc_testqGetString() CHECK_DATABASE(db); QSqlQuery q(db); - QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(65538))")); + if (tst_Databases::isSqlServer(db)) + QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(MAX))")); + else + QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(65538))")); QString largeString; largeString.fill('A', 65536); -- cgit v0.12 From 44554f497d941acdc8c8e37948f77e04445f34d2 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 10 Sep 2009 19:34:39 +1000 Subject: Make opengl fragment program generator output license header. Stops the license checker failing each time the file is re-generated. Also added "_P" to the generated header guard, as it's a private header. Reviewed-by: Gunnar Sletta --- src/opengl/util/fragmentprograms_p.h | 4 +-- src/opengl/util/generator.cpp | 57 ++++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/opengl/util/fragmentprograms_p.h b/src/opengl/util/fragmentprograms_p.h index 15315e5..364f99f 100644 --- a/src/opengl/util/fragmentprograms_p.h +++ b/src/opengl/util/fragmentprograms_p.h @@ -38,8 +38,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef FRAGMENTPROGRAMS_H -#define FRAGMENTPROGRAMS_H +#ifndef FRAGMENTPROGRAMS_P_H +#define FRAGMENTPROGRAMS_P_H // // W A R N I N G diff --git a/src/opengl/util/generator.cpp b/src/opengl/util/generator.cpp index 87f42db..4704d54 100644 --- a/src/opengl/util/generator.cpp +++ b/src/opengl/util/generator.cpp @@ -258,8 +258,61 @@ void writeIncludeFile(const QSet &variables, QLatin1String tab(" "); - out << "#ifndef FRAGMENTPROGRAMS_H\n" - << "#define FRAGMENTPROGRAMS_H\n\n"; + out << "/****************************************************************************\n" + "**\n" + "** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\n" + "** All rights reserved.\n" + "** Contact: Nokia Corporation (qt-info@nokia.com)\n" + "**\n" + "** This file is part of the test suite of the Qt Toolkit.\n" + "**\n" + "** $QT_BEGIN_LICENSE:LGPL$\n" + "** No Commercial Usage\n" + "** This file contains pre-release code and may not be distributed.\n" + "** You may use this file in accordance with the terms and conditions\n" + "** contained in the Technology Preview License Agreement accompanying\n" + "** this package.\n" + "**\n" + "** GNU Lesser General Public License Usage\n" + "** Alternatively, this file may be used under the terms of the GNU Lesser\n" + "** General Public License version 2.1 as published by the Free Software\n" + "** Foundation and appearing in the file LICENSE.LGPL included in the\n" + "** packaging of this file. Please review the following information to\n" + "** ensure the GNU Lesser General Public License version 2.1 requirements\n" + "** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.\n" + "**\n" + "** In addition, as a special exception, Nokia gives you certain additional\n" + "** rights. These rights are described in the Nokia Qt LGPL Exception\n" + "** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.\n" + "**\n" + "** If you have questions regarding the use of this file, please contact\n" + "** Nokia at qt-info@nokia.com.\n" + "**\n" + "**\n" + "**\n" + "**\n" + "**\n" + "**\n" + "**\n" + "**\n" + "** $QT_END_LICENSE$\n" + "**\n" + "****************************************************************************/\n" + "\n" + "#ifndef FRAGMENTPROGRAMS_P_H\n" + "#define FRAGMENTPROGRAMS_P_H\n" + "\n" + "//\n" + "// W A R N I N G\n" + "// -------------\n" + "//\n" + "// This file is not part of the Qt API. It exists purely as an\n" + "// implementation detail. This header file may change from version to\n" + "// version without notice, or even be removed.\n" + "//\n" + "// We mean it.\n" + "//\n" + "\n"; out << "enum FragmentVariable {\n"; foreach (QString str, variables) -- cgit v0.12 From ebc0079ee5fa70564816817a2ea4aecd7ff189db Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 10 Sep 2009 14:42:58 +0200 Subject: tst_qinfo: Be more verbose in case of failures --- tests/auto/qhostinfo/tst_qhostinfo.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp index 1fd805a..5f4dfaf 100644 --- a/tests/auto/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp @@ -236,6 +236,9 @@ void tst_QHostInfo::lookupIPv4() QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(lookupDone); + if ((int)lookupResults.error() != (int)err) { + qWarning() << hostname << "=>" << lookupResults.errorString(); + } QCOMPARE((int)lookupResults.error(), (int)err); QStringList tmp; @@ -351,6 +354,9 @@ void tst_QHostInfo::blockingLookup() tmp.append(hostInfo.addresses().at(i).toString()); tmp.sort(); + if ((int)hostInfo.error() != (int)err) { + qWarning() << hostname << "=>" << lookupResults.errorString(); + } QCOMPARE((int)hostInfo.error(), (int)err); QStringList expected = addresses.split(' '); -- cgit v0.12 From 77945d775006c296632c293fb320c5308901d5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 10 Sep 2009 14:40:52 +0200 Subject: Only reset the backend pointer after we're done with it Since 925912ebf552417306a5bd20fd986afda6a582be QNetworkReplyImplPrivate no longer holds its own pointer to the network cache and relies on the backend to get it. Since the cache is used in our call to finished, we must reset the backend only after that. This fixes a crash I was seeing in Arora... Reviewed-by: Markus Goetz Reviewed-by: Peter Hartmann --- src/network/access/qnetworkreplyimpl.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 29bf238..87dd19a 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -540,10 +540,6 @@ void QNetworkReplyImpl::abort() return; // stop both upload and download - if (d->backend) { - d->backend->deleteLater(); - d->backend = 0; - } if (d->outgoingData) disconnect(d->outgoingData, 0, this, 0); if (d->copyDevice) @@ -557,6 +553,12 @@ void QNetworkReplyImpl::abort() d->finished(); } d->state = QNetworkReplyImplPrivate::Aborted; + + // finished may access the backend + if (d->backend) { + d->backend->deleteLater(); + d->backend = 0; + } } void QNetworkReplyImpl::close() -- cgit v0.12 From cc59689e4a09349b7475426bf98f4c0839f6ba6a Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 10 Sep 2009 15:41:42 +0200 Subject: QHttpNetworkConnection autotest: include zlib dir test was not building Reviewed-by: Trust Me --- tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro b/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro index 9593c55..2e41fcd 100644 --- a/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro +++ b/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro @@ -1,4 +1,5 @@ load(qttest_p4) SOURCES += tst_qhttpnetworkreply.cpp +INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/zlib QT = core network -- cgit v0.12 From 53e1c8983b0093ce2b63f90eaee856f57961c00f Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 10 Sep 2009 15:55:08 +0200 Subject: restoring a minimized window on Windows CE didn't work After restoring a minimized window we only saw the window decoration. All content was missing. That's because we don't get a WM_SIZE message for restoring the window. We must react on WM_ACTIVATE in this case. This fixes the issue for Windows mobile too. Task-number: 260702 Reviewed-by: thartman --- src/gui/kernel/qapplication_win.cpp | 8 ++++++-- src/gui/kernel/qguifunctions_wince.cpp | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index d7d079c..1babb69 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -2084,8 +2084,12 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam // where it got it from; it would simply get a 0 value as the old focus widget. #ifdef Q_OS_WINCE { - if (widget->windowState() & Qt::WindowMinimized) - widget->dataPtr()->window_state &= ~Qt::WindowMinimized; + if (widget->windowState() & Qt::WindowMinimized) { + if (widget->windowState() & Qt::WindowMaximized) + widget->showMaximized(); + else + widget->show(); + } #else if (!(widget->windowState() & Qt::WindowMinimized)) { #endif diff --git a/src/gui/kernel/qguifunctions_wince.cpp b/src/gui/kernel/qguifunctions_wince.cpp index 6d6aec8..4bfc14b 100644 --- a/src/gui/kernel/qguifunctions_wince.cpp +++ b/src/gui/kernel/qguifunctions_wince.cpp @@ -314,8 +314,8 @@ void qt_wince_maximize(QWidget *widget) } } -void qt_wince_minimize(HWND hwnd) { - +void qt_wince_minimize(HWND hwnd) +{ uint exstyle = GetWindowLongW(hwnd, GWL_EXSTYLE); uint style = GetWindowLongW(hwnd, GWL_STYLE); RECT rect; @@ -324,10 +324,13 @@ void qt_wince_minimize(HWND hwnd) { AdjustWindowRectEx(&crect, style & ~WS_OVERLAPPED, FALSE, exstyle); MoveWindow(hwnd, rect.left - crect.left, rect.top - crect.top, 0, 0, true); SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong (hwnd, GWL_EXSTYLE) | WS_EX_NODRAG); +#ifdef Q_OS_WINCE_WM ShowWindow(hwnd, SW_HIDE); +#else + ShowWindow(hwnd, SW_MINIMIZE); +#endif } - void qt_wince_hide_taskbar(HWND hwnd) { if (ptrAygFullScreen) ptrAygFullScreen(hwnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON); -- cgit v0.12 From 7c52bd0b28eaf0b1d5435fda6140a9d05fddba19 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 11 Sep 2009 08:30:20 +1000 Subject: Make an EGL context current when initializing GL extensions Reviewed-by: trustme --- src/opengl/qgl_qws.cpp | 23 +++++++++++++++++++++++ src/opengl/qgl_wince.cpp | 7 +++++++ src/opengl/qgl_x11egl.cpp | 7 +++++++ 3 files changed, 37 insertions(+) diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp index c71ceeb..759f9de 100644 --- a/src/opengl/qgl_qws.cpp +++ b/src/opengl/qgl_qws.cpp @@ -41,6 +41,7 @@ #include "qgl.h" #include "qgl_egl_p.h" +#include "qglpixelbuffer.h" #include #include @@ -411,7 +412,29 @@ void QGLExtensions::init() if (init_done) return; init_done = true; + + // We need a context current to initialize the extensions, + // but getting a valid EGLNativeWindowType this early can be + // problematic under QWS. So use a pbuffer instead. + // + // Unfortunately OpenGL/ES 2.0 systems don't normally + // support pbuffers, so we have no choice but to try + // our luck with a window on those systems. +#if defined(QT_OPENGL_ES_2) + QGLWidget tmpWidget; + tmpWidget.makeCurrent(); + init_extensions(); + + tmpWidget.doneCurrent(); +#else + QGLPixelBuffer pbuffer(16, 16); + pbuffer.makeCurrent(); + + init_extensions(); + + pbuffer.doneCurrent(); +#endif } QT_END_NAMESPACE diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp index 881d7f7..83efca8 100644 --- a/src/opengl/qgl_wince.cpp +++ b/src/opengl/qgl_wince.cpp @@ -730,7 +730,14 @@ void QGLExtensions::init() if (init_done) return; init_done = true; + + // We need a context current to initialize the extensions. + QGLWidget tmpWidget; + tmpWidget.makeCurrent(); + init_extensions(); + + tmpWidget.doneCurrent(); } QT_END_NAMESPACE diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 055138d..c54315f 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -470,7 +470,14 @@ void QGLExtensions::init() if (init_done) return; init_done = true; + + // We need a context current to initialize the extensions. + QGLWidget tmpWidget; + tmpWidget.makeCurrent(); + init_extensions(); + + tmpWidget.doneCurrent(); } // Re-creates the EGL surface if the window ID has changed or if force is true -- cgit v0.12 From c5455e3aa004cc8ecf430b15def1d2000c886f45 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 11 Sep 2009 09:49:50 +1000 Subject: Resolve ARB_framebuffer_object and OES_framebuffer_object extensions Reviewed-by: trustme --- src/opengl/qgl.cpp | 9 +++++ src/opengl/qglextensions.cpp | 84 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 75 insertions(+), 18 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 8a9ea1c..acb4d4f 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4815,6 +4815,15 @@ void QGLExtensions::init_extensions() glExtensions |= FramebufferObject; glExtensions |= GenerateMipmap; #endif +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) + if (extensions.contains(QLatin1String("OES_framebuffer_object"))) + glExtensions |= FramebufferObject; +#endif + if (extensions.contains(QLatin1String("ARB_framebuffer_object"))) { + // ARB_framebuffer_object also includes EXT_framebuffer_blit. + glExtensions |= FramebufferObject; + glExtensions |= FramebufferBlit; + } if (extensions.contains(QLatin1String("EXT_framebuffer_blit"))) glExtensions |= FramebufferBlit; diff --git a/src/opengl/qglextensions.cpp b/src/opengl/qglextensions.cpp index 8c8d46c..69946a1 100644 --- a/src/opengl/qglextensions.cpp +++ b/src/opengl/qglextensions.cpp @@ -43,6 +43,52 @@ QT_BEGIN_NAMESPACE +static void *qt_gl_getProcAddress_search + (QGLContext *ctx, const char *name1, const char *name2, + const char *name3, const char *name4) +{ + void *addr; + + addr = ctx->getProcAddress(QLatin1String(name1)); + if (addr) + return addr; + + addr = ctx->getProcAddress(QLatin1String(name2)); + if (addr) + return addr; + + addr = ctx->getProcAddress(QLatin1String(name3)); + if (addr) + return addr; + + if (name4) + return ctx->getProcAddress(QLatin1String(name4)); + + return 0; +} + +// Search for an extension function starting with the most likely +// function suffix first, and then trying the other variations. +#if defined(QT_OPENGL_ES) +#define qt_gl_getProcAddress(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name, name "OES", name "EXT", name "ARB") +#define qt_gl_getProcAddressEXT(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name "OES", name, name "EXT", name "ARB") +#define qt_gl_getProcAddressARB(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name "OES", name, name "ARB", name "EXT") +#define qt_gl_getProcAddressOES(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name "OES", name, name "EXT", name "ARB") +#else +#define qt_gl_getProcAddress(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name, name "ARB", name "EXT", 0) +#define qt_gl_getProcAddressEXT(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name "EXT", name, name "ARB", 0) +#define qt_gl_getProcAddressARB(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name "ARB", name, name "EXT", 0) +#define qt_gl_getProcAddressOES(ctx,name) \ + qt_gl_getProcAddress_search((ctx), name "OES", name, name "EXT", name "ARB") +#endif + bool qt_resolve_framebufferobject_extensions(QGLContext *ctx) { #if defined(QT_OPENGL_ES_2) @@ -62,30 +108,32 @@ bool qt_resolve_framebufferobject_extensions(QGLContext *ctx) } - glBlitFramebufferEXT = (_glBlitFramebufferEXT) ctx->getProcAddress(QLatin1String("glBlitFramebufferEXT")); + glBlitFramebufferEXT = (_glBlitFramebufferEXT) qt_gl_getProcAddressEXT(ctx, "glBlitFramebuffer"); glRenderbufferStorageMultisampleEXT = - (_glRenderbufferStorageMultisampleEXT) ctx->getProcAddress(QLatin1String("glRenderbufferStorageMultisampleEXT")); + (_glRenderbufferStorageMultisampleEXT) qt_gl_getProcAddressEXT(ctx, "glRenderbufferStorageMultisample"); #if !defined(QT_OPENGL_ES_2) - glIsRenderbuffer = (_glIsRenderbuffer) ctx->getProcAddress(QLatin1String("glIsRenderbufferEXT")); - glBindRenderbuffer = (_glBindRenderbuffer) ctx->getProcAddress(QLatin1String("glBindRenderbufferEXT")); - glDeleteRenderbuffers = (_glDeleteRenderbuffers) ctx->getProcAddress(QLatin1String("glDeleteRenderbuffersEXT")); - glGenRenderbuffers = (_glGenRenderbuffers) ctx->getProcAddress(QLatin1String("glGenRenderbuffersEXT")); - glRenderbufferStorage = (_glRenderbufferStorage) ctx->getProcAddress(QLatin1String("glRenderbufferStorageEXT")); + glIsRenderbuffer = (_glIsRenderbuffer) qt_gl_getProcAddressEXT(ctx, "glIsRenderbuffer"); + if (!glIsRenderbuffer) + return false; // Not much point searching for anything else. + glBindRenderbuffer = (_glBindRenderbuffer) qt_gl_getProcAddressEXT(ctx, "glBindRenderbuffer"); + glDeleteRenderbuffers = (_glDeleteRenderbuffers) qt_gl_getProcAddressEXT(ctx, "glDeleteRenderbuffers"); + glGenRenderbuffers = (_glGenRenderbuffers) qt_gl_getProcAddressEXT(ctx, "glGenRenderbuffers"); + glRenderbufferStorage = (_glRenderbufferStorage) qt_gl_getProcAddressEXT(ctx, "glRenderbufferStorage"); glGetRenderbufferParameteriv = - (_glGetRenderbufferParameteriv) ctx->getProcAddress(QLatin1String("glGetRenderbufferParameterivEXT")); - glIsFramebuffer = (_glIsFramebuffer) ctx->getProcAddress(QLatin1String("glIsFramebufferEXT")); - glBindFramebuffer = (_glBindFramebuffer) ctx->getProcAddress(QLatin1String("glBindFramebufferEXT")); - glDeleteFramebuffers = (_glDeleteFramebuffers) ctx->getProcAddress(QLatin1String("glDeleteFramebuffersEXT")); - glGenFramebuffers = (_glGenFramebuffers) ctx->getProcAddress(QLatin1String("glGenFramebuffersEXT")); - glCheckFramebufferStatus = (_glCheckFramebufferStatus) ctx->getProcAddress(QLatin1String("glCheckFramebufferStatusEXT")); - glFramebufferTexture2D = (_glFramebufferTexture2D) ctx->getProcAddress(QLatin1String("glFramebufferTexture2DEXT")); - glFramebufferRenderbuffer = (_glFramebufferRenderbuffer) ctx->getProcAddress(QLatin1String("glFramebufferRenderbufferEXT")); + (_glGetRenderbufferParameteriv) qt_gl_getProcAddressEXT(ctx, "glGetRenderbufferParameteriv"); + glIsFramebuffer = (_glIsFramebuffer) qt_gl_getProcAddressEXT(ctx, "glIsFramebuffer"); + glBindFramebuffer = (_glBindFramebuffer) qt_gl_getProcAddressEXT(ctx, "glBindFramebuffer"); + glDeleteFramebuffers = (_glDeleteFramebuffers) qt_gl_getProcAddressEXT(ctx, "glDeleteFramebuffers"); + glGenFramebuffers = (_glGenFramebuffers) qt_gl_getProcAddressEXT(ctx, "glGenFramebuffers"); + glCheckFramebufferStatus = (_glCheckFramebufferStatus) qt_gl_getProcAddressEXT(ctx, "glCheckFramebufferStatus"); + glFramebufferTexture2D = (_glFramebufferTexture2D) qt_gl_getProcAddressEXT(ctx, "glFramebufferTexture2D"); + glFramebufferRenderbuffer = (_glFramebufferRenderbuffer) qt_gl_getProcAddressEXT(ctx, "glFramebufferRenderbuffer"); glGetFramebufferAttachmentParameteriv = - (_glGetFramebufferAttachmentParameteriv) ctx->getProcAddress(QLatin1String("glGetFramebufferAttachmentParameterivEXT")); - glGenerateMipmap = (_glGenerateMipmap) ctx->getProcAddress(QLatin1String("glGenerateMipmapEXT")); + (_glGetFramebufferAttachmentParameteriv) qt_gl_getProcAddressEXT(ctx, "glGetFramebufferAttachmentParameteriv"); + glGenerateMipmap = (_glGenerateMipmap) qt_gl_getProcAddressEXT(ctx, "glGenerateMipmap"); - return glIsRenderbuffer; + return glIsRenderbuffer != 0; #else return true; #endif -- cgit v0.12 From f5417ce0e6c46b56a21b7bc968cc67b22d894392 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 11 Sep 2009 10:10:50 +1000 Subject: Resolve GL buffer functions in a better way This change should make qt_resolve_buffer_extensions() handle all of the ARB, OES, and regular name variants for glBindBuffer(), etc that may occur in the wild. Reviewed-by: trustme --- src/opengl/qglextensions.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/opengl/qglextensions.cpp b/src/opengl/qglextensions.cpp index 69946a1..3699d62 100644 --- a/src/opengl/qglextensions.cpp +++ b/src/opengl/qglextensions.cpp @@ -199,13 +199,13 @@ bool qt_resolve_buffer_extensions(QGLContext *ctx) return true; #if !defined(QT_OPENGL_ES_2) - glBindBuffer = (_glBindBuffer) ctx->getProcAddress(QLatin1String("glBindBufferARB")); - glDeleteBuffers = (_glDeleteBuffers) ctx->getProcAddress(QLatin1String("glDeleteBuffersARB")); - glGenBuffers = (_glGenBuffers) ctx->getProcAddress(QLatin1String("glGenBuffersARB")); - glBufferData = (_glBufferData) ctx->getProcAddress(QLatin1String("glBufferDataARB")); + glBindBuffer = (_glBindBuffer) qt_gl_getProcAddressARB(ctx, "glBindBuffer"); + glDeleteBuffers = (_glDeleteBuffers) qt_gl_getProcAddressARB(ctx, "glDeleteBuffers"); + glGenBuffers = (_glGenBuffers) qt_gl_getProcAddressARB(ctx, "glGenBuffers"); + glBufferData = (_glBufferData) qt_gl_getProcAddressARB(ctx, "glBufferData"); #endif - glMapBufferARB = (_glMapBufferARB) ctx->getProcAddress(QLatin1String("glMapBufferARB")); - glUnmapBufferARB = (_glUnmapBufferARB) ctx->getProcAddress(QLatin1String("glUnmapBufferARB")); + glMapBufferARB = (_glMapBufferARB) qt_gl_getProcAddressARB(ctx, "glMapBuffer"); + glUnmapBufferARB = (_glUnmapBufferARB) qt_gl_getProcAddressARB(ctx, "glUnmapBuffer"); return glMapBufferARB && glUnmapBufferARB -- cgit v0.12 From 88035568a9eb19fe92595eff6d5df1ecb493916d Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 11 Sep 2009 10:24:56 +1000 Subject: Recognize the OES_packed_depth_stencil extension Reviewed-by: trustme --- src/opengl/qgl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index acb4d4f..bb20b6d 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4819,6 +4819,10 @@ void QGLExtensions::init_extensions() if (extensions.contains(QLatin1String("OES_framebuffer_object"))) glExtensions |= FramebufferObject; #endif +#if defined(QT_OPENGL_ES) + if (extensions.contains(QLatin1String("OES_packed_depth_stencil"))) + glExtensions |= PackedDepthStencil; +#endif if (extensions.contains(QLatin1String("ARB_framebuffer_object"))) { // ARB_framebuffer_object also includes EXT_framebuffer_blit. glExtensions |= FramebufferObject; -- cgit v0.12 From f9243aac1e26ccf9f46cc1d7de5f57063a053211 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 11 Sep 2009 14:53:00 +1000 Subject: Dump texture formats in hex, not decimal Reviewed-by: trustme --- src/opengl/qgl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index bb20b6d..0e05b10 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2183,8 +2183,8 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G } } #ifdef QGL_BIND_TEXTURE_DEBUG - printf(" - uploading, image.format=%d, externalFormat=0x%d, internalFormat=0x%d\n", - img.format(), externalFormat, internalFormat); + printf(" - uploading, image.format=%d, externalFormat=0x%x, internalFormat=0x%x, pixel_type=0x%x\n", + img.format(), externalFormat, internalFormat, pixel_type); #endif const QImage &constRef = img; // to avoid detach in bits()... -- cgit v0.12 From aad2316995d46cb8a1bfc2763c0617b0c7c92307 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Fri, 11 Sep 2009 07:27:16 +0200 Subject: Run on 10.3 Panther. HIViewSetNeedsDisplayInRect was added in 10.4. --- src/gui/kernel/qwidget_mac.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index c5418f6..09ac2c3 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3781,7 +3781,10 @@ static void qt_mac_update_widget_posisiton(QWidget *q, QRect oldRect, QRect newR (oldRect.isValid() == false || newRect.isValid() == false) || // the position update is a part of a drag-and-drop operation - QDragManager::self()->object + QDragManager::self()->object || + + // we are on Panther (no HIViewSetNeedsDisplayInRect) + QSysInfo::MacintoshVersion < QSysInfo::MV_10_4 ){ HIViewSetFrame(view, &bounds); return; -- cgit v0.12 From 8ee8f3383c05c0e82d81304f60b97ca7659074cc Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Fri, 11 Sep 2009 07:51:09 +0200 Subject: Run on 10.3. _HIViewScrollRectWithOptions needs to be declared as a weak-linked symbol in order to make static linking work. --- src/gui/kernel/qwidget_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 09ac2c3..987d2ae 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -122,7 +122,7 @@ QT_BEGIN_NAMESPACE extern "C" { extern OSStatus _HIViewScrollRectWithOptions(HIViewRef, const HIRect *, CGFloat, CGFloat, - OptionBits); + OptionBits) __attribute__ ((weak)); } #define kHIViewScrollRectAdjustInvalid 1 #define kHIViewScrollRectDontInvalidateRevealedArea 2 -- cgit v0.12 From 4b1a48f212c7624e9c1976c9e7c92a08b4fb307d Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 11 Sep 2009 16:37:53 +1000 Subject: Port the textures example to OpenGL/ES 2.0 Reviewed-by: trustme --- examples/opengl/opengl.pro | 6 +- examples/opengl/textures/glwidget.cpp | 110 ++++++++++++++++++++++++---------- examples/opengl/textures/glwidget.h | 10 +++- 3 files changed, 91 insertions(+), 35 deletions(-) diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro index b86e0ba..2cb8227 100644 --- a/examples/opengl/opengl.pro +++ b/examples/opengl/opengl.pro @@ -5,9 +5,9 @@ contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles1cl)|contains(QT_CONF SUBDIRS = hellogl_es2 } else { SUBDIRS = hellogl_es - !contains(QT_CONFIG, opengles1cl) { - SUBDIRS += textures - } + } + !contains(QT_CONFIG, opengles1cl) { + SUBDIRS += textures } } else { SUBDIRS = 2dpainting \ diff --git a/examples/opengl/textures/glwidget.cpp b/examples/opengl/textures/glwidget.cpp index 024133b..6efd31a 100644 --- a/examples/opengl/textures/glwidget.cpp +++ b/examples/opengl/textures/glwidget.cpp @@ -44,16 +44,6 @@ #include "glwidget.h" -class CubeObject -{ -public: - GLuint textures[6]; - QVector vertices; - QVector texCoords; - - void draw(); -}; - GLWidget::GLWidget(QWidget *parent, QGLWidget *shareWidget) : QGLWidget(parent, shareWidget) { @@ -61,12 +51,13 @@ GLWidget::GLWidget(QWidget *parent, QGLWidget *shareWidget) xRot = 0; yRot = 0; zRot = 0; - cube = 0; +#ifdef QT_OPENGL_ES_2 + program = 0; +#endif } GLWidget::~GLWidget() { - delete cube; } QSize GLWidget::minimumSizeHint() const @@ -99,19 +90,90 @@ void GLWidget::initializeGL() glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); +#ifndef QT_OPENGL_ES_2 glEnable(GL_TEXTURE_2D); +#endif + +#ifdef QT_OPENGL_ES_2 + +#define PROGRAM_VERTEX_ATTRIBUTE 0 +#define PROGRAM_TEXCOORD_ATTRIBUTE 1 + + QGLShader *vshader = new QGLShader(QGLShader::VertexShader, this); + const char *vsrc = + "attribute highp vec4 vertex;\n" + "attribute mediump vec4 texCoord;\n" + "varying mediump vec4 texc;\n" + "uniform mediump mat4 matrix;\n" + "void main(void)\n" + "{\n" + " gl_Position = matrix * vertex;\n" + " texc = texCoord;\n" + "}\n"; + vshader->compile(vsrc); + + QGLShader *fshader = new QGLShader(QGLShader::FragmentShader, this); + const char *fsrc = + "uniform sampler2D texture;\n" + "varying mediump vec4 texc;\n" + "void main(void)\n" + "{\n" + " gl_FragColor = texture2D(texture, texc.st);\n" + "}\n"; + fshader->compile(fsrc); + + program = new QGLShaderProgram(this); + program->addShader(vshader); + program->addShader(fshader); + program->bindAttributeLocation("vertex", PROGRAM_VERTEX_ATTRIBUTE); + program->bindAttributeLocation("texCoord", PROGRAM_TEXCOORD_ATTRIBUTE); + program->link(); + + program->enable(); + program->setUniformValue("texture", 0); + +#endif } void GLWidget::paintGL() { qglClearColor(clearColor); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + +#if !defined(QT_OPENGL_ES_2) + glLoadIdentity(); glTranslatef(0.0f, 0.0f, -10.0f); glRotatef(xRot / 16.0f, 1.0f, 0.0f, 0.0f); glRotatef(yRot / 16.0f, 0.0f, 1.0f, 0.0f); glRotatef(zRot / 16.0f, 0.0f, 0.0f, 1.0f); - cube->draw(); + + glVertexPointer(3, GL_FLOAT, 0, vertices.constData()); + glTexCoordPointer(2, GL_FLOAT, 0, texCoords.constData()); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + +#else + + QMatrix4x4 m; + m.ortho(-0.5f, +0.5f, +0.5f, -0.5f, 4.0f, 15.0f); + m.translate(0.0f, 0.0f, -10.0f); + m.rotate(xRot / 16.0f, 1.0f, 0.0f, 0.0f); + m.rotate(yRot / 16.0f, 0.0f, 1.0f, 0.0f); + m.rotate(zRot / 16.0f, 0.0f, 0.0f, 1.0f); + + program->setUniformValue("matrix", m); + program->setAttributeArray + (PROGRAM_VERTEX_ATTRIBUTE, vertices.constData()); + program->setAttributeArray + (PROGRAM_TEXCOORD_ATTRIBUTE, texCoords.constData()); + +#endif + + for (int i = 0; i < 6; ++i) { + glBindTexture(GL_TEXTURE_2D, textures[i]); + glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4); + } } void GLWidget::resizeGL(int width, int height) @@ -119,6 +181,7 @@ void GLWidget::resizeGL(int width, int height) int side = qMin(width, height); glViewport((width - side) / 2, (height - side) / 2, side, side); +#if !defined(QT_OPENGL_ES_2) glMatrixMode(GL_PROJECTION); glLoadIdentity(); #ifndef QT_OPENGL_ES @@ -127,6 +190,7 @@ void GLWidget::resizeGL(int width, int height) glOrthof(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); #endif glMatrixMode(GL_MODELVIEW); +#endif } void GLWidget::mousePressEvent(QMouseEvent *event) @@ -163,32 +227,18 @@ void GLWidget::makeObject() { { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } } }; - cube = new CubeObject(); - for (int j=0; j < 6; ++j) { - cube->textures[j] = bindTexture + textures[j] = bindTexture (QPixmap(QString(":/images/side%1.png").arg(j + 1)), GL_TEXTURE_2D); } for (int i = 0; i < 6; ++i) { for (int j = 0; j < 4; ++j) { - cube->texCoords.append + texCoords.append (QVector2D(j == 0 || j == 3, j == 0 || j == 1)); - cube->vertices.append + vertices.append (QVector3D(0.2 * coords[i][j][0], 0.2 * coords[i][j][1], 0.2 * coords[i][j][2])); } } } - -void CubeObject::draw() -{ - glVertexPointer(3, GL_FLOAT, 0, vertices.constData()); - glTexCoordPointer(2, GL_FLOAT, 0, texCoords.constData()); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - for (int i = 0; i < 6; ++i) { - glBindTexture(GL_TEXTURE_2D, textures[i]); - glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4); - } -} diff --git a/examples/opengl/textures/glwidget.h b/examples/opengl/textures/glwidget.h index 46507ce..4dcff3b 100644 --- a/examples/opengl/textures/glwidget.h +++ b/examples/opengl/textures/glwidget.h @@ -42,9 +42,10 @@ #ifndef GLWIDGET_H #define GLWIDGET_H +#include #include -class CubeObject; +class QGLShaderProgram; class GLWidget : public QGLWidget { @@ -78,7 +79,12 @@ private: int xRot; int yRot; int zRot; - CubeObject *cube; + GLuint textures[6]; + QVector vertices; + QVector texCoords; +#ifdef QT_OPENGL_ES_2 + QGLShaderProgram *program; +#endif }; #endif -- cgit v0.12 From 02df785c9d95cdafe47a087d29a25f08bfb9e387 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 11 Sep 2009 16:50:24 +1000 Subject: Make mipmaps work on OpenGL/ES 2.0 Reviewed-by: Gunnar --- src/opengl/qgl.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 0e05b10..9148456 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2070,6 +2070,9 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G glBindTexture(target, tx_id); glTexParameterf(target, GL_TEXTURE_MAG_FILTER, filtering); +#if defined(QT_OPENGL_ES_2) + bool genMipmap = false; +#endif if (glFormat.directRendering() && QGLExtensions::glExtensions & QGLExtensions::GenerateMipmap && target == GL_TEXTURE_2D @@ -2078,12 +2081,17 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G #ifdef QGL_BIND_TEXTURE_DEBUG printf(" - generating mipmaps\n"); #endif +#if !defined(QT_OPENGL_ES_2) glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST); #ifndef QT_OPENGL_ES glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); #else glTexParameterf(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); #endif +#else + glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST); + genMipmap = true; +#endif glTexParameterf(target, GL_TEXTURE_MIN_FILTER, options & QGLContext::LinearFilteringBindOption ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST); } else { @@ -2190,6 +2198,10 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G const QImage &constRef = img; // to avoid detach in bits()... glTexImage2D(target, 0, internalFormat, img.width(), img.height(), 0, externalFormat, pixel_type, constRef.bits()); +#if defined(QT_OPENGL_ES_2) + if (genMipmap) + glGenerateMipmap(target); +#endif #ifndef QT_NO_DEBUG GLenum error = glGetError(); if (error != GL_NO_ERROR) { -- cgit v0.12 From ebefcd1c0d4286a58bea2b4859d471df07f1f013 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 11 Sep 2009 10:00:26 +0300 Subject: Optimized S60 version check. Use pure Symbian code to get S60 version, because if done using QDir, there will be a call back to this method, resulting doing this expensive operation twice before the cache kicks in. Pure Symbian code also makes this method ~10x faster, speeding up the application launch. Task-number: 260757 Reviewed-by: Janne Anttila --- src/corelib/global/qglobal.cpp | 50 ++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index a790dc1..9909b7b 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -75,6 +75,11 @@ #if defined(Q_OS_SYMBIAN) #include #include +#include +# include "private/qcore_symbian_p.h" + +_LIT(qt_S60Filter, "Series60v?.*.sis"); +_LIT(qt_S60SystemInstallDir, "z:\\system\\install\\"); #endif QT_BEGIN_NAMESPACE @@ -1786,28 +1791,31 @@ QSysInfo::S60Version QSysInfo::s60Version() if (cachedS60Version != -1) return cachedS60Version; - QDir dir(QLatin1String("z:\\system\\install")); - QStringList filters; - filters << QLatin1String("Series60v?.*.sis"); - dir.setNameFilters(filters); - - QStringList names = dir.entryList(QDir::NoFilter, QDir::Name | QDir::Reversed | QDir::IgnoreCase); - if (names.size() == 0) - return cachedS60Version = SV_S60_Unknown; - - int major, minor; - major = names[0][9].toAscii() - '0'; - minor = names[0][11].toAscii() - '0'; - if (major == 3) { - if (minor == 1) { - return cachedS60Version = SV_S60_3_1; - } else if (minor == 2) { - return cachedS60Version = SV_S60_3_2; - } - } else if (major == 5) { - if (minor == 0) { - return cachedS60Version = SV_S60_5_0; + // Use pure Symbian code, because if done using QDir, there will be a call back + // to this method, resulting doing this expensive operation twice before the cache kicks in. + // Pure Symbian code also makes this method ~10x faster, speeding up the application launch. + RFs rfs = qt_s60GetRFs(); + TFindFile fileFinder(rfs); + CDir* contents; + TInt err = fileFinder.FindWildByDir(qt_S60Filter, qt_S60SystemInstallDir, contents); + if (err == KErrNone) { + err = contents->Sort(EDescending|ESortByName); + if (err == KErrNone) { + TInt major = (*contents)[0].iName[9] - '0'; + TInt minor = (*contents)[0].iName[11] - '0'; + if (major == 3) { + if (minor == 1) { + return cachedS60Version = SV_S60_3_1; + } else if (minor == 2) { + return cachedS60Version = SV_S60_3_2; + } + } else if (major == 5) { + if (minor == 0) { + return cachedS60Version = SV_S60_5_0; + } + } } + delete contents; } return cachedS60Version = SV_S60_Unknown; -- cgit v0.12 From 22bbc21ba4c838d6afe000e07f70b470acc87d8b Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 10 Sep 2009 18:38:43 +0200 Subject: make tst_QLocalSocket::writeToClientAndDisconnect even more robust no more qApp->processEvents() ! Reviewed-by: ossi --- tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index c0d870f..1180d4d 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -895,9 +895,9 @@ void tst_QLocalSocket::writeToClientAndDisconnect() QCOMPARE(clientSocket->write(buffer, sizeof(buffer)), (qint64)sizeof(buffer)); clientSocket->waitForBytesWritten(); clientSocket->disconnectFromServer(); - qApp->processEvents(); // give the socket the chance to receive data + QVERIFY(client.waitForReadyRead()); QCOMPARE(client.read(buffer, sizeof(buffer)), (qint64)sizeof(buffer)); - qApp->processEvents(); // give the socket the chance to close itself + QVERIFY(client.waitForDisconnected()); QCOMPARE(client.state(), QLocalSocket::UnconnectedState); } -- cgit v0.12 From 3fd024c6d9f0b0998efc44a783ee8390c6494dfa Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 10 Sep 2009 18:44:52 +0200 Subject: QLocalSocket (Win) emit readChannelFinished only once If pipeClosed is true, then we've already emitted the readChannelFinished signal. We must not do this in close() in that case. Reviewed-by: ossi --- src/network/socket/qlocalsocket_win.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index d6e70be..8a745ab 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -375,7 +375,8 @@ void QLocalSocket::close() QIODevice::close(); d->state = ClosingState; emit stateChanged(d->state); - emit readChannelFinished(); + if (!d->pipeClosed) + emit readChannelFinished(); d->serverName = QString(); d->fullServerName = QString(); -- cgit v0.12 From dacb14e457b40b6839e9f17ec968e95e29113d20 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Fri, 11 Sep 2009 11:13:28 +0300 Subject: Fixed QWidget::setWindowState for Symbian. Before this commit calling setWindowState(Qt::WindowFullScreen) on a widget instance affected all new widget instances created after this method. This bug happened due to fact that window decorations i.e. statuspane and softkeys visibility was only changed when switching to or from fullscreen state. In the reported bug it happened that second widget was initially in Qt::WindowNoState and it was changed to Maximized. Since window decorations are global not window specific at the moment, the default decoration visibility for second window is the one to which previous window has set them. In this case previous window was in fullscreen and that's why the decorations were visible also for second maximized window. Probably the right fix would be to change the decoration to window specific but that is quite a big change and for now the bug is fixed with this commit. Autotest: Excluding new test case, same results before and after. Task-number: 261048 Reviewed-by: Jason Barron --- src/gui/kernel/qwidget_s60.cpp | 43 ++++++++++++++++++++++++-------------- tests/auto/qwidget/qwidget.pro | 1 + tests/auto/qwidget/tst_qwidget.cpp | 43 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 16 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 94f3532..7509fa5 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -989,6 +989,32 @@ void QWidget::setWindowState(Qt::WindowStates newstate) return; if (isWindow()) { +#ifdef Q_WS_S60 + // Change window decoration visibility if switching to or from fullsccreen + // In addition decoration visibility is changed when the initial has been + // WindowNoState. + // The window decoration visibility has to be changed before doing actual + // window state change since in that order the availableGeometry will return + // directly the right size and we will avoid unnecessarty redraws + if((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen) || + oldstate == Qt::WindowNoState) { + CEikStatusPane* statusPane = S60->statusPane(); + CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer(); + if (newstate & Qt::WindowFullScreen) { + if (statusPane) + statusPane->MakeVisible(false); + if (buttonGroup) + buttonGroup->MakeVisible(false); + } else { + if (statusPane) + statusPane->MakeVisible(true); + if (buttonGroup) + buttonGroup->MakeVisible(true); + } + + } +#endif // Q_WS_S60 + createWinId(); Q_ASSERT(testAttribute(Qt::WA_WState_Created)); QTLWExtra *top = d->topData(); @@ -1013,30 +1039,15 @@ void QWidget::setWindowState(Qt::WindowStates newstate) } } if ((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen)) { -#ifdef Q_WS_S60 - CEikStatusPane* statusPane = S60->statusPane(); - CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer(); -#endif if (newstate & Qt::WindowFullScreen) { const QRect normalGeometry = geometry(); const QRect r = top->normalGeometry; setGeometry(qApp->desktop()->screenGeometry(this)); -#ifdef Q_WS_S60 - if (statusPane) - statusPane->MakeVisible(false); - if (buttonGroup) - buttonGroup->MakeVisible(false); -#endif + top->normalGeometry = r; if (top->normalGeometry.width() < 0) top->normalGeometry = normalGeometry; } else { -#ifdef Q_WS_S60 - if (statusPane) - statusPane->MakeVisible(true); - if (buttonGroup) - buttonGroup->MakeVisible(true); -#endif if (newstate & Qt::WindowMaximized) { const QRect r = top->normalGeometry; setGeometry(qApp->desktop()->availableGeometry(this)); diff --git a/tests/auto/qwidget/qwidget.pro b/tests/auto/qwidget/qwidget.pro index 59c1753..def28f5 100644 --- a/tests/auto/qwidget/qwidget.pro +++ b/tests/auto/qwidget/qwidget.pro @@ -16,6 +16,7 @@ OBJECTIVE_SOURCES += tst_qwidget_mac_helpers.mm symbian { INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE + LIBS += -leikcore -lcone -leikcoctl } !wince*:!symbian:win32: LIBS += -luser32 -lgdi32 diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index b94f381..230b7c9 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -74,6 +74,7 @@ #include // CAknTitlePane #include // CAknContextPane #include // CEikStatusPane +#include // CEikButtonGroupContainer #endif #ifdef Q_WS_QWS @@ -366,6 +367,10 @@ private slots: void setGraphicsEffect(); void destroyBackingStore(); + +#ifdef Q_OS_SYMBIAN + void cbaVisibility(); +#endif private: bool ensureScreenSize(int width, int height); @@ -9323,5 +9328,43 @@ void tst_QWidget::setGraphicsEffect() delete anotherWidget; } +#ifdef Q_OS_SYMBIAN +void tst_QWidget::cbaVisibility() +{ + // Test case for task 261048 + + // Create first mainwindow in fullsreen and activate it + QMainWindow* mainwindow = new QMainWindow(); + QLabel* label = new QLabel(mainwindow); + mainwindow->setCentralWidget(label); + mainwindow->setWindowState(Qt::WindowFullScreen); + mainwindow->setVisible(true); + mainwindow->activateWindow(); + qApp->processEvents(); + + QVERIFY(mainwindow->isActiveWindow()); + QVERIFY(QDesktopWidget().availableGeometry().size() == mainwindow->size()); + + // Create second mainwindow in maximized and activate it + QMainWindow* mainwindow2 = new QMainWindow(); + QLabel* label2 = new QLabel(mainwindow2); + mainwindow2->setCentralWidget(label2); + mainwindow2->setWindowState(Qt::WindowMaximized); + mainwindow2->setVisible(true); + mainwindow2->activateWindow(); + qApp->processEvents(); + + QVERIFY(!mainwindow->isActiveWindow()); + QVERIFY(mainwindow2->isActiveWindow()); + QVERIFY(QDesktopWidget().availableGeometry().size() == mainwindow2->size()); + + // Verify window decorations i.e. status pane and CBA are visible. + CEikStatusPane* statusPane = CEikonEnv::Static()->AppUiFactory()->StatusPane(); + QVERIFY(statusPane->IsVisible()); + CEikButtonGroupContainer* buttonGroup = CEikonEnv::Static()->AppUiFactory()->Cba(); + QVERIFY(buttonGroup->IsVisible()); +} +#endif + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" -- cgit v0.12 From fe9b8d7d2cf9c25ad8c594dda3339c32ea8e876b Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 11 Sep 2009 11:33:06 +0300 Subject: Changed Symbian tests to sleep only when run on emulator. Changed comment to be more accurate and changed ifdefs so that this will only be done for emulator. This issue needs more comprehensive analysis and wide test runs to determine what the pratical impact of removing this delay entirely would be. Task-number: 247270 Reviewed-by: Janne Anttila --- src/testlib/qtestcase.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 830a5ae..b7b2327 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -367,9 +367,9 @@ QT_BEGIN_NAMESPACE this macro. Unlike QBENCHMARK, the contents of the contained code block is only run - once. The elapsed time will be reported as "0" if it's to short to + once. The elapsed time will be reported as "0" if it's to short to be measured by the selected backend. (Use) - + \sa {QTestLib Manual#Creating a Benchmark}{Creating a Benchmark}, {Chapter 5: Writing a Benchmark}{Writing a Benchmark} */ @@ -738,7 +738,7 @@ QT_BEGIN_NAMESPACE \brief The QTouchEventSequence class is used to simulate a sequence of touch events. - To simulate a sequence of touch events on a specific device for a widget, call + To simulate a sequence of touch events on a specific device for a widget, call QTest::touchEvent to create a QTouchEventSequence instance. Add touch events to the sequence by calling press(), move(), release() and stationary(), and let the instance run out of scope to commit the sequence to the event system. @@ -756,7 +756,7 @@ QT_BEGIN_NAMESPACE Adds a press event for touchpoint \a touchId at position \a pt to this sequence and returns a reference to this QTouchEventSequence. - The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then + The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence. Simulates that the user pressed the touch screen or pad with the finger identified by \a touchId. @@ -768,7 +768,7 @@ QT_BEGIN_NAMESPACE Adds a move event for touchpoint \a touchId at position \a pt to this sequence and returns a reference to this QTouchEventSequence. - The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then + The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence. Simulates that the user moved the finger identified by \a touchId. @@ -779,8 +779,8 @@ QT_BEGIN_NAMESPACE Adds a release event for touchpoint \a touchId at position \a pt to this sequence and returns a reference to this QTouchEventSequence. - - The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then + + The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence. Simulates that the user lifted the finger identified by \a touchId. @@ -791,7 +791,7 @@ QT_BEGIN_NAMESPACE Adds a stationary event for touchpoint \a touchId to this sequence and returns a reference to this QTouchEventSequence. - + Simulates that the user did not move the finger identified by \a touchId. */ @@ -1612,8 +1612,11 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) } #endif -#ifdef Q_OS_SYMBIAN -//### FIX THIS temporary hack to delay execution of symbian os tests. Used to get emulator to stable state before running testcase +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + // Delay execution of tests in Symbian emulator. + // Needed to allow worst of other higher priority apps and services launched by emulator + // to get out of the way before we run our test. Otherwise some of the timing sensitive tests + // will not work properly. qSleep(3000); #endif @@ -2124,7 +2127,7 @@ bool QTest::compare_string_helper(const char *t1, const char *t2, const char *ac /*! \fn bool QTest::qCompare(bool const &t1, int const &t2, const char *actual, const char *expected, const char *file, int line) \internal */ - + /*! \fn bool QTest::qTest(const T& actual, const char *elementName, const char *actualStr, const char *expected, const char *file, int line) \internal */ -- cgit v0.12 From d753c7bc9028a97887d2c67f989d468cda39e1c6 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 11 Sep 2009 10:36:23 +0200 Subject: Fixed a bug in the autotest for q3progressbar. The "standard" test would sometimes fail (Mac OS X) because extra paint events could be generated, which would cause paintNumber to be > 1. Comparing it to 1 would fail. This test should be redesigned, I think. --- tests/auto/bic/tst_bic.cpp | 2 +- tests/auto/q3progressbar/tst_q3progressbar.cpp | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp index db0c5ba..82c8dc0 100644 --- a/tests/auto/bic/tst_bic.cpp +++ b/tests/auto/bic/tst_bic.cpp @@ -293,7 +293,7 @@ void tst_Bic::sizesAndVTables() bool isFailed = false; - qDebug() << oldLib.arg(libName); + //qDebug() << oldLib.arg(libName); if (oldLib.isEmpty() || !QFile::exists(oldLib.arg(libName))) QSKIP("No platform spec found for this platform/version.", SkipSingle); diff --git a/tests/auto/q3progressbar/tst_q3progressbar.cpp b/tests/auto/q3progressbar/tst_q3progressbar.cpp index c5485a7..34a95d3 100644 --- a/tests/auto/q3progressbar/tst_q3progressbar.cpp +++ b/tests/auto/q3progressbar/tst_q3progressbar.cpp @@ -93,11 +93,15 @@ class MyCustomProgressBar : public Q3ProgressBar void paintEvent(QPaintEvent * event) { paintNumber++; + qDebug() << "PAINT EVENT:" << paintNumber; Q3ProgressBar::paintEvent(event); } int paintNumber; }; +/* + Maybe this test should be redesigned. + */ void tst_Q3ProgressBar::setProgress() { MyCustomProgressBar * m_progressBar = new MyCustomProgressBar(); @@ -111,15 +115,21 @@ void tst_Q3ProgressBar::setProgress() m_progressBar->setProgress(m_progressBar->progress() + 1); QCOMPARE(oldValue + 1,m_progressBar->progress()); QApplication::processEvents(); - QVERIFY(m_progressBar->paintNumber >= 1); //it might be more than 1 because it is animated + // It might be > 1 because it is animated. + QVERIFY(m_progressBar->paintNumber >= 1); + qDebug() << "Animation test: paintNumber =" << m_progressBar->paintNumber; + //standard case m_progressBar->setTotalSteps(3); m_progressBar->setProgress(0); m_progressBar->paintNumber = 0; m_progressBar->setProgress(m_progressBar->progress() + 1); QApplication::processEvents(); - QCOMPARE(m_progressBar->paintNumber,1); + + // It might be > 1 because other events might cause painting. + QVERIFY(m_progressBar->paintNumber >= 1); + qDebug() << "Standard test: paintNumber =" << m_progressBar->paintNumber; } QTEST_MAIN(tst_Q3ProgressBar) -- cgit v0.12 From c03d1a9e12c9b9766c1e652985aeeab23be352a8 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Thu, 13 Aug 2009 12:37:39 +0200 Subject: Pick a suitable default architecture for qmake-based applications. If the Qt package contains one of x86 and x86_64, pick that one. If it contains both then use the compiler default. Make a similiar decision for PowerPC-based systems. Note that this logic assumes that Qt has been configured with an architecture that is usable on the system. Reviewed-by: Marius Storm-Olsen --- mkspecs/features/mac/default_post.prf | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index ea9e9bd..210a704 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -1,2 +1,18 @@ load(default_post) !no_objective_c:CONFIG += objective_c + +# Pick a suitable default architecture for qmake-based applications. +# If the Qt package contains one of x86 and x86_64, pick that one. If it +# contains both then use the compiler default. Make a similiar decision for +# PowerPC-based systems. Note that this logic assumes that Qt has been +# configured with an architecture that is usable on the system. +message(hei $$QT_CONFIG ) +qt:!isEmpty(QT_CONFIG) { + contains(QMAKE_HOST.arch, ppc) { + !contains(QT_CONFIG, ppc64):contains(QT_CONFIG, ppc):CONFIG += ppc + contains(QT_CONFIG, ppc64):!contains(QT_CONFIG, ppc):CONFIG += ppc64 + } else { + !contains(QT_CONFIG, x86_64):contains(QT_CONFIG, x86):CONFIG += x86 + contains(QT_CONFIG, x86_64):!contains(QT_CONFIG, x86):CONFIG += x86_64 + } +} -- cgit v0.12 From 5a5337879fa4bfeacc1fe11e4b617ba623f22273 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 11 Sep 2009 10:18:12 +0200 Subject: Clean up properly in the QPF1 font engine We have to munmap() what we have mmap()ed Reviewed-by: Gunnar Reviewed-by: Jeremy --- src/gui/text/qfontengine_qws.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/text/qfontengine_qws.cpp b/src/gui/text/qfontengine_qws.cpp index 62a674a..888e1be 100644 --- a/src/gui/text/qfontengine_qws.cpp +++ b/src/gui/text/qfontengine_qws.cpp @@ -381,6 +381,8 @@ class QFontEngineQPF1Data public: QPFFontMetrics fm; QPFGlyphTree *tree; + void *mmapStart; + size_t mmapLength; }; @@ -410,6 +412,8 @@ QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn) QT_CLOSE(f); d = new QFontEngineQPF1Data; + d->mmapStart = data; + d->mmapLength = st.st_size; memcpy(reinterpret_cast(&d->fm),data,sizeof(d->fm)); data += sizeof(d->fm); @@ -431,6 +435,8 @@ QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn) QFontEngineQPF1::~QFontEngineQPF1() { + if (d->mmapStart) + munmap(d->mmapStart, d->mmapLength); delete d->tree; delete d; } -- cgit v0.12 From 3d4a2cd013f9e62788adf902a57ae8e2f31fccc7 Mon Sep 17 00:00:00 2001 From: Iain Date: Fri, 11 Sep 2009 11:19:23 +0200 Subject: Fix compile errors (missing uncaught_exception definition) on Symbian^3 When using STDCPP in Symbian^3, the definition for uncaught_exception *must* be provided before any attempt to include e32base.h is made. This is because STDCPP support disables the standard Symbian definition of uncaught_exception, so the version from needs to be used instead. Reviewed-by: Jason Barron --- src/s60main/qts60main.cpp | 1 + src/s60main/qts60main_mcrt0.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/s60main/qts60main.cpp b/src/s60main/qts60main.cpp index a919593..725b17c 100644 --- a/src/s60main/qts60main.cpp +++ b/src/s60main/qts60main.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ // INCLUDE FILES +#include // must be before e32base.h so uncaught_exception gets defined #include #include diff --git a/src/s60main/qts60main_mcrt0.cpp b/src/s60main/qts60main_mcrt0.cpp index 9439d2a..d30e07a 100644 --- a/src/s60main/qts60main_mcrt0.cpp +++ b/src/s60main/qts60main_mcrt0.cpp @@ -48,8 +48,8 @@ // EPOC32 version of crt0.c for C programs which always want multi-threaded support #include +#include // must be before e32base.h so uncaught_exception gets defined #include -#include #include "estlib.h" // Needed for QT_TRYCATCH_LEAVING. -- cgit v0.12 From ed501bfc4a6510b70dc0bba17ab3da9921ab9f9f Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 10 Sep 2009 11:15:02 +0200 Subject: Fix autotests on QMenuBar We have mousemove events but we were missing the mouse press ones. --- tests/auto/qmenubar/tst_qmenubar.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp index c74bbcb..07aa9f4 100644 --- a/tests/auto/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/qmenubar/tst_qmenubar.cpp @@ -1545,22 +1545,27 @@ void tst_QMenuBar::task256322_highlight() win.show(); QTest::qWait(200); + QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center()); QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(file).center()); - QTest::mouseClick(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center()); + QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center()); QTRY_VERIFY(menu.isVisible()); QVERIFY(!menu2.isVisible()); QCOMPARE(win.menuBar()->activeAction(), file); + QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file2).center()); QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(file2).center()); QTRY_VERIFY(!menu.isVisible()); QVERIFY(menu2.isVisible()); QCOMPARE(win.menuBar()->activeAction(), file2); + QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file2).center()); QPoint nothingCenter = win.menuBar()->actionGeometry(nothing).center(); + QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, nothingCenter); QTest::mouseMove(win.menuBar(), nothingCenter); QTRY_VERIFY(!menu2.isVisible()); QVERIFY(!menu.isVisible()); QCOMPARE(win.menuBar()->activeAction(), nothing); + QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, nothingCenter); } void tst_QMenuBar::menubarSizeHint() -- cgit v0.12 From 26da6385e1d687cc9aef375cc9b5fb4f6fc353d0 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 11 Sep 2009 11:34:15 +0200 Subject: animations now display a warning if they don't have a end value also improved the autotests --- src/corelib/animation/qpropertyanimation.cpp | 4 ++-- tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index d6ded62..861bd9f 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -273,9 +273,9 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState, if (oldState == Stopped) { d->setDefaultStartEndValue(d->targetValue->property(d->propertyName.constData())); //let's check if we have a start value and an end value - if (d->direction == Forward && !startValue().isValid() && !d->defaultStartEndValue.isValid()) + if (!startValue().isValid() && (d->direction == Backward || !d->defaultStartEndValue.isValid())) qWarning("QPropertyAnimation::updateState: starting an animation without start value"); - if (d->direction == Backward && !endValue().isValid() && !d->defaultStartEndValue.isValid()) + if (!endValue().isValid() && (d->direction == Forward || !d->defaultStartEndValue.isValid())) qWarning("QPropertyAnimation::updateState: starting an animation without end value"); } } else if (hash.value(key) == this) { diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 60bc39e..bea399c 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -473,6 +473,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() { //normal case: the animation finishes and is deleted QPointer anim = new QPropertyAnimation(&o, "ole"); + anim->setEndValue(100); QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim->start(QVariantAnimation::DeleteWhenStopped); QTest::qWait(anim->duration() + 50); @@ -482,10 +483,12 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() { QPointer anim = new QPropertyAnimation(&o, "ole"); + anim->setEndValue(100); QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim->start(QVariantAnimation::DeleteWhenStopped); QTest::qWait(anim->duration()/2); QPointer anim2 = new QPropertyAnimation(&o, "ole"); + anim2->setEndValue(100); QCOMPARE(runningSpy.count(), 1); QCOMPARE(anim->state(), QVariantAnimation::Running); @@ -634,6 +637,7 @@ void tst_QPropertyAnimation::playForwardBackward() QCOMPARE(o.property("ole").toInt(), 0); QPropertyAnimation anim(&o, "ole"); + anim.setStartValue(0); anim.setEndValue(100); anim.start(); QTest::qWait(anim.duration() + 50); @@ -906,6 +910,7 @@ void tst_QPropertyAnimation::operationsInStates() QObject o; o.setProperty("ole", 42); QPropertyAnimation anim(&o, "ole"); + anim.setEndValue(100); QSignalSpy spy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim.stop(); -- cgit v0.12 From 92789fabd6728820b244d23d7477f2a224a33f94 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 11 Sep 2009 11:44:26 +0200 Subject: small optimization for variant handling in animations Just one test less --- src/corelib/animation/qpropertyanimation.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 861bd9f..b64d7df 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -106,13 +106,19 @@ void QPropertyAnimationPrivate::updateMetaProperty() return; } + //propertyType will be set to a valid type only if there is a Q_PROPERTY + //otherwise it will be set to QVariant::Invalid at the end of this function propertyType = targetValue->property(propertyName).userType(); propertyIndex = targetValue->metaObject()->indexOfProperty(propertyName); - if (propertyIndex == -1 && !targetValue->dynamicPropertyNames().contains(propertyName)) - qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); if (propertyType != QVariant::Invalid) convertValues(propertyType); + if (propertyIndex == -1) { + //there is no Q_PROPERTY on the object + propertyType = QVariant::Invalid; + if (!targetValue->dynamicPropertyNames().contains(propertyName)) + qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); + } } void QPropertyAnimationPrivate::updateProperty(const QVariant &newValue) @@ -125,7 +131,7 @@ void QPropertyAnimationPrivate::updateProperty(const QVariant &newValue) return; } - if (propertyIndex != -1 && newValue.userType() == propertyType) { + if (newValue.userType() == propertyType) { //no conversion is needed, we directly call the QObject::qt_metacall void *data = const_cast(newValue.constData()); targetValue->qt_metacall(QMetaObject::WriteProperty, propertyIndex, &data); -- cgit v0.12 From e59d4e9f0b147409a8a2732ee3f29f8e7768349a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 10 Sep 2009 15:34:05 +0200 Subject: Enabled use of graphics system with old GL engine for testing. Reviewed-by: Trond --- src/plugins/graphicssystems/opengl/main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/opengl/main.cpp b/src/plugins/graphicssystems/opengl/main.cpp index 0562132..c28b09a 100644 --- a/src/plugins/graphicssystems/opengl/main.cpp +++ b/src/plugins/graphicssystems/opengl/main.cpp @@ -41,6 +41,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -53,11 +54,18 @@ public: QStringList QGLGraphicsSystemPlugin::keys() const { - return QStringList(QLatin1String("OpenGL")); + QStringList list; + list << QLatin1String("OpenGL") << QLatin1String("OpenGL1"); + return list; } QGraphicsSystem* QGLGraphicsSystemPlugin::create(const QString& system) { + if (system.toLower() == QLatin1String("opengl1")) { + QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); + return new QGLGraphicsSystem; + } + if (system.toLower() == QLatin1String("opengl")) return new QGLGraphicsSystem; -- cgit v0.12 From 47d6e83659f23de6bf4d0a37cb30c325dcacefc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 11 Sep 2009 10:53:39 +0200 Subject: Fixed clipping bugs in GL2 graphics system with oxygen style. QGL2PaintEngineEx::clip() needs to call ensureActive() to make sure the engine is active and synced before doing any clipping operations. We also need to set needsSync to false before entering setState() since otherwise we end up in an infinite loop in the case where replayClipOperations() again calls QGL2PaintEngineEx::clip(). Reviewed-by: Tom --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 4427ee9..e32bbbd 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1405,8 +1405,8 @@ void QGL2PaintEngineEx::ensureActive() glViewport(0, 0, d->width, d->height); glDepthMask(false); glDepthFunc(GL_LESS); - setState(state()); d->needsSync = false; + setState(state()); } } @@ -1519,6 +1519,8 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) // qDebug("QGL2PaintEngineEx::clip()"); Q_D(QGL2PaintEngineEx); + ensureActive(); + if (op == Qt::ReplaceClip && !d->hasClipOperations()) op = Qt::IntersectClip; -- cgit v0.12 From a5a27973b1e4df62217ed510229b0d8dfa70e354 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Fri, 11 Sep 2009 12:19:48 +0200 Subject: Doc: QHeaderView::section:checked was left out of stylesheet docs. Task-number: 254741 Reviewed-by: Trust Me --- doc/src/snippets/code/doc_src_stylesheet.qdoc | 5 +++++ doc/src/widgets-and-layouts/stylesheet.qdoc | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/src/snippets/code/doc_src_stylesheet.qdoc b/doc/src/snippets/code/doc_src_stylesheet.qdoc index f79f7ff..1c0440c 100644 --- a/doc/src/snippets/code/doc_src_stylesheet.qdoc +++ b/doc/src/snippets/code/doc_src_stylesheet.qdoc @@ -1007,6 +1007,11 @@ QHeaderView::section { border: 1px solid #6c6c6c; } +QHeaderView::section:checked +{ + background-color: red; +} + /* style the sort indicator */ QHeaderView::down-arrow { image: url(down_arrow.png); diff --git a/doc/src/widgets-and-layouts/stylesheet.qdoc b/doc/src/widgets-and-layouts/stylesheet.qdoc index c40795a..d2538f4 100644 --- a/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -840,7 +840,8 @@ \l{#first-ps}{:first}, \l{#last-ps}{:last}, \l{#only-one-ps}{:only-one}, \l{#next-selected-ps}{:next-selected}, \l{#previous-selected-ps}{:previous-selected}, - \l{#selected-ps}{:selected} pseudo states. + \l{#selected-ps}{:selected}, + and \l{#checked-ps}{:checked} pseudo states. Sort indicator in can be styled using the \l{#up-arrow-sub}{::up-arrow} and the -- cgit v0.12 From 6ac7728fe442988e86786cb75a851063b4380404 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Thu, 13 Aug 2009 13:08:46 +0200 Subject: Remove yet another forgotten debug message. --- mkspecs/features/mac/default_post.prf | 1 - 1 file changed, 1 deletion(-) diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index 210a704..4999762 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -6,7 +6,6 @@ load(default_post) # contains both then use the compiler default. Make a similiar decision for # PowerPC-based systems. Note that this logic assumes that Qt has been # configured with an architecture that is usable on the system. -message(hei $$QT_CONFIG ) qt:!isEmpty(QT_CONFIG) { contains(QMAKE_HOST.arch, ppc) { !contains(QT_CONFIG, ppc64):contains(QT_CONFIG, ppc):CONFIG += ppc -- cgit v0.12 From 0293aff5c44202e5c62e229b74d8bd0bf9206185 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Fri, 11 Sep 2009 12:49:25 +0200 Subject: Fix memory leak when deleteLater is triggered via the main menu bar. The deleteLater was beeing created with loopLevel of 1, causing it to be defferd until QApplication::exec() returned. Add a QScopedLoopLevelCounter to increase the loopLevel while triggering the action. RevBy: Brad --- src/gui/kernel/qcocoamenuloader_mac.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm index ce2a92c..9ab077f 100644 --- a/src/gui/kernel/qcocoamenuloader_mac.mm +++ b/src/gui/kernel/qcocoamenuloader_mac.mm @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -198,6 +199,7 @@ QT_USE_NAMESPACE - (IBAction)qtDispatcherToQAction:(id)sender { + QScopedLoopLevelCounter loopLevelCounter(QApplicationPrivate::instance()->threadData); NSMenuItem *item = static_cast(sender); if (QAction *action = reinterpret_cast([item tag])) { action->trigger(); -- cgit v0.12 From e2411ebd04bf9a55e6e3b24cc7886e597521d473 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Thu, 10 Sep 2009 16:14:59 +0200 Subject: Out of memory fix for qUncompress qUncompress shouldn't crash when running out of memory, since it might deal with buffers which are not under user control (same behavior as Qt 4.5). It will however throw a std::bad_alloc exception if Qt is compiled with exception handling. Reviewed-by: Harald Fernengel Reviewed-by: Ralf Engels Reviewed-by: Lars Knoll --- src/corelib/tools/qbytearray.cpp | 54 +++++++++++++++++++------------- src/corelib/tools/qbytearray.h | 1 + tests/auto/qbytearray/tst_qbytearray.cpp | 16 ++++++++-- 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 6d55ef9..d8557e5 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -47,6 +47,7 @@ #include "qlocale.h" #include "qlocale_p.h" #include "qunicodetables_p.h" +#include "qscopedpointer.h" #ifndef QT_NO_DATASTREAM #include #endif @@ -535,38 +536,49 @@ QByteArray qUncompress(const uchar* data, int nbytes) ulong expectedSize = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | (data[3] ); ulong len = qMax(expectedSize, 1ul); - QByteArray baunzip; - int res; - do { - QT_TRY { - baunzip.resize(len); - res = ::uncompress((uchar*)baunzip.data(), &len, - (uchar*)data+4, nbytes-4); - } QT_CATCH (const std::bad_alloc &) { - res = Z_MEM_ERROR; + QScopedPointer d; + + forever { + ulong alloc = len; + d.reset(q_check_ptr(static_cast(qRealloc(d.data(), sizeof(QByteArray::Data) + alloc)))); + if (!d) { + // we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS + qWarning("qUncompress: could not allocate enough memory to uncompress data"); + return QByteArray(); } + int res = ::uncompress((uchar*)d->array, &len, + (uchar*)data+4, nbytes-4); + switch (res) { case Z_OK: - if ((int)len != baunzip.size()) - baunzip.resize(len); - break; + if (len != alloc) { + d.reset(q_check_ptr(static_cast(qRealloc(d.data(), sizeof(QByteArray::Data) + len)))); + if (!d) { + // we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS + qWarning("qUncompress: could not allocate enough memory to uncompress data"); + return QByteArray(); + } + } + d->ref = 1; + d->alloc = d->size = len; + d->data = d->array; + + return QByteArray(d.take(), 0, 0); + case Z_MEM_ERROR: qWarning("qUncompress: Z_MEM_ERROR: Not enough memory"); - break; + return QByteArray(); + case Z_BUF_ERROR: len *= 2; - break; + continue; + case Z_DATA_ERROR: qWarning("qUncompress: Z_DATA_ERROR: Input data is corrupted"); - break; + return QByteArray(); } - } while (res == Z_BUF_ERROR); - - if (res != Z_OK) - baunzip = QByteArray(); - - return baunzip; + } } #endif diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 191f6a2..9621dbf 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -372,6 +372,7 @@ private: friend class QByteRef; friend class QString; + friend QByteArray qUncompress(const uchar *data, int nbytes); public: typedef Data * DataPtr; inline DataPtr &data_ptr() { return d; } diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp index 44cfe4a..b0bf3df 100644 --- a/tests/auto/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/qbytearray/tst_qbytearray.cpp @@ -236,6 +236,7 @@ void tst_QByteArray::qUncompress_data() void tst_QByteArray::qUncompress() { QFETCH(QByteArray, in); + QFETCH(QByteArray, out); #if defined Q_OS_HPUX && !defined __ia64 && defined Q_CC_GNU QSKIP("Corrupt data causes this tests to lock up on HP-UX / PA-RISC with gcc", SkipAll); @@ -245,9 +246,20 @@ void tst_QByteArray::qUncompress() QSKIP("Corrupt data causes this test to lock up on QNX", SkipAll); #endif - QTEST(::qUncompress(in), "out"); + QByteArray res; + QT_TRY { + res = ::qUncompress(in); + } QT_CATCH(const std::bad_alloc &) { + res = QByteArray(); + } + QCOMPARE(res, out); - QTEST(::qUncompress(in + "blah"), "out"); + QT_TRY { + res = ::qUncompress(in + "blah"); + } QT_CATCH(const std::bad_alloc &) { + res = QByteArray(); + } + QCOMPARE(res, out); } #endif -- cgit v0.12 From 42beaa8e1e422a41efe1a398b55db044827f336c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 11 Sep 2009 13:21:35 +0200 Subject: Skip pointless test It is planned that this test will do something sensible in the future. Reviewed-by: Jesper --- tests/auto/qtwidgets/tst_qtwidgets.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/qtwidgets/tst_qtwidgets.cpp b/tests/auto/qtwidgets/tst_qtwidgets.cpp index 12bc02f..a765bde 100644 --- a/tests/auto/qtwidgets/tst_qtwidgets.cpp +++ b/tests/auto/qtwidgets/tst_qtwidgets.cpp @@ -72,6 +72,8 @@ tst_QtWidgets::~tst_QtWidgets() void tst_QtWidgets::snapshot() { + QSKIP("Jesper will fix this test when he has time.", SkipAll); +#if 0 StyleWidget widget(0, Qt::X11BypassWindowManagerHint); widget.show(); @@ -100,6 +102,7 @@ void tst_QtWidgets::snapshot() } QVERIFY2(ftp.error() == QFtp::NoError, ftp.errorString().toLocal8Bit().constData()); QVERIFY(!ftp.hasPendingCommands()); +#endif } -- cgit v0.12 From 7ea2c96fbd394fe930dc59b611b125ad269ec0ab Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Fri, 11 Sep 2009 14:29:23 +0300 Subject: Fixed QWidget::activateWindow for Symbian. activeWindow documentation says: "active window is a visible top-level window that has the keyboard input focus" and "If you want to ensure that the window is stacked on top as well you should also call raise(). Note that the window must be visible, otherwise activateWindow has no effect." What we were doing earlier was basically raise. Now we just set the keyboard focus to underlying native window. Task-number: 260685 Reviewed-by: Jason Barron --- src/gui/kernel/qwidget_s60.cpp | 11 ++++---- tests/auto/qwidget/tst_qwidget.cpp | 58 ++++++++++++++++++++++++++++++-------- 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 7509fa5..744d20f 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -315,7 +315,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de id = (WId)control; setWinId(id); QT_TRAP_THROWING(control->ConstructL(true,desktop)); - + if (!desktop) { TInt stackingFlags; if ((q->windowType() & Qt::Popup) == Qt::Popup) { @@ -1013,8 +1013,8 @@ void QWidget::setWindowState(Qt::WindowStates newstate) } } -#endif // Q_WS_S60 - +#endif // Q_WS_S60 + createWinId(); Q_ASSERT(testAttribute(Qt::WA_WState_Created)); QTLWExtra *top = d->topData(); @@ -1210,10 +1210,9 @@ void QWidget::activateWindow() Q_D(QWidget); QWidget *tlw = window(); if (tlw->isVisible()) { - S60->windowGroup().SetOrdinalPosition(0); window()->createWinId(); - RDrawableWindow* rw = tlw->d_func()->topData()->rwindow; - rw->SetOrdinalPosition(0); + WId id = tlw->internalWinId(); + id->SetFocus(true); } } QT_END_NAMESPACE diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 230b7c9..47cd860 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -367,10 +367,12 @@ private slots: void setGraphicsEffect(); void destroyBackingStore(); - + + void activateWindow(); + #ifdef Q_OS_SYMBIAN void cbaVisibility(); -#endif +#endif private: bool ensureScreenSize(int width, int height); @@ -9328,11 +9330,45 @@ void tst_QWidget::setGraphicsEffect() delete anotherWidget; } +void tst_QWidget::activateWindow() +{ + // Test case for task 260685 + + // Create first mainwindow and set it active + QMainWindow* mainwindow = new QMainWindow(); + QLabel* label = new QLabel(mainwindow); + mainwindow->setCentralWidget(label); + mainwindow->setVisible(true); + mainwindow->activateWindow(); + qApp->processEvents(); + + QVERIFY(mainwindow->isActiveWindow()); + + // Create second mainwindow and set it active + QMainWindow* mainwindow2 = new QMainWindow(); + QLabel* label2 = new QLabel(mainwindow2); + mainwindow2->setCentralWidget(label2); + mainwindow2->setVisible(true); + mainwindow2->activateWindow(); + qApp->processEvents(); + + QVERIFY(!mainwindow->isActiveWindow()); + QVERIFY(mainwindow2->isActiveWindow()); + + // Revert first mainwindow back to visible active + mainwindow->setVisible(true); + mainwindow->activateWindow(); + qApp->processEvents(); + + QVERIFY(mainwindow->isActiveWindow()); + QVERIFY(!mainwindow2->isActiveWindow()); +} + #ifdef Q_OS_SYMBIAN void tst_QWidget::cbaVisibility() { // Test case for task 261048 - + // Create first mainwindow in fullsreen and activate it QMainWindow* mainwindow = new QMainWindow(); QLabel* label = new QLabel(mainwindow); @@ -9340,11 +9376,11 @@ void tst_QWidget::cbaVisibility() mainwindow->setWindowState(Qt::WindowFullScreen); mainwindow->setVisible(true); mainwindow->activateWindow(); - qApp->processEvents(); + qApp->processEvents(); QVERIFY(mainwindow->isActiveWindow()); - QVERIFY(QDesktopWidget().availableGeometry().size() == mainwindow->size()); - + QVERIFY(QDesktopWidget().availableGeometry().size() == mainwindow->size()); + // Create second mainwindow in maximized and activate it QMainWindow* mainwindow2 = new QMainWindow(); QLabel* label2 = new QLabel(mainwindow2); @@ -9352,17 +9388,17 @@ void tst_QWidget::cbaVisibility() mainwindow2->setWindowState(Qt::WindowMaximized); mainwindow2->setVisible(true); mainwindow2->activateWindow(); - qApp->processEvents(); - + qApp->processEvents(); + QVERIFY(!mainwindow->isActiveWindow()); QVERIFY(mainwindow2->isActiveWindow()); - QVERIFY(QDesktopWidget().availableGeometry().size() == mainwindow2->size()); - + QVERIFY(QDesktopWidget().availableGeometry().size() == mainwindow2->size()); + // Verify window decorations i.e. status pane and CBA are visible. CEikStatusPane* statusPane = CEikonEnv::Static()->AppUiFactory()->StatusPane(); QVERIFY(statusPane->IsVisible()); CEikButtonGroupContainer* buttonGroup = CEikonEnv::Static()->AppUiFactory()->Cba(); - QVERIFY(buttonGroup->IsVisible()); + QVERIFY(buttonGroup->IsVisible()); } #endif -- cgit v0.12 From 203721da4d1fe32a92854ca8edd9e47339832e30 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 11 Sep 2009 14:04:03 +0200 Subject: Better failure message when it fails Some platforms do not recalculate the Qt::WA_UnderMouse attribute when a widget is shown underneath the mouse. Reviewed-by: Olivier --- tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index 9d76741..491330b 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -850,6 +850,8 @@ void tst_QStyleSheetStyle::hoverColors() QTest::mouseMove ( widget, QPoint(5,5)); QTest::qWait(60); + QVERIFY(widget->testAttribute(Qt::WA_UnderMouse)); + QImage image(frame.width(), frame.height(), QImage::Format_ARGB32); frame.render(&image); @@ -877,6 +879,8 @@ void tst_QStyleSheetStyle::hoverColors() QTest::mouseMove (widget, QPoint(5,5)); QTest::qWait(60); + QVERIFY(widget->testAttribute(Qt::WA_UnderMouse)); + frame.render(&image); QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)), -- cgit v0.12 From 799c921e27b7321f8b912428e5fb45022a6581bd Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Fri, 11 Sep 2009 14:35:34 +0200 Subject: Compile fix for windows Reviewed-by: TrustMe --- src/corelib/tools/qbytearray.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 9621dbf..14425ba 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -372,7 +372,7 @@ private: friend class QByteRef; friend class QString; - friend QByteArray qUncompress(const uchar *data, int nbytes); + friend Q_CORE_EXPORT QByteArray qUncompress(const uchar *data, int nbytes); public: typedef Data * DataPtr; inline DataPtr &data_ptr() { return d; } -- cgit v0.12 From 49b0c307cf5ab5f18d34fbbd3e1c83949640bcf7 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 11 Sep 2009 14:44:03 +0200 Subject: Do not use FBO as backend for window surface in opengl engine There are too many platform regressions when using the FBO as a backend for the opengl engine. We need to find whether it's possible to work around them, but for the time being, to preserve compatibility, we only use FBOs when using the opengl2 engine. Example of issue: Smudged text and smudged diagonal lines on Windows XP when running with opengl engine and latest nvidia driver. Reviewed-by: Trond --- src/opengl/qwindowsurface_gl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index efea369..c2f05cc 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -579,7 +579,8 @@ void QGLWindowSurface::updateGeometry() #ifdef QT_OPENGL_ES_2 && (QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit) #endif - && (d_ptr->fbo || !d_ptr->tried_fbo)) + && (d_ptr->fbo || !d_ptr->tried_fbo) + && qt_gl_preferGL2Engine()) { d_ptr->tried_fbo = true; hijackWindow(window()); -- cgit v0.12 From 33d1c616d8d4085ba6fa848bafaec66576eba224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Wed, 9 Sep 2009 15:54:40 +0200 Subject: Respect the layoutDirection property of the parent widget. Add a layoutDirection autotest, and sprinkle some of the tests with checkReverseDirection() Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout.cpp | 2 +- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 45 ++++++++----- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 2 +- .../tst_qgraphicsanchorlayout.cpp | 78 ++++++++++++++++++++++ 4 files changed, 107 insertions(+), 20 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp index 3bb8c29..c7033c6 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp @@ -383,7 +383,7 @@ void QGraphicsAnchorLayout::setGeometry(const QRectF &geom) QGraphicsLayout::setGeometry(geom); d->calculateVertexPositions(QGraphicsAnchorLayoutPrivate::Horizontal); d->calculateVertexPositions(QGraphicsAnchorLayoutPrivate::Vertical); - d->setItemsGeometries(); + d->setItemsGeometries(geom); } /*! diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 787060f..f81ede0 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -1772,20 +1772,42 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation) Use the current vertices distance to calculate and set the geometry of each item. */ -void QGraphicsAnchorLayoutPrivate::setItemsGeometries() +void QGraphicsAnchorLayoutPrivate::setItemsGeometries(const QRectF &geom) { + Q_Q(QGraphicsAnchorLayout); AnchorVertex *firstH, *secondH, *firstV, *secondV; + qreal top; + qreal left; + qreal right; + + q->getContentsMargins(&left, &top, &right, 0); + const Qt::LayoutDirection visualDir = visualDirection(); + if (visualDir == Qt::RightToLeft) + qSwap(left, right); + + left += geom.left(); + top += geom.top(); + right = geom.right() - right; + foreach (QGraphicsLayoutItem *item, items) { firstH = internalVertex(item, Qt::AnchorLeft); secondH = internalVertex(item, Qt::AnchorRight); firstV = internalVertex(item, Qt::AnchorTop); secondV = internalVertex(item, Qt::AnchorBottom); - QPointF topLeft(firstH->distance, firstV->distance); - QPointF bottomRight(secondH->distance, secondV->distance); + QRectF newGeom; + newGeom.setTop(top + firstV->distance); + newGeom.setBottom(top + secondV->distance); - item->setGeometry(QRectF(topLeft, bottomRight)); + if (visualDir == Qt::LeftToRight) { + newGeom.setLeft(left + firstH->distance); + newGeom.setRight(left + secondH->distance); + } else { + newGeom.setLeft(right - secondH->distance); + newGeom.setRight(right - firstH->distance); + } + item->setGeometry(newGeom); } } @@ -1798,26 +1820,13 @@ void QGraphicsAnchorLayoutPrivate::setItemsGeometries() void QGraphicsAnchorLayoutPrivate::calculateVertexPositions( QGraphicsAnchorLayoutPrivate::Orientation orientation) { - Q_Q(QGraphicsAnchorLayout); QQueue > queue; QSet visited; // Get root vertex AnchorVertex *root = graph[orientation].rootVertex(); - qreal widgetMargin; - qreal layoutMargin; - - // Initialize the first vertex - if (orientation == Horizontal) { - widgetMargin = q->geometry().x(); - q->getContentsMargins(&layoutMargin, 0, 0, 0); - } else { - // Root position is equal to the top margin - widgetMargin = q->geometry().y(); - q->getContentsMargins(0, &layoutMargin, 0, 0); - } - root->distance = widgetMargin + layoutMargin; + root->distance = 0; visited.insert(root); // Add initial edges to the queue diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 1470fb3..31da1a1 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -437,7 +437,7 @@ public: void removeInternalVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge); // Geometry interpolation methods - void setItemsGeometries(); + void setItemsGeometries(const QRectF &geom); void calculateVertexPositions(Orientation orientation); void setupEdgesInterpolation(Orientation orientation); diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 0d311fe..95476f0 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -52,6 +52,7 @@ private slots: void simple(); void simple_center(); void simple_semifloat(); + void layoutDirection(); void diagonal(); void parallel(); void parallel2(); @@ -104,6 +105,39 @@ static void setAnchor(QGraphicsAnchorLayout *l, l->setAnchorSpacing(firstItem, firstEdge, secondItem, secondEdge, spacing); } +static bool checkReverseDirection(QGraphicsWidget *w) +{ + QGraphicsLayout *l = w->layout(); + Q_ASSERT(l); + qreal left, top, right, bottom; + l->getContentsMargins(&left, &top, &right, &bottom); + w->setLayoutDirection(Qt::LeftToRight); + QApplication::processEvents(); + const QRectF lg = l->geometry(); + QMap geometries; + for (int i = 0; i < l->count(); ++i) { + QGraphicsLayoutItem *w = l->itemAt(i); + geometries.insert(w, w->geometry()); + } + w->setLayoutDirection(Qt::RightToLeft); + QApplication::processEvents(); + lg.adjusted(+right, +top, -left, -bottom); + for (int i = 0; i < l->count(); ++i) { + QGraphicsLayoutItem *w = l->itemAt(i); + const QRectF rtlGeom = w->geometry(); + const QRectF ltrGeom = geometries.value(w); + QRectF expectedGeom = ltrGeom; + expectedGeom.moveRight(lg.right() - (0 + ltrGeom.left())); + if (expectedGeom != rtlGeom) { + qDebug() << "layout->geometry():" << lg + << "expected:" << expectedGeom + << "actual:" << rtlGeom; + return false; + } + } + return true; +} + void tst_QGraphicsAnchorLayout::simple() { QGraphicsWidget *w1 = createItem(); @@ -204,6 +238,46 @@ void tst_QGraphicsAnchorLayout::simple_semifloat() QCOMPARE(layoutMaximumSize, QSizeF(200, 20)); } +void tst_QGraphicsAnchorLayout::layoutDirection() +{ + QSizeF min(10, 10); + QSizeF pref(50, 10); + QSizeF max(100, 10); + + QGraphicsWidget *a = createItem(min, pref, max, "a"); + QGraphicsWidget *b = createItem(min, pref, max, "b"); + QGraphicsWidget *c = createItem(min, pref, QSizeF(100, 20), "c"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 5, 10, 15); + // horizontal + setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); + setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft, 0); + setAnchor(l, b, Qt::AnchorRight, l, Qt::AnchorRight, 0); + setAnchor(l, a, Qt::AnchorHorizontalCenter, c, Qt::AnchorLeft, 0); + setAnchor(l, c, Qt::AnchorRight, b, Qt::AnchorHorizontalCenter, 0); + + // vertical + setAnchor(l, l, Qt::AnchorTop, a, Qt::AnchorTop, 0); + setAnchor(l, l, Qt::AnchorTop, b, Qt::AnchorTop, 0); + setAnchor(l, a, Qt::AnchorBottom, c, Qt::AnchorTop, 0); + setAnchor(l, b, Qt::AnchorBottom, c, Qt::AnchorTop, 0); + setAnchor(l, c, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + + QCOMPARE(l->count(), 3); + + QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window); + p->setLayoutDirection(Qt::LeftToRight); + p->setLayout(l); + + QGraphicsScene scene; + QGraphicsView *view = new QGraphicsView(&scene); + scene.addItem(p); + p->show(); + view->show(); + + QCOMPARE(checkReverseDirection(p), true); +} void tst_QGraphicsAnchorLayout::diagonal() { @@ -306,6 +380,8 @@ void tst_QGraphicsAnchorLayout::diagonal() QCOMPARE(d->geometry(), QRectF(0.0, 200.0, 100.0, 100.0)); QCOMPARE(e->geometry(), QRectF(100.0, 200.0, 75.0, 100.0)); QCOMPARE(p.size(), testA); + + QCOMPARE(checkReverseDirection(&p), true); } void tst_QGraphicsAnchorLayout::parallel() @@ -599,6 +675,8 @@ void tst_QGraphicsAnchorLayout::snakeOppositeDirections() QCOMPARE(b->geometry(), QRectF(90.0, 100.0, 10.0, 100.0)); QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0)); QCOMPARE(p.size(), layoutMaximumSize); + + QCOMPARE(checkReverseDirection(&p), true); } void tst_QGraphicsAnchorLayout::fairDistribution() -- cgit v0.12 From 3fed939e82e4946546775602f4898c363871c3f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 11 Sep 2009 16:09:47 +0200 Subject: Made GL window surface work better with native child widgets. Need to unbind the window surface FBO and re-bind it in the child widget's context before doing a blit. Reviewed-by: Kim --- src/opengl/qglframebufferobject.cpp | 2 + src/opengl/qwindowsurface_gl.cpp | 80 ++++++++++++++++++++++++++++--------- 2 files changed, 64 insertions(+), 18 deletions(-) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index f15aa01..81f2aa9 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -854,6 +854,7 @@ bool QGLFramebufferObject::bind() d->valid = d->checkFramebufferStatus(); const QGLContext *context = QGLContext::currentContext(); if (d->valid && context) { + Q_ASSERT(QGLContextPrivate::contextGroup(context) == ctx); // Save the previous setting to automatically restore in release(). if (context->d_ptr->current_fbo != d->fbo) { d->previous_fbo = context->d_ptr->current_fbo; @@ -885,6 +886,7 @@ bool QGLFramebufferObject::release() const QGLContext *context = QGLContext::currentContext(); if (context) { + Q_ASSERT(QGLContextPrivate::contextGroup(context) == ctx); // Restore the previous setting for stacked framebuffer objects. if (d->previous_fbo != context->d_ptr->current_fbo) { context->d_ptr->current_fbo = d->previous_fbo; diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index c2f05cc..e89352d 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -71,6 +71,7 @@ #include #include +#include #ifndef QT_OPENGL_ES_2 #include @@ -399,6 +400,11 @@ void QGLWindowSurface::endPaint(const QRegion &rgn) void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset) { + if (context() && widget != window()) { + qWarning("No native child widget support in GL window surface without FBOs or pixel buffers"); + return; + } + QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget(); Q_ASSERT(parent); @@ -473,7 +479,22 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & return; } + QGLContext *previous_ctx = const_cast(QGLContext::currentContext()); QGLContext *ctx = reinterpret_cast(parent->d_func()->extraData()->glContext); + + if (ctx != previous_ctx) { + if (d_ptr->fbo && d_ptr->fbo->isBound()) + d_ptr->fbo->release(); + ctx->makeCurrent(); + } + + QSize size = widget->rect().size(); + if (d_ptr->destructive_swap_buffers && ctx->format().doubleBuffer()) { + rect = parent->rect(); + br = rect.translated(wOffset + offset); + size = parent->size(); + } + GLuint texture; if (d_ptr->fbo) { texture = d_ptr->fbo->texture(); @@ -486,31 +507,54 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & glBindTexture(target, 0); } - QSize size = widget->rect().size(); - if (d_ptr->destructive_swap_buffers && ctx->format().doubleBuffer()) { - rect = parent->rect(); - br = rect.translated(wOffset); - size = parent->size(); - } - glDisable(GL_SCISSOR_TEST); - if (d_ptr->fbo && QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit) { + if (d_ptr->fbo && (QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit)) { const int h = d_ptr->fbo->height(); - const int x0 = rect.left(); - const int x1 = rect.left() + rect.width(); - const int y0 = h - (rect.top() + rect.height()); - const int y1 = h - rect.top(); + const int sx0 = br.left(); + const int sx1 = br.left() + br.width(); + const int sy0 = h - (br.top() + br.height()); + const int sy1 = h - br.top(); + + const int tx0 = rect.left(); + const int tx1 = rect.left() + rect.width(); + const int ty0 = parent->height() - (rect.top() + rect.height()); + const int ty1 = parent->height() - rect.top(); + + if (window() == parent || d_ptr->fbo->format().samples() <= 1) { + glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, 0); + glBlitFramebufferEXT(sx0, sy0, sx1, sy1, + tx0, ty0, tx1, ty1, + GL_COLOR_BUFFER_BIT, + GL_NEAREST); - glBlitFramebufferEXT(x0, y0, x1, y1, - x0, y0, x1, y1, - GL_COLOR_BUFFER_BIT, - GL_NEAREST); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, d_ptr->fbo->handle()); + } else { + // can't do sub-region blits with multisample FBOs + QGLFramebufferObject *temp = qgl_fbo_pool()->acquire(d_ptr->fbo->size(), QGLFramebufferObjectFormat()); + + glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, temp->handle()); + glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, d_ptr->fbo->handle()); + + glBlitFramebufferEXT(0, 0, d_ptr->fbo->width(), d_ptr->fbo->height(), + 0, 0, d_ptr->fbo->width(), d_ptr->fbo->height(), + GL_COLOR_BUFFER_BIT, + GL_NEAREST); + + glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, temp->handle()); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, d_ptr->fbo->handle()); + glBlitFramebufferEXT(sx0, sy0, sx1, sy1, + tx0, ty0, tx1, ty1, + GL_COLOR_BUFFER_BIT, + GL_NEAREST); + + glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, 0); + + qgl_fbo_pool()->release(temp); + } } #if !defined(QT_OPENGL_ES_2) else { -- cgit v0.12 From bd513e9feeb70068d4d638f1a72843be195a924d Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 11 Sep 2009 08:04:07 -0700 Subject: Don't use UI_TOOLS for browser demo on QWS When cross-compiling and shadow building Makefiles are not generated for designer and libQtUiTools. For this reason designer usually doesn't build for people trying to compile the browser example on QWS due to unresolved externals or weird link errors when the build tries to pick up the system Qt libraries instead. The mechanism to fix this is already in place for S60. --- demos/browser/browser.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/browser/browser.pro b/demos/browser/browser.pro index f54afe4..afc25e3 100644 --- a/demos/browser/browser.pro +++ b/demos/browser/browser.pro @@ -3,7 +3,7 @@ TARGET = browser QT += webkit network CONFIG += qt warn_on -contains(QT_BUILD_PARTS, tools):!symbian: CONFIG += uitools +contains(QT_BUILD_PARTS, tools):!symbian:!embedded: CONFIG += uitools else: DEFINES += QT_NO_UITOOLS FORMS += \ -- cgit v0.12 From 04ee935a67b4f4296c31655d625cc3e45cb31b9b Mon Sep 17 00:00:00 2001 From: Iain Date: Fri, 11 Sep 2009 17:49:54 +0200 Subject: Add platform specific libraries required to use OpenVG to star example Reviewed-by: Jason Barron --- examples/openvg/star/star.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/openvg/star/star.pro b/examples/openvg/star/star.pro index 90c236d..6ae1238 100644 --- a/examples/openvg/star/star.pro +++ b/examples/openvg/star/star.pro @@ -4,3 +4,4 @@ CONFIG += qt debug warn_on QT += openvg SOURCES = starwidget.cpp main.cpp HEADERS = starwidget.h +LIBS += $$QMAKE_LIBS_OPENVG \ No newline at end of file -- cgit v0.12 From 1aa4cfab2d437210b8c0b064fa3bd071e53374c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 11 Sep 2009 17:32:43 +0200 Subject: Added example to docs for QPainter::beginNativePainting(). Hopefully this helps clarify the use of beginNativePainting(). Reviewed-by: Trond --- doc/src/snippets/code/src_gui_painting_qpainter.cpp | 17 +++++++++++++++++ src/gui/painting/qpainter.cpp | 9 +++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/src/snippets/code/src_gui_painting_qpainter.cpp b/doc/src/snippets/code/src_gui_painting_qpainter.cpp index 8dfda66..0226161 100644 --- a/doc/src/snippets/code/src_gui_painting_qpainter.cpp +++ b/doc/src/snippets/code/src_gui_painting_qpainter.cpp @@ -241,3 +241,20 @@ QImage image(":/images/myImage.png"); QPainter painter(this); painter.drawImage(target, image, source); //! [20] + + +//! [21] +QPainter painter(this); +painter.fillRect(0, 0, 128, 128, Qt::green); +painter.beginNativePainting(); + +glEnable(GL_SCISSOR_TEST); +glScissor(0, 0, 64, 64); + +glClearColor(1, 0, 0, 1); +glClear(GL_COLOR_BUFFER_BIT); + +glDisable(GL_SCISSOR_TEST); + +painter.endNativePainting(); +//! [21] diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 2dcc20c..a9257c7 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1894,8 +1894,13 @@ QPaintEngine *QPainter::paintEngine() const /*! Flushes the painting pipeline and prepares for the user issuing - native painting commands. Must be followed by a call to - endNativePainting(). + commands directly to the underlying graphics context. Must be + followed by a call to endNativePainting(). + + Here is an example that shows intermixing of painter commands + and raw OpenGL commands: + + \snippet doc/src/snippets/code/src_gui_painting_qpainter.cpp 21 \sa endNativePainting() */ -- cgit v0.12