From 08587c9b18f94b3e108ee54489801a11d61ee29d Mon Sep 17 00:00:00 2001 From: mread Date: Thu, 6 Aug 2009 10:14:36 +0100 Subject: Leaves -> exceptions --- src/gui/kernel/qwidget_s60.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 4336d45..ca1500f 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -323,7 +323,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de } else { stackingFlags = ECoeStackFlagStandard; } - control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags); + QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags)); QTLWExtra *topExtra = topData(); topExtra->rwindow = control->DrawableWindow(); @@ -356,7 +356,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de } else { stackingFlags = ECoeStackFlagStandard; } - control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags); + QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags)); WId parentw = parentWidget->effectiveWinId(); QT_TRAP_THROWING(control->SetContainerWindowL(*parentw)); @@ -763,10 +763,11 @@ void QWidgetPrivate::setWindowTitle_sys(const QString &caption) Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); CAknTitlePane* titlePane = S60->titlePane(); if(titlePane) { - if(caption.isEmpty()) - titlePane->SetTextToDefaultL(); - else + if(caption.isEmpty()) { + QT_TRAP_THROWING(titlePane->SetTextToDefaultL()); + } else { QT_TRAP_THROWING(titlePane->SetTextL(qt_QString2TPtrC(caption))); + } } } #else -- cgit v0.12 From 252e1e7c98eca34add9f4531edf800fc1b47fde6 Mon Sep 17 00:00:00 2001 From: mread Date: Thu, 6 Aug 2009 10:36:31 +0100 Subject: plugin factory loader memory leak protection --- src/corelib/plugin/qfactoryloader.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 3b44b47..2e852f7 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -64,6 +64,7 @@ class QFactoryLoaderPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QFactoryLoader) public: QFactoryLoaderPrivate(){} + ~QFactoryLoaderPrivate(); mutable QMutex mutex; QByteArray iid; QList libraryList; @@ -76,6 +77,12 @@ public: void unloadPath(const QString &path); }; +QFactoryLoaderPrivate::~QFactoryLoaderPrivate() +{ + for (int i = 0; i < libraryList.count(); ++i) + libraryList.at(i)->release(); +} + QFactoryLoader::QFactoryLoader(const char *iid, const QString &suffix, Qt::CaseSensitivity cs) @@ -89,8 +96,8 @@ QFactoryLoader::QFactoryLoader(const char *iid, QMutexLocker locker(qt_factoryloader_mutex()); - qt_factory_loaders()->append(this); update(); + qt_factory_loaders()->append(this); } @@ -197,10 +204,6 @@ void QFactoryLoader::update() QFactoryLoader::~QFactoryLoader() { - Q_D(QFactoryLoader); - for (int i = 0; i < d->libraryList.count(); ++i) - d->libraryList.at(i)->release(); - QMutexLocker locker(qt_factoryloader_mutex()); qt_factory_loaders()->removeAll(this); } -- cgit v0.12 From 48018d7e8b016d14c27219dbba41ca229870d00b Mon Sep 17 00:00:00 2001 From: mread Date: Thu, 6 Aug 2009 10:38:54 +0100 Subject: fixing memory leaks in dir iterator --- src/corelib/io/qdiriterator.cpp | 27 ++++++++++++++++++++------- src/corelib/io/qdiriterator.h | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 582d657..12fe258 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -99,6 +99,18 @@ QT_BEGIN_NAMESPACE +class QDirIteratorPrivateIteratorStack : public QStack +{ +public: + ~QDirIteratorPrivateIteratorStack(); +}; + +QDirIteratorPrivateIteratorStack::~QDirIteratorPrivateIteratorStack() +{ + qDeleteAll(*this); +} + + class QDirIteratorPrivate { public: @@ -113,8 +125,8 @@ public: bool matchesFilters(const QString &fileName, const QFileInfo &fi) const; QSet visitedLinks; - QAbstractFileEngine *engine; - QStack fileEngineIterators; + QScopedPointer engine; + QDirIteratorPrivateIteratorStack fileEngineIterators; QString path; QFileInfo nextFileInfo; //This fileinfo is the current that we will return from the public API @@ -135,7 +147,7 @@ public: */ QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList &nameFilters, QDir::Filters filters, QDirIterator::IteratorFlags flags) - : engine(0), path(path), nextFileInfo(path), iteratorFlags(flags), followNextDir(false), first(true), done(false) + : path(path), nextFileInfo(path), iteratorFlags(flags), followNextDir(false), first(true), done(false) { if (filters == QDir::NoFilter) filters = QDir::AllEntries; @@ -151,7 +163,6 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList */ QDirIteratorPrivate::~QDirIteratorPrivate() { - delete engine; } /*! @@ -170,7 +181,11 @@ void QDirIteratorPrivate::pushSubDirectory(const QString &path, const QStringLis } } - if (engine || (engine = QAbstractFileEngine::create(this->path))) { + if (engine.isNull()) { + engine.reset(QAbstractFileEngine::create(this->path)); + } + + if (!engine.isNull()) { engine->setFileName(path); QAbstractFileEngineIterator *it = engine->beginEntryList(filters, nameFilters); if (it) { @@ -461,8 +476,6 @@ QDirIterator::QDirIterator(const QString &path, const QStringList &nameFilters, */ QDirIterator::~QDirIterator() { - qDeleteAll(d->fileEngineIterators); - delete d; } /*! diff --git a/src/corelib/io/qdiriterator.h b/src/corelib/io/qdiriterator.h index 3117bf9..2639e02 100644 --- a/src/corelib/io/qdiriterator.h +++ b/src/corelib/io/qdiriterator.h @@ -84,7 +84,7 @@ public: private: Q_DISABLE_COPY(QDirIterator) - QDirIteratorPrivate *d; + QScopedPointer d; friend class QDir; }; -- cgit v0.12 From 4fe95c758d684ad7511eafc2777d5a3176a2334a Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 7 Aug 2009 14:22:23 +0100 Subject: check for possibility that time pointer is NULL --- src/corelib/tools/qdatetime.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 5dc7693..6e4aaeb 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1842,7 +1842,8 @@ QTime QTime::currentTime() #else t = localtime(<ime); #endif - + Q_CHECK_PTR(t); + ct.mds = MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min + 1000 * t->tm_sec + tv.tv_usec / 1000; #else -- cgit v0.12 From 2bdc65c043237c53eaeb0068d558d2ea6e47354f Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 7 Aug 2009 14:24:32 +0100 Subject: replacing assert with recovery for begin/end paint lock for exception compatability --- src/gui/painting/qwindowsurface_s60.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp index 5de4317..fd2c4c4 100644 --- a/src/gui/painting/qwindowsurface_s60.cpp +++ b/src/gui/painting/qwindowsurface_s60.cpp @@ -85,8 +85,8 @@ QS60WindowSurface::QS60WindowSurface(QWidget* widget) QS60WindowSurface::~QS60WindowSurface() { - // Ensure that locking and unlocking of this surface were symmetrical - Q_ASSERT(QS60WindowSurfacePrivate::lockedSurface != this); + if (QS60WindowSurfacePrivate::lockedSurface == this) + unlockBitmapHeap(); delete d_ptr->bitmap; delete d_ptr; @@ -97,7 +97,9 @@ void QS60WindowSurface::beginPaint(const QRegion &rgn) if(!d_ptr->bitmap) return; - Q_ASSERT(!QS60WindowSurfacePrivate::lockedSurface); + if (QS60WindowSurfacePrivate::lockedSurface) + unlockBitmapHeap(); + QS60WindowSurfacePrivate::lockedSurface = this; lockBitmapHeap(); -- cgit v0.12 From 0f6f1f841cea61cbb6905de92c2ca63bd369d55d Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 7 Aug 2009 14:26:29 +0100 Subject: exception -> leave conversion for pointer events --- src/gui/kernel/qapplication_s60.cpp | 7 ++++++- src/gui/kernel/qt_s60_p.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index c831dad..15f5c95 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -352,8 +352,13 @@ void QSymbianControl::HandleLongTapEventL( const TPoint& aPenEventLocation, cons void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent) { - //### refactor me, getting too complex m_longTapDetector->PointerEventL(pEvent); + QT_TRYCATCH_LEAVING(HandlePointerEvent(pEvent)); +} + +void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent) +{ + //### refactor me, getting too complex QMouseEvent::Type type; Qt::MouseButton button; mapS60MouseEventTypeToQt(&type, &button, &pEvent); diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index f6dd2e1..7fb401c 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -150,6 +150,7 @@ protected: void FocusChanged(TDrawNow aDrawNow); private: + void HandlePointerEvent(const TPointerEvent& aPointerEvent); TKeyResponse OfferKeyEvent(const TKeyEvent& aKeyEvent,TEventCode aType); TKeyResponse sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent); void sendMouseEvent(QWidget *widget, QMouseEvent *mEvent); -- cgit v0.12 From 921eaf6bf3a1420ff9ce8f797c60247da80110ab Mon Sep 17 00:00:00 2001 From: mread Date: Mon, 10 Aug 2009 09:37:48 +0100 Subject: moved declaration of engine to better match merge and to remove warning --- src/corelib/io/qdiriterator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index a91c112..2039827 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -124,6 +124,8 @@ public: void checkAndPushDirectory(const QFileInfo &); bool matchesFilters(const QString &fileName, const QFileInfo &fi) const; + QScopedPointer engine; + const QString path; const QStringList nameFilters; const QDir::Filters filters; @@ -133,7 +135,6 @@ public: QVector nameRegExps; #endif - QScopedPointer engine; QDirIteratorPrivateIteratorStack fileEngineIterators; QFileInfo currentFileInfo; QFileInfo nextFileInfo; -- cgit v0.12 From d62491f595d59a63d9c493a223573e9af2306214 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 10 Aug 2009 15:11:39 +0200 Subject: add operator! to QScopedPointer --- src/corelib/tools/qscopedpointer.cpp | 8 ++++++++ src/corelib/tools/qscopedpointer.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp index 06f9e6f..5b8991e 100644 --- a/src/corelib/tools/qscopedpointer.cpp +++ b/src/corelib/tools/qscopedpointer.cpp @@ -207,4 +207,12 @@ QT_BEGIN_NAMESPACE Callers of this function take ownership of the pointer. */ +/*! \fn bool QScopedPointer::operator!() const + + Returns \c true if the pointer referenced by this object is \c null, otherwise + returns \c false. + + \sa isNull() +*/ + QT_END_NAMESPACE diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 923ae1b..769ad10 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -123,6 +123,11 @@ public: return d != other.d; } + inline bool operator!() const + { + return !d; + } + #if defined(Q_CC_NOKIAX86) || defined(Q_QDOC) inline operator bool() const { -- cgit v0.12 From 361e40191a82b69fe7549215bd27db94c05fc083 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 10 Aug 2009 17:11:20 +0200 Subject: s/class/struct/ Stop confusing MSVC by correctly forward declare QScopedPointerDeleter as struct --- src/corelib/io/qdir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 836fa44..5e24bf4 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -86,7 +86,7 @@ class QDirPrivate QDir *q_ptr; Q_DECLARE_PUBLIC(QDir) - friend class QScopedPointerDeleter; + friend struct QScopedPointerDeleter; protected: QDirPrivate(QDir*, const QDir *copy=0); ~QDirPrivate(); -- cgit v0.12 From 975b75bcda1570adc2aa0d0327c5445b25da1515 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 10 Aug 2009 18:16:16 +0200 Subject: Add comparison operators also to subclasses Compiler would for some reason choose operator bool() instead when comparing subclasses of QScopedPointer. --- src/corelib/tools/qscopedpointer.h | 34 ++++++++++++++++++++++-- tests/auto/qscopedpointer/tst_qscopedpointer.cpp | 27 +++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 769ad10..344964b 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -113,12 +113,12 @@ public: return d; } - inline bool operator==(const QScopedPointer &other) const + inline bool operator==(const QScopedPointer &other) const { return d == other.d; } - inline bool operator!=(const QScopedPointer &other) const + inline bool operator!=(const QScopedPointer &other) const { return d != other.d; } @@ -194,6 +194,16 @@ public: return this->d[i]; } + inline bool operator==(const QScopedArrayPointer &other) const + { + return this->d == other.d; + } + + inline bool operator!=(const QScopedArrayPointer &other) const + { + return this->d != other.d; + } + private: Q_DISABLE_COPY(QScopedArrayPointer) }; @@ -214,6 +224,16 @@ public: return this->d; } + inline bool operator==(const QCustomScopedPointer &other) const + { + return this->d == other.d; + } + + inline bool operator!=(const QCustomScopedPointer &other) const + { + return this->d != other.d; + } + private: Q_DISABLE_COPY(QCustomScopedPointer) }; @@ -258,6 +278,16 @@ public: QScopedPointerSharedDeleter::cleanup(oldD); } + inline bool operator==(const QScopedSharedPointer &other) const + { + return this->d == other.d; + } + + inline bool operator!=(const QScopedSharedPointer &other) const + { + return this->d != other.d; + } + private: Q_DISABLE_COPY(QScopedSharedPointer) }; diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp index e9b1cce..b8e0f0a 100644 --- a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp +++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp @@ -71,6 +71,7 @@ private Q_SLOTS: void isNull() const; void isNullSignature() const; void objectSize() const; + void comparison() const; // TODO instansiate on const object }; @@ -312,5 +313,31 @@ void tst_QScopedPointer::objectSize() const QCOMPARE(sizeof(QScopedPointer), sizeof(void *)); } +void tst_QScopedPointer::comparison() const +{ + int *a = new int(42); + int *b = new int(43); + + QScopedPointer pa(a); + QScopedPointer pa2(a); + QScopedPointer pb(b); + + // test equality on equal pointers + QVERIFY(pa == pa2); + QVERIFY(pa2 == pa); + + // test unequality on equal pointers + QVERIFY(!(pa != pa2)); + QVERIFY(!(pa2 != pa)); + + // test on unequal pointers + QVERIFY(!(pa == pb)); + QVERIFY(!(pb == pa)); + QVERIFY(pb != pa); + QVERIFY(pa != pb); + + pa2.take(); +} + QTEST_MAIN(tst_QScopedPointer) #include "tst_qscopedpointer.moc" -- cgit v0.12 From 5b80fbad54eccfc79f38c4f24d6267834b23e742 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 11 Aug 2009 09:06:36 +0300 Subject: Unified QtNetworkSettings:severIP return type for all platforms. This commit fixes the following autotest case build breaks on windows when compiling QtS60 sources: - q3socket - q3socketdevice - qhostinfo - qsocks5socketengine --- tests/auto/network-settings.h | 25 ++++++++-------------- tests/auto/qhostinfo/tst_qhostinfo.cpp | 6 ++++-- .../qhttpsocketengine/tst_qhttpsocketengine.cpp | 8 +++---- .../tst_qsocks5socketengine.cpp | 16 +++++++------- 4 files changed, 25 insertions(+), 30 deletions(-) diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index 9488fda..9b67910 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -37,12 +37,10 @@ ** ****************************************************************************/ #include - -/* #ifdef QT_NETWORK_LIB #include #endif -*/ + #ifdef Q_OS_SYMBIAN #include @@ -131,7 +129,9 @@ public: //return "qt-test-server.wildcard.dev." + serverDomainName(); return "qttest.wildcard.dev." + serverDomainName(); } - static const char *serverIP() + +#ifdef QT_NETWORK_LIB + static QHostAddress serverIP() { #ifdef Q_OS_SYMBIAN loadTestSettings(); @@ -141,12 +141,13 @@ public: if(serverIp.isNull()) { serverIp = entry->recordValue().toAscii(); } - return serverIp.data(); + return QHostAddress(serverIp.data()); } -#endif - return "10.10.14.172"; +#endif + return QHostInfo::fromName(serverName()).addresses().first(); } - +#endif + static QByteArray expectedReplyIMAP() { #ifdef Q_OS_SYMBIAN @@ -315,14 +316,6 @@ private: } #endif -/* -#ifdef QT_NETWORK_LIB - static QHostAddress serverIP() - { - return QHostInfo::fromName(serverName()).addresses().first(); - } -#endif -*/ }; #ifdef Q_OS_SYMBIAN diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp index f4ad307..06fdf7b 100644 --- a/tests/auto/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp @@ -92,6 +92,8 @@ //TESTED_CLASS= //TESTED_FILES= +const char * const lupinellaIp = "10.3.4.6"; + class tst_QHostInfo : public QObject { @@ -216,8 +218,8 @@ void tst_QHostInfo::lookupIPv4_data() #ifdef Q_OS_SYMBIAN // Test server lookup - QTest::newRow("lookup_01") << QtNetworkSettings::serverName() << QtNetworkSettings::serverIP() << int(QHostInfo::NoError); - QTest::newRow("literal_ip4") << QtNetworkSettings::serverIP() << QtNetworkSettings::serverIP() << int(QHostInfo::NoError); + QTest::newRow("lookup_01") << QtNetworkSettings::serverName() << QtNetworkSettings::serverIP().toString() << int(QHostInfo::NoError); + QTest::newRow("literal_ip4") << QtNetworkSettings::serverIP() << QtNetworkSettings::serverIP().toString() << 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); #else QTest::newRow("empty") << "" << "" << int(QHostInfo::HostNotFound); diff --git a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp index 4287a16..0245e95 100644 --- a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp +++ b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp @@ -306,11 +306,11 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP() socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128)); - QVERIFY(!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::serverIP()), 143)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState); - QVERIFY(socketDevice.peerAddress() == QHostAddress(QtNetworkSettings::serverIP())); + QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP()); QVERIFY(!socketDevice.localAddress().isNull()); QVERIFY(socketDevice.localPort() > 0); @@ -695,11 +695,11 @@ void tst_QHttpSocketEngine::passwordAuth() socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128, "qsockstest", "password")); - QVERIFY(!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::serverIP()), 143)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState); - QVERIFY(socketDevice.peerAddress() == QHostAddress(QtNetworkSettings::serverIP())); + QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); diff --git a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp index d6628bd..ff78830 100644 --- a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -319,11 +319,11 @@ void tst_QSocks5SocketEngine::simpleConnectToIMAP() socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); - QVERIFY(!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::serverIP()), 143)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState); - QVERIFY(socketDevice.peerAddress() == QHostAddress(QtNetworkSettings::serverIP())); + QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); @@ -838,14 +838,14 @@ void tst_QSocks5SocketEngine::passwordAuth() socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080, "qsockstest", "password")); // Connect to imap.trolltech.com's IP - QVERIFY(!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::serverIP()), 143)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); - if (!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::serverIP()), 143)) { + if (!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)) { qDebug("%d, %s", socketDevice.error(), socketDevice.errorString().toLatin1().constData()); } QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState); - QVERIFY(socketDevice.peerAddress() == QHostAddress(QtNetworkSettings::serverIP())); + QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); @@ -904,16 +904,16 @@ void tst_QSocks5SocketEngine::passwordAuth2() socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081)); socketDevice.setReceiver(this); - QVERIFY(!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::serverIP()), 143)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); while (socketDevice.state() == QAbstractSocket::ConnectingState) { QVERIFY(socketDevice.waitForWrite()); - socketDevice.connectToHost(QHostAddress(QtNetworkSettings::serverIP()), 143); + socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143); } if (socketDevice.state() != QAbstractSocket::ConnectedState) qDebug("%d, %s", socketDevice.error(), socketDevice.errorString().toLatin1().constData()); QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState); - QVERIFY(socketDevice.peerAddress() == QHostAddress(QtNetworkSettings::serverIP())); + QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); -- cgit v0.12 From aa11cdf62d5b6b1b19fb3cf241267917a875aba9 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 11 Aug 2009 09:31:21 +0300 Subject: Fixed KERN-EXEC 3 crash in qdesktopwidget for S60. QDesktopWidgetPrivate::rects etc variables are shared between QDesktopWidgetPrivate objects and private objects maintains refcount to data. We called cleanup for private object directly from QDesktopWidget, which caused the shared private data to be freed after some instance of QDesktopWidget was destroyed. Since we bypassed the refcount also the data for other QDesktopWidgets was invalidated and this cauyse crash when resizeEvent was received. There is no need to call QDesktopWidgetPrivate::cleanup directly since when QDesktopWidget is deleted, it will call destructor for QDesktopWidgetPrivate which deletes the shared data based on ref count. --- src/gui/kernel/qdesktopwidget_s60.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/kernel/qdesktopwidget_s60.cpp b/src/gui/kernel/qdesktopwidget_s60.cpp index 226a759..5734ddd 100644 --- a/src/gui/kernel/qdesktopwidget_s60.cpp +++ b/src/gui/kernel/qdesktopwidget_s60.cpp @@ -126,7 +126,6 @@ QDesktopWidget::QDesktopWidget() QDesktopWidget::~QDesktopWidget() { - QDesktopWidgetPrivate::cleanup(); } bool QDesktopWidget::isVirtualDesktop() const -- cgit v0.12 From d1ce08936b4a6f4ce2b2e878287de76d47df0b8c Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 11 Aug 2009 09:53:49 +0300 Subject: Switched QtNetworkSetting to use 'qt-test-server' config by default. Qt/Master uses qt-test-server config by default but our S60/master was configure to use different server by default. The assumption is that this caused several QtNetwork autotests to fail when testing QtS60 branch on other configurations in QtSW premises. This because the old test server was very likely unavailable... --- tests/auto/network-settings.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index 9b67910..48ba8e8 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -96,9 +96,9 @@ public: return entry->recordValue(); } #endif - return QString("qttest"); + //return QString("qttest"); //return QString("aspiriniks"); - //return QString("qt-test-server"); + return QString("qt-test-server"); } static QString serverDomainName() { @@ -110,8 +110,9 @@ public: return entry->recordValue(); } #endif - return QString("it.local"); + //return QString("it.local"); //return QString("troll.no"); + return QString("qt-test-net"); } static QString serverName() { @@ -126,8 +127,8 @@ public: } static QString wildcardServerName() { - //return "qt-test-server.wildcard.dev." + serverDomainName(); - return "qttest.wildcard.dev." + serverDomainName(); + return "qt-test-server.wildcard.dev." + serverDomainName(); + //return "qttest.wildcard.dev." + serverDomainName(); } #ifdef QT_NETWORK_LIB -- cgit v0.12 From 7ae19c4358a4cd7907569c12a2d3c4784257808e Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 11 Aug 2009 10:38:03 +0300 Subject: Fixed SRCDIR for qxmlquery autotest for Symbian --- tests/auto/qxmlquery/qxmlquery.pro | 8 ++++---- tests/auto/qxmlquery/tst_qxmlquery.cpp | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/auto/qxmlquery/qxmlquery.pro b/tests/auto/qxmlquery/qxmlquery.pro index 92700c5..cfab564 100644 --- a/tests/auto/qxmlquery/qxmlquery.pro +++ b/tests/auto/qxmlquery/qxmlquery.pro @@ -10,10 +10,10 @@ RESOURCES = input.qrc QT += network -!wince* { -DEFINES += SRCDIR=\\\"$$PWD/\\\" -} else { -DEFINES += SRCDIR=\\\"./\\\" +wince* { + DEFINES += SRCDIR=\\\"./\\\" +} else:!symbian { + DEFINES += SRCDIR=\\\"$$PWD/\\\" } include (../xmlpatterns.pri) diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp index 32e1e16..b563e06 100644 --- a/tests/auto/qxmlquery/tst_qxmlquery.cpp +++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp @@ -65,6 +65,10 @@ #include "TestFundament.h" #include "../network-settings.h" +#if defined(Q_OS_SYMBIAN) +#define SRCDIR "" +#endif + /*! \class tst_QXmlQuery \internal -- cgit v0.12 From a329c91a197c90854cbc6ce2a626935ff1d57680 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 11 Aug 2009 10:43:47 +0300 Subject: Fixed qsocketnotifier autotest compilation for win32-msvc2008 platform. --- tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp index a6064bc..a29674f 100644 --- a/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp +++ b/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp @@ -175,7 +175,7 @@ void tst_QSocketNotifier::unexpectedDisconnection() QVERIFY(readEnd2.state() == QAbstractSocket::ConnectedState); #if defined(Q_OS_WIN) qWarning("### Windows returns 1 activation, Unix returns 2."); - QCOMPARE(tester.sequence, 1); + QCOMPARE(tester.getSequence(), 1); #else QCOMPARE(tester.getSequence(), 2); #endif -- cgit v0.12 From 731c7be94590f0bee1c02a95273732e14543b175 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 11 Aug 2009 10:40:42 +0200 Subject: Removed qkeyevent autotest. This test hasn't been updated in years, and never worked in the first place. RevBy: Trust me --- tests/auto/qkeyevent/.gitignore | 1 - tests/auto/qkeyevent/qkeyevent.pro | 5 - tests/auto/qkeyevent/tst_qkeyevent.cpp | 263 --------------------------------- 3 files changed, 269 deletions(-) delete mode 100644 tests/auto/qkeyevent/.gitignore delete mode 100644 tests/auto/qkeyevent/qkeyevent.pro delete mode 100644 tests/auto/qkeyevent/tst_qkeyevent.cpp diff --git a/tests/auto/qkeyevent/.gitignore b/tests/auto/qkeyevent/.gitignore deleted file mode 100644 index 8d69f55..0000000 --- a/tests/auto/qkeyevent/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qkeyevent diff --git a/tests/auto/qkeyevent/qkeyevent.pro b/tests/auto/qkeyevent/qkeyevent.pro deleted file mode 100644 index 8a3dc12..0000000 --- a/tests/auto/qkeyevent/qkeyevent.pro +++ /dev/null @@ -1,5 +0,0 @@ -load(qttest_p4) -HEADERS += -SOURCES += tst_qkeyevent.cpp - - diff --git a/tests/auto/qkeyevent/tst_qkeyevent.cpp b/tests/auto/qkeyevent/tst_qkeyevent.cpp deleted file mode 100644 index 9adf97c..0000000 --- a/tests/auto/qkeyevent/tst_qkeyevent.cpp +++ /dev/null @@ -1,263 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include -#include -#include - - -#include - -//TESTED_CLASS= -//TESTED_FILES=gui/itemviews/qitemselectionmodel.h gui/itemviews/qitemselectionmodel.cpp - -class KeyEventWidget : public QWidget -{ -public: - KeyEventWidget( QWidget* parent = 0, const char* name = 0 ); - ~KeyEventWidget(); - QKeyEvent* getLastKeyPress(); - QKeyEvent* getLastKeyRelease(); - bool recievedKeyPress; - bool recievedKeyRelease; -protected: - void keyPressEvent( QKeyEvent* e ); - void keyReleaseEvent( QKeyEvent* e ); -private: - QKeyEvent* lastKeyPress; - QKeyEvent* lastKeyRelease; -}; - -class tst_QKeyEvent : public QObject -{ - Q_OBJECT -public: - tst_QKeyEvent(); - ~tst_QKeyEvent(); -public slots: - void initTestCase(); - void cleanupTestCase(); -private slots: - void sendRecieveKeyEvents_data(); - void sendRecieveKeyEvents(); - void standardKey(); -private: - KeyEventWidget* testWidget; -}; - - -KeyEventWidget::KeyEventWidget( QWidget* parent, const char* name ) - : QWidget( parent ), recievedKeyPress( false ), recievedKeyRelease( false ), - lastKeyPress( 0 ), lastKeyRelease( 0 ) -{ - setObjectName(name); -} - -KeyEventWidget::~KeyEventWidget() -{ - delete lastKeyPress; - delete lastKeyRelease; -} - -QKeyEvent* KeyEventWidget::getLastKeyPress() -{ - return lastKeyPress; -} - -QKeyEvent* KeyEventWidget::getLastKeyRelease() -{ - return lastKeyRelease; -} - -void KeyEventWidget::keyPressEvent( QKeyEvent* e ) -{ - if (lastKeyPress) - delete lastKeyPress; - lastKeyPress = new QKeyEvent(*e); - recievedKeyPress = true; -} - -void KeyEventWidget::keyReleaseEvent( QKeyEvent* e ) -{ - if (lastKeyRelease) - delete lastKeyRelease; - lastKeyRelease = new QKeyEvent(*e); - recievedKeyRelease = true; -} - -tst_QKeyEvent::tst_QKeyEvent() -{ -} - -tst_QKeyEvent::~tst_QKeyEvent() -{ -} - -void tst_QKeyEvent::initTestCase() -{ - testWidget = new KeyEventWidget( 0 ); - testWidget->show(); -} - -void tst_QKeyEvent::cleanupTestCase() -{ - delete testWidget; -} - -void tst_QKeyEvent::sendRecieveKeyEvents_data() -{ - QTest::addColumn("key"); - QTest::addColumn("textExpected"); - QTest::addColumn("text"); - int a; - for ( a = Qt::Key_Escape; a < Qt::Key_Direction_R; a++ ) { - if ( ( a > Qt::Key_Clear && a < Qt::Key_Home ) - || ( a > Qt::Key_PageDown && a < Qt::Key_Shift ) - || ( a > Qt::Key_ScrollLock && a < Qt::Key_F1 ) ) { - // There is no representation for these values - continue; - } - if ( a == Qt::Key_Backtab ) // Actually SHIFT+Tab - QTest::newRow( QString("key - %1").arg( a ).toLatin1() ) << int(Qt::Key_Tab) << false << ""; - else - QTest::newRow( QString("key - %1").arg( a ).toLatin1() ) << a << false << ""; - } - - for ( a = Qt::Key_Space; a < Qt::Key_ydiaeresis; a++ ) { - QTest::newRow( QString("key - %1").arg( a ).toLatin1() ) << a << true << QString( QChar(a) ); - } -} - -void tst_QKeyEvent::standardKey() -{ - -} - -void tst_QKeyEvent::sendRecieveKeyEvents() -{ - QFETCH( int, key ); - QFETCH( bool, textExpected ); - QFETCH( QString, text ); - testWidget->recievedKeyPress = false; - -#ifdef Q_WS_WIN - // Will be eaten by Windows system - if ( key == Qt::Key_Print ) - return; - - // This is mapped to nothing on Windows - if ( key == Qt::Key_SysReq ) - return; - - // Not supported on Windows - if ( key >= Qt::Key_F25 && key <= Qt::Key_Super_R ) - return; - if ( key >= Qt::Key_Hyper_L && key <= Qt::Key_Hyper_R ) - return; - if ( key == Qt::Key_Help ) - return; - - // Not sure on how to add support for these yet - if ( key >= Qt::Key_Direction_L && key <= Qt::Key_Direction_R ) - return; - - // Not sure on how to test these yet, since they use SHIFT etc - if ( key >= Qt::Key_Exclam && key <= Qt::Key_Slash ) - return; - if ( key >= Qt::Key_Colon && key <= Qt::Key_At ) - return; - if ( key >= Qt::Key_BracketRight && key <= Qt::Key_ydiaeresis ) - return; -#endif // Q_WS_WIN - -#ifdef Q_OS_SYMBIAN - // Not supported on symbian - if ( key == Qt::Key_Print ) - return; - - // Not supported on symbian - if ( key == Qt::Key_SysReq ) - return; - - // Not supported on symbian - if ( key >= Qt::Key_F25 && key <= Qt::Key_Super_R ) - return; - if ( key >= Qt::Key_Hyper_L && key <= Qt::Key_Hyper_R ) - return; - if ( key == Qt::Key_Help ) - return; - - // Not sure on how to add support for these yet - if ( key >= Qt::Key_Direction_L && key <= Qt::Key_Direction_R ) - return; - - // Not supported on symbian - if ( key >= Qt::Key_Exclam && key <= Qt::Key_Slash ) - return; - if ( key >= Qt::Key_Colon && key <= Qt::Key_At ) - return; - if ( key >= Qt::Key_BracketRight && key <= Qt::Key_ydiaeresis ) - return; -#endif // Q_WS_WIN - - if ( key == Qt::Key_F1 ) - return; // Ignore for the moment - - QTest::keyPress( testWidget, (Qt::Key)key ); - while ( !testWidget->recievedKeyPress ) - qApp->processEvents(); - QKeyEvent* ke = testWidget->getLastKeyPress(); - QCOMPARE( ke->key(), key ); - if ( textExpected ) - QCOMPARE( ke->text(), text ); - testWidget->recievedKeyRelease = false; - QTest::keyRelease( testWidget, (Qt::Key)key ); - while ( !testWidget->recievedKeyRelease ) - qApp->processEvents(); - ke = testWidget->getLastKeyRelease(); - QCOMPARE( ke->key(), key ); - if ( textExpected ) - QCOMPARE( ke->text(), text ); -} - -QTEST_MAIN(tst_QKeyEvent) -#include "tst_qkeyevent.moc" -- cgit v0.12 From dce17b9375c1fce6cb5b94554f4aaa3fc4c42f7b Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 11 Aug 2009 11:02:26 +0200 Subject: test slots are not const --- tests/auto/qscopedpointer/tst_qscopedpointer.cpp | 76 ++++++++++++------------ 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp index b8e0f0a..7f571a9 100644 --- a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp +++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp @@ -54,35 +54,35 @@ class tst_QScopedPointer : public QObject Q_OBJECT private Q_SLOTS: - void defaultConstructor() const; - void dataOnDefaultConstructed() const; - void useSubClassInConstructor() const; - void dataOnValue() const; - void dataSignature() const; - void reset() const; - void dereferenceOperator() const; - void dereferenceOperatorSignature() const; - void pointerOperator() const; - void pointerOperatorSignature() const; - void negationOperator() const; - void negationOperatorSignature() const; - void operatorBool() const; - void operatorBoolSignature() const; - void isNull() const; - void isNullSignature() const; - void objectSize() const; - void comparison() const; - // TODO instansiate on const object + void defaultConstructor(); + void dataOnDefaultConstructed(); + void useSubClassInConstructor(); + void dataOnValue(); + void dataSignature(); + void reset(); + void dereferenceOperator(); + void dereferenceOperatorSignature(); + void pointerOperator(); + void pointerOperatorSignature(); + void negationOperator(); + void negationOperatorSignature(); + void operatorBool(); + void operatorBoolSignature(); + void isNull(); + void isNullSignature(); + void objectSize(); + void comparison(); + // TODO instanciate on const object }; -void tst_QScopedPointer::defaultConstructor() const +void tst_QScopedPointer::defaultConstructor() { /* Check that the members, one, is correctly initialized. */ QScopedPointer p; QCOMPARE(p.data(), static_cast(0)); } -void tst_QScopedPointer::dataOnDefaultConstructed() const +void tst_QScopedPointer::dataOnDefaultConstructed() { QScopedPointer p; @@ -97,13 +97,13 @@ class MySubClass : public MyClass { }; -void tst_QScopedPointer::useSubClassInConstructor() const +void tst_QScopedPointer::useSubClassInConstructor() { /* Use a syntax which users typically would do. */ QScopedPointer p(new MyClass()); } -void tst_QScopedPointer::dataOnValue() const +void tst_QScopedPointer::dataOnValue() { int *const rawPointer = new int(5); QScopedPointer p(rawPointer); @@ -111,14 +111,14 @@ void tst_QScopedPointer::dataOnValue() const QCOMPARE(p.data(), rawPointer); } -void tst_QScopedPointer::dataSignature() const +void tst_QScopedPointer::dataSignature() { const QScopedPointer p; /* data() should be const. */ p.data(); } -void tst_QScopedPointer::reset() const +void tst_QScopedPointer::reset() { /* Call reset() on a default constructed value. */ { @@ -172,7 +172,7 @@ public: } }; -void tst_QScopedPointer::dereferenceOperator() const +void tst_QScopedPointer::dereferenceOperator() { /* Dereference a basic value. */ { @@ -192,7 +192,7 @@ void tst_QScopedPointer::dereferenceOperator() const } } -void tst_QScopedPointer::dereferenceOperatorSignature() const +void tst_QScopedPointer::dereferenceOperatorSignature() { /* The operator should be const. */ { @@ -219,7 +219,7 @@ public: int value; }; -void tst_QScopedPointer::pointerOperator() const +void tst_QScopedPointer::pointerOperator() { QScopedPointer p(new AnyForm()); p->value = 5; @@ -227,7 +227,7 @@ void tst_QScopedPointer::pointerOperator() const QCOMPARE(p->value, 5); } -void tst_QScopedPointer::pointerOperatorSignature() const +void tst_QScopedPointer::pointerOperatorSignature() { /* The operator should be const. */ const QScopedPointer p(new AnyForm); @@ -236,7 +236,7 @@ void tst_QScopedPointer::pointerOperatorSignature() const QVERIFY(p->value); } -void tst_QScopedPointer::negationOperator() const +void tst_QScopedPointer::negationOperator() { /* Invoke on default constructed value. */ { @@ -251,7 +251,7 @@ void tst_QScopedPointer::negationOperator() const } } -void tst_QScopedPointer::negationOperatorSignature() const +void tst_QScopedPointer::negationOperatorSignature() { /* The signature should be const. */ const QScopedPointer p; @@ -261,7 +261,7 @@ void tst_QScopedPointer::negationOperatorSignature() const static_cast(!p); } -void tst_QScopedPointer::operatorBool() const +void tst_QScopedPointer::operatorBool() { /* Invoke on default constructed value. */ { @@ -276,15 +276,15 @@ void tst_QScopedPointer::operatorBool() const } } -void tst_QScopedPointer::operatorBoolSignature() const +void tst_QScopedPointer::operatorBoolSignature() { /* The signature should be const and return bool. */ const QScopedPointer p; - static_cast(p); + (void)static_cast(p); } -void tst_QScopedPointer::isNull() const +void tst_QScopedPointer::isNull() { /* Invoke on default constructed value. */ { @@ -299,7 +299,7 @@ void tst_QScopedPointer::isNull() const } } -void tst_QScopedPointer::isNullSignature() const +void tst_QScopedPointer::isNullSignature() { const QScopedPointer p(new int(69)); @@ -307,13 +307,13 @@ void tst_QScopedPointer::isNullSignature() const static_cast(p.isNull()); } -void tst_QScopedPointer::objectSize() const +void tst_QScopedPointer::objectSize() { /* The size of QScopedPointer should be the same as one pointer. */ QCOMPARE(sizeof(QScopedPointer), sizeof(void *)); } -void tst_QScopedPointer::comparison() const +void tst_QScopedPointer::comparison() { int *a = new int(42); int *b = new int(43); -- cgit v0.12 From 7f7965212438405c64566416c0f8972f06d6dcd1 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Mon, 10 Aug 2009 17:06:00 +0200 Subject: Refactor S60 related changes to QGraphicsItem / QGraphicsView. The change mostly removes duplication and does minor touchups. Reviewed-by: axis --- src/gui/graphicsview/qgraphicsitem.cpp | 149 ++++++++------------------------- src/gui/graphicsview/qgraphicsview.cpp | 28 ++----- 2 files changed, 44 insertions(+), 133 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 52f333b..1e7708c 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -577,7 +577,7 @@ #include #include #include -#include +#include #include #include @@ -8995,7 +8995,42 @@ bool QGraphicsTextItem::sceneEvent(QEvent *event) return true; } } - return QGraphicsItem::sceneEvent(event); + bool result = QGraphicsItem::sceneEvent(event); + + // Ensure input context is updated. + switch (event->type()) { + case QEvent::ContextMenu: + case QEvent::FocusIn: + case QEvent::FocusOut: + case QEvent::GraphicsSceneDragEnter: + case QEvent::GraphicsSceneDragLeave: + case QEvent::GraphicsSceneDragMove: + case QEvent::GraphicsSceneDrop: + case QEvent::GraphicsSceneHoverEnter: + case QEvent::GraphicsSceneHoverLeave: + case QEvent::GraphicsSceneHoverMove: + case QEvent::GraphicsSceneMouseDoubleClick: + case QEvent::GraphicsSceneMousePress: + case QEvent::GraphicsSceneMouseMove: + case QEvent::GraphicsSceneMouseRelease: + case QEvent::KeyPress: + case QEvent::KeyRelease: + // Reset the focus widget's input context, regardless + // of how this item gained or lost focus. + if (QWidget *fw = qApp->focusWidget()) { + if (QInputContext *qic = fw->inputContext()) { + if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut) + qic->reset(); + else + qic->update(); + } + } + break; + default: + break; + } + + return result; } /*! @@ -9021,11 +9056,6 @@ void QGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) } dd->sendControlEvent(event); - Q_ASSERT(event->widget()); - QInputContext *qic = event->widget()->inputContext(); - if(qic) { - qic->update(); - } } /*! @@ -9039,11 +9069,6 @@ void QGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } dd->sendControlEvent(event); - Q_ASSERT(event->widget()); - QInputContext *qic = event->widget()->inputContext(); - if(qic) { - qic->update(); - } } /*! @@ -9072,14 +9097,7 @@ void QGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) QGraphicsItem::mouseReleaseEvent(event); } dd->clickCausedFocus = 0; - dd->sendControlEvent(event); - - Q_ASSERT(event->widget()); - QInputContext *qic = event->widget()->inputContext(); - if(qic) { - qic->update(); - } } /*! @@ -9098,11 +9116,6 @@ void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) } dd->sendControlEvent(event); - Q_ASSERT(event->widget()); - QInputContext *qic = event->widget()->inputContext(); - if(qic) { - qic->update(); - } } /*! @@ -9111,11 +9124,6 @@ void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { dd->sendControlEvent(event); - Q_ASSERT(event->widget()); - QInputContext *qic = event->widget()->inputContext(); - if(qic) { - qic->update(); - } } /*! @@ -9124,18 +9132,6 @@ void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void QGraphicsTextItem::keyPressEvent(QKeyEvent *event) { dd->sendControlEvent(event); - QList views = scene()->views(); - for (int i = 0; i < views.size(); ++i) { - QGraphicsView *view = views.at(i); - Q_ASSERT(view->viewport()); - if(view->viewport()->hasFocus()) { - QInputContext *qic = view->viewport()->inputContext(); - if(qic){ - qic->update(); - } - break; - } - } } /*! @@ -9144,18 +9140,6 @@ void QGraphicsTextItem::keyPressEvent(QKeyEvent *event) void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event) { dd->sendControlEvent(event); - QList views = scene()->views(); - for (int i = 0; i < views.size(); ++i) { - QGraphicsView *view = views.at(i); - Q_ASSERT(view->viewport()); - if(view->viewport()->hasFocus()) { - QInputContext *qic = view->viewport()->inputContext(); - if(qic){ - qic->update(); - } - break; - } - } } /*! @@ -9168,18 +9152,6 @@ void QGraphicsTextItem::focusInEvent(QFocusEvent *event) dd->clickCausedFocus = 1; } update(); - QList views = scene()->views(); - for (int i = 0; i < views.size(); ++i) { - QGraphicsView *view = views.at(i); - Q_ASSERT(view->viewport()); - if(view->viewport()->hasFocus()) { - QInputContext *qic = view->viewport()->inputContext(); - if(qic){ - qic->reset(); - } - break; - } - } } /*! @@ -9189,18 +9161,6 @@ void QGraphicsTextItem::focusOutEvent(QFocusEvent *event) { dd->sendControlEvent(event); update(); - QList views = scene()->views(); - for (int i = 0; i < views.size(); ++i) { - QGraphicsView *view = views.at(i); - Q_ASSERT(view->viewport()); - if(view->viewport()->hasFocus()) { - QInputContext *qic = view->viewport()->inputContext(); - if(qic){ - qic->reset(); - } - break; - } - } } /*! @@ -9209,11 +9169,6 @@ void QGraphicsTextItem::focusOutEvent(QFocusEvent *event) void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) { dd->sendControlEvent(event); - Q_ASSERT(event->widget()); - QInputContext *qic = event->widget()->inputContext(); - if(qic) { - qic->update(); - } } /*! @@ -9222,11 +9177,6 @@ void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) { dd->sendControlEvent(event); - Q_ASSERT(event->widget()); - QInputContext *qic = event->widget()->inputContext(); - if(qic) { - qic->update(); - } } /*! @@ -9235,11 +9185,6 @@ void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event) { dd->sendControlEvent(event); - Q_ASSERT(event->widget()); - QInputContext *qic = event->widget()->inputContext(); - if(qic) { - qic->update(); - } } /*! @@ -9248,11 +9193,6 @@ void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event) void QGraphicsTextItem::dropEvent(QGraphicsSceneDragDropEvent *event) { dd->sendControlEvent(event); - Q_ASSERT(event->widget()); - QInputContext *qic = event->widget()->inputContext(); - if(qic) { - qic->update(); - } } /*! @@ -9269,11 +9209,6 @@ void QGraphicsTextItem::inputMethodEvent(QInputMethodEvent *event) void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { dd->sendControlEvent(event); - Q_ASSERT(event->widget()); - QInputContext *qic = event->widget()->inputContext(); - if(qic) { - qic->update(); - } } /*! @@ -9282,11 +9217,6 @@ void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { dd->sendControlEvent(event); - Q_ASSERT(event->widget()); - QInputContext *qic = event->widget()->inputContext(); - if(qic) { - qic->update(); - } } /*! @@ -9295,11 +9225,6 @@ void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) void QGraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { dd->sendControlEvent(event); - Q_ASSERT(event->widget()); - QInputContext *qic = event->widget()->inputContext(); - if(qic) { - qic->update(); - } } /*! diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 5d8bce5..0af1070 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -1007,10 +1007,10 @@ QList QGraphicsViewPrivate::findItems(const QRegion &exposedReg void QGraphicsViewPrivate::updateInputMethodSensitivity() { Q_Q(QGraphicsView); - q->setAttribute( - Qt::WA_InputMethodEnabled, - scene && scene->focusItem() - && scene->focusItem()->flags() & QGraphicsItem::ItemAcceptsInputMethod); + bool enabled = scene && scene->focusItem() + && (scene->focusItem()->flags() & QGraphicsItem::ItemAcceptsInputMethod); + q->setAttribute(Qt::WA_InputMethodEnabled, enabled); + q->viewport()->setAttribute(Qt::WA_InputMethodEnabled, enabled); } /*! @@ -1022,16 +1022,8 @@ QGraphicsView::QGraphicsView(QWidget *parent) setViewport(0); setAcceptDrops(true); setBackgroundRole(QPalette::Base); - - // ### Ideally this would be enabled/disabled depending on whether any - // widgets in the current scene enabled input methods. We could do that - // using a simple reference count. The same goes for acceptDrops and mouse - // tracking. + // Investigate leaving these disabled by default. setAttribute(Qt::WA_InputMethodEnabled); - - // viewport part of the graphics view has to be enabled - // as well, because when events come this widget is asked - // for input context and so on viewport()->setAttribute(Qt::WA_InputMethodEnabled); } @@ -1046,11 +1038,8 @@ QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent) setViewport(0); setAcceptDrops(true); setBackgroundRole(QPalette::Base); + // Investigate leaving these disabled by default. setAttribute(Qt::WA_InputMethodEnabled); - - // viewport part of the graphics view has to be enabled - // as well, because when events come this widget is asked - // for input context and so on viewport()->setAttribute(Qt::WA_InputMethodEnabled); } @@ -1063,11 +1052,8 @@ QGraphicsView::QGraphicsView(QGraphicsViewPrivate &dd, QWidget *parent) setViewport(0); setAcceptDrops(true); setBackgroundRole(QPalette::Base); + // Investigate leaving these disabled by default. setAttribute(Qt::WA_InputMethodEnabled); - - // viewport part of the graphics view has to be enabled - // as well, because when events come this widget is asked - // for input context and so on viewport()->setAttribute(Qt::WA_InputMethodEnabled); } -- cgit v0.12