From b78ec7dcd8b13a76703baefff1731d3f345392cc Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 8 Nov 2010 11:10:53 +0100 Subject: fix memleak in test --- tests/auto/qtextdocument/tst_qtextdocument.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index 808299b..23f6a6c 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -2054,6 +2054,7 @@ void tst_QTextDocument::clonePreservesIndentWidth() doc->setIndentWidth(42); QTextDocument *clone = doc->clone(); QCOMPARE(clone->indentWidth(), qreal(42)); + delete clone; } void tst_QTextDocument::blockCount() -- cgit v0.12 From 2da8d40ac2c7de25d811bac0befaef577a696065 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 8 Nov 2010 14:02:28 +0100 Subject: QNAM: Remove dead waitForDownstreamReadyRead() code Reviewed-by: Thiago Macieira --- src/network/access/qnetworkaccessbackend_p.h | 1 - src/network/access/qnetworkaccesscachebackend.cpp | 6 ------ src/network/access/qnetworkaccesscachebackend_p.h | 1 - .../access/qnetworkaccessdebugpipebackend.cpp | 6 ------ .../access/qnetworkaccessdebugpipebackend_p.h | 1 - src/network/access/qnetworkaccessfilebackend.cpp | 6 ------ src/network/access/qnetworkaccessfilebackend_p.h | 1 - src/network/access/qnetworkaccessftpbackend.cpp | 17 ----------------- src/network/access/qnetworkaccessftpbackend_p.h | 1 - src/network/access/qnetworkaccesshttpbackend.cpp | 20 -------------------- src/network/access/qnetworkaccesshttpbackend_p.h | 1 - 11 files changed, 61 deletions(-) diff --git a/src/network/access/qnetworkaccessbackend_p.h b/src/network/access/qnetworkaccessbackend_p.h index 4fe6de6..7faa5cb 100644 --- a/src/network/access/qnetworkaccessbackend_p.h +++ b/src/network/access/qnetworkaccessbackend_p.h @@ -115,7 +115,6 @@ public: virtual bool start(); #endif virtual void closeDownstreamChannel() = 0; - virtual bool waitForDownstreamReadyRead(int msecs) = 0; // slot-like: virtual void downstreamReadyWrite(); diff --git a/src/network/access/qnetworkaccesscachebackend.cpp b/src/network/access/qnetworkaccesscachebackend.cpp index 73491a9..597cbef 100644 --- a/src/network/access/qnetworkaccesscachebackend.cpp +++ b/src/network/access/qnetworkaccesscachebackend.cpp @@ -132,12 +132,6 @@ void QNetworkAccessCacheBackend::closeUpstreamChannel() Q_ASSERT_X(false, Q_FUNC_INFO, "This function show not have been called!"); } -bool QNetworkAccessCacheBackend::waitForDownstreamReadyRead(int) -{ - Q_ASSERT_X(false, Q_FUNC_INFO , "This function show not have been called!"); - return false; -} - bool QNetworkAccessCacheBackend::waitForUpstreamBytesWritten(int) { Q_ASSERT_X(false, Q_FUNC_INFO, "This function show not have been called!"); diff --git a/src/network/access/qnetworkaccesscachebackend_p.h b/src/network/access/qnetworkaccesscachebackend_p.h index df001ab..995c875 100644 --- a/src/network/access/qnetworkaccesscachebackend_p.h +++ b/src/network/access/qnetworkaccesscachebackend_p.h @@ -69,7 +69,6 @@ public: void open(); void closeDownstreamChannel(); void closeUpstreamChannel(); - bool waitForDownstreamReadyRead(int msecs); bool waitForUpstreamBytesWritten(int msecs); void upstreamReadyRead(); diff --git a/src/network/access/qnetworkaccessdebugpipebackend.cpp b/src/network/access/qnetworkaccessdebugpipebackend.cpp index cd077e7..5f99f84 100644 --- a/src/network/access/qnetworkaccessdebugpipebackend.cpp +++ b/src/network/access/qnetworkaccessdebugpipebackend.cpp @@ -278,12 +278,6 @@ void QNetworkAccessDebugPipeBackend::socketConnected() { } -bool QNetworkAccessDebugPipeBackend::waitForDownstreamReadyRead(int ms) -{ - Q_UNUSED(ms); - qCritical("QNetworkAccess: Debug pipe backend does not support waitForReadyRead()"); - return false; -} #endif diff --git a/src/network/access/qnetworkaccessdebugpipebackend_p.h b/src/network/access/qnetworkaccessdebugpipebackend_p.h index 58a4fd0..918a813 100644 --- a/src/network/access/qnetworkaccessdebugpipebackend_p.h +++ b/src/network/access/qnetworkaccessdebugpipebackend_p.h @@ -71,7 +71,6 @@ public: virtual void open(); virtual void closeDownstreamChannel(); - virtual bool waitForDownstreamReadyRead(int msecs); virtual void downstreamReadyWrite(); diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp index 4560153..65f19ca 100644 --- a/src/network/access/qnetworkaccessfilebackend.cpp +++ b/src/network/access/qnetworkaccessfilebackend.cpp @@ -203,12 +203,6 @@ void QNetworkAccessFileBackend::closeDownstreamChannel() } } -bool QNetworkAccessFileBackend::waitForDownstreamReadyRead(int) -{ - Q_ASSERT(operation() == QNetworkAccessManager::GetOperation); - return readMoreFromFile(); -} - void QNetworkAccessFileBackend::downstreamReadyWrite() { Q_ASSERT_X(operation() == QNetworkAccessManager::GetOperation, "QNetworkAccessFileBackend", diff --git a/src/network/access/qnetworkaccessfilebackend_p.h b/src/network/access/qnetworkaccessfilebackend_p.h index 6df8710..d1dbe8d 100644 --- a/src/network/access/qnetworkaccessfilebackend_p.h +++ b/src/network/access/qnetworkaccessfilebackend_p.h @@ -69,7 +69,6 @@ public: virtual void open(); virtual void closeDownstreamChannel(); - virtual bool waitForDownstreamReadyRead(int msecs); virtual void downstreamReadyWrite(); diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp index 1a59011..d1a18d3 100644 --- a/src/network/access/qnetworkaccessftpbackend.cpp +++ b/src/network/access/qnetworkaccessftpbackend.cpp @@ -182,23 +182,6 @@ void QNetworkAccessFtpBackend::closeDownstreamChannel() #endif } -bool QNetworkAccessFtpBackend::waitForDownstreamReadyRead(int ms) -{ - if (!ftp) - return false; - - if (ftp->bytesAvailable()) { - ftpReadyRead(); - return true; - } - - if (ms == 0) - return false; - - qCritical("QNetworkAccess: FTP backend does not support waitForReadyRead()"); - return false; -} - void QNetworkAccessFtpBackend::downstreamReadyWrite() { if (state == Transferring && ftp && ftp->bytesAvailable()) diff --git a/src/network/access/qnetworkaccessftpbackend_p.h b/src/network/access/qnetworkaccessftpbackend_p.h index 737fa72..8a2bfc3 100644 --- a/src/network/access/qnetworkaccessftpbackend_p.h +++ b/src/network/access/qnetworkaccessftpbackend_p.h @@ -87,7 +87,6 @@ public: virtual void open(); virtual void closeDownstreamChannel(); - virtual bool waitForDownstreamReadyRead(int msecs); virtual void downstreamReadyWrite(); diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index 2a0daf8..80b05a4 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -674,26 +674,6 @@ void QNetworkAccessHttpBackend::closeDownstreamChannel() // this indicates that the user closed the stream while the reply isn't finished yet } -bool QNetworkAccessHttpBackend::waitForDownstreamReadyRead(int msecs) -{ - Q_ASSERT(http); - - if (httpReply->bytesAvailable()) { - readFromHttp(); - return true; - } - - if (msecs == 0) { - // no bytes available in the socket and no waiting - return false; - } - - // ### FIXME - qCritical("QNetworkAccess: HTTP backend does not support waitForReadyRead()"); - return false; -} - - void QNetworkAccessHttpBackend::downstreamReadyWrite() { readFromHttp(); diff --git a/src/network/access/qnetworkaccesshttpbackend_p.h b/src/network/access/qnetworkaccesshttpbackend_p.h index 568b2ee..5de3429 100644 --- a/src/network/access/qnetworkaccesshttpbackend_p.h +++ b/src/network/access/qnetworkaccesshttpbackend_p.h @@ -79,7 +79,6 @@ public: virtual void open(); virtual void closeDownstreamChannel(); - virtual bool waitForDownstreamReadyRead(int msecs); virtual void downstreamReadyWrite(); virtual void setDownstreamLimited(bool b); -- cgit v0.12 From a3a84a872bb731d375a431626ccfcde5a660dd72 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 8 Nov 2010 14:08:13 +0100 Subject: QNAM: Remove dead waitForUpstreamBytesWritten() code --- src/network/access/qnetworkaccesscachebackend.cpp | 6 ------ src/network/access/qnetworkaccesscachebackend_p.h | 1 - 2 files changed, 7 deletions(-) diff --git a/src/network/access/qnetworkaccesscachebackend.cpp b/src/network/access/qnetworkaccesscachebackend.cpp index 597cbef..e78694e 100644 --- a/src/network/access/qnetworkaccesscachebackend.cpp +++ b/src/network/access/qnetworkaccesscachebackend.cpp @@ -132,12 +132,6 @@ void QNetworkAccessCacheBackend::closeUpstreamChannel() Q_ASSERT_X(false, Q_FUNC_INFO, "This function show not have been called!"); } -bool QNetworkAccessCacheBackend::waitForUpstreamBytesWritten(int) -{ - Q_ASSERT_X(false, Q_FUNC_INFO, "This function show not have been called!"); - return false; -} - void QNetworkAccessCacheBackend::upstreamReadyRead() { Q_ASSERT_X(false, Q_FUNC_INFO, "This function show not have been called!"); diff --git a/src/network/access/qnetworkaccesscachebackend_p.h b/src/network/access/qnetworkaccesscachebackend_p.h index 995c875..32581d5 100644 --- a/src/network/access/qnetworkaccesscachebackend_p.h +++ b/src/network/access/qnetworkaccesscachebackend_p.h @@ -69,7 +69,6 @@ public: void open(); void closeDownstreamChannel(); void closeUpstreamChannel(); - bool waitForUpstreamBytesWritten(int msecs); void upstreamReadyRead(); void downstreamReadyWrite(); -- cgit v0.12 From 626f13421baf258407f03e3bf21ed67138d55ea4 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 8 Nov 2010 15:03:05 +0100 Subject: Don't crash if QScriptClass property getter returns an invalid value It's possible that a class claims to have a property of a given name (i.e. queryProperty() returns true), but returns an invalid value for that property. In that case we should silently convert the value to undefined, otherwise the value may wreak havoc in JS. This is a regression from Qt 4.5 (pre-JavaScriptCore-based), which had this check. Task-number: QTBUG-15079 Reviewed-by: Jedrzej Nowacki --- src/script/bridge/qscriptclassobject.cpp | 12 ++++++++++++ tests/auto/qscriptclass/tst_qscriptclass.cpp | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp index dd229f1..228e755 100644 --- a/src/script/bridge/qscriptclassobject.cpp +++ b/src/script/bridge/qscriptclassobject.cpp @@ -78,6 +78,12 @@ bool ClassObjectDelegate::getOwnPropertySlot(QScriptObject* object, scriptObject, scriptName, QScriptClass::HandlesReadAccess, &id); if (flags & QScriptClass::HandlesReadAccess) { QScriptValue value = m_scriptClass->property(scriptObject, scriptName, id); + if (!value.isValid()) { + // The class claims to have the property, but returned an invalid + // value. Silently convert to undefined to avoid the invalid value + // "escaping" into JS. + value = QScriptValue(QScriptValue::UndefinedValue); + } slot.setValue(engine->scriptValueToJSCValue(value)); return true; } @@ -119,6 +125,12 @@ bool ClassObjectDelegate::getOwnPropertyDescriptor(QScriptObject *object, attribs |= pflags & QScriptValue::UserRange; // Rather than calling the getter, we could return an access descriptor here. QScriptValue value = m_scriptClass->property(scriptObject, scriptName, id); + if (!value.isValid()) { + // The class claims to have the property, but returned an invalid + // value. Silently convert to undefined to avoid the invalid value + // "escaping" into JS. + value = QScriptValue(QScriptValue::UndefinedValue); + } descriptor.setDescriptor(engine->scriptValueToJSCValue(value), attribs); return true; } diff --git a/tests/auto/qscriptclass/tst_qscriptclass.cpp b/tests/auto/qscriptclass/tst_qscriptclass.cpp index b4dbe73..da6c76f 100644 --- a/tests/auto/qscriptclass/tst_qscriptclass.cpp +++ b/tests/auto/qscriptclass/tst_qscriptclass.cpp @@ -66,6 +66,7 @@ public: private slots: void newInstance(); void getAndSetProperty(); + void getProperty_invalidValue(); void enumerate(); void extension(); }; @@ -741,6 +742,26 @@ void tst_QScriptClass::getAndSetProperty() QVERIFY(!obj1.property(bar).isValid()); } +void tst_QScriptClass::getProperty_invalidValue() +{ + QScriptEngine eng; + TestClass cls(&eng); + cls.addCustomProperty(eng.toStringHandle("foo"), QScriptClass::HandlesReadAccess, + /*id=*/0, QScriptValue::ReadOnly, QScriptValue()); + QScriptValue obj = eng.newObject(&cls); + + QVERIFY(obj.property("foo").isUndefined()); + + eng.globalObject().setProperty("obj", obj); + QVERIFY(eng.evaluate("obj.hasOwnProperty('foo'))").toBool()); + // The JS environment expects that a valid value is returned, + // otherwise we could crash. + QVERIFY(eng.evaluate("obj.foo").isUndefined()); + QVERIFY(eng.evaluate("obj.foo + ''").isString()); + QVERIFY(eng.evaluate("Object.getOwnPropertyDescriptor(obj, 'foo').value").isUndefined()); + QVERIFY(eng.evaluate("Object.getOwnPropertyDescriptor(obj, 'foo').value +''").isString()); +} + void tst_QScriptClass::enumerate() { QScriptEngine eng; -- cgit v0.12 From a98b9daa4cd1341ee0ce6d2cf859666db9ebda59 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 8 Nov 2010 17:23:27 +0100 Subject: QNAM: Do not need QNetworkSession in AlwaysCache load mode Move the creation code to the top of QNAM::createRequest() to avoid setting up a QNetworkSession when it is not needed. Reviewed-by: ogoffart --- src/network/access/qnetworkaccessbackend.cpp | 12 ------------ src/network/access/qnetworkaccessmanager.cpp | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp index 0a0987a..05eb6cb 100644 --- a/src/network/access/qnetworkaccessbackend.cpp +++ b/src/network/access/qnetworkaccessbackend.cpp @@ -88,18 +88,6 @@ QNetworkAccessBackendFactory::~QNetworkAccessBackendFactory() QNetworkAccessBackend *QNetworkAccessManagerPrivate::findBackend(QNetworkAccessManager::Operation op, const QNetworkRequest &request) { - QNetworkRequest::CacheLoadControl mode = - static_cast( - request.attribute(QNetworkRequest::CacheLoadControlAttribute, - QNetworkRequest::PreferNetwork).toInt()); - if (mode == QNetworkRequest::AlwaysCache - && (op == QNetworkAccessManager::GetOperation - || op == QNetworkAccessManager::HeadOperation)) { - QNetworkAccessBackend *backend = new QNetworkAccessCacheBackend; - backend->manager = this; - return backend; - } - if (!factoryDataShutdown) { QMutexLocker locker(&factoryData()->mutex); QNetworkAccessBackendFactoryData::ConstIterator it = factoryData()->constBegin(), diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index e5f4d5a..effd79e 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -54,6 +54,7 @@ #include "qnetworkaccessfilebackend_p.h" #include "qnetworkaccessdatabackend_p.h" #include "qnetworkaccessdebugpipebackend_p.h" +#include "qnetworkaccesscachebackend_p.h" #include "qfilenetworkreply_p.h" #include "QtCore/qbuffer.h" @@ -970,6 +971,26 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera return new QFileNetworkReply(this, req, op); } + // A request with QNetworkRequest::AlwaysCache does not need any bearer management + QNetworkRequest::CacheLoadControl mode = + static_cast( + req.attribute(QNetworkRequest::CacheLoadControlAttribute, + QNetworkRequest::PreferNetwork).toInt()); + if (mode == QNetworkRequest::AlwaysCache + && (op == QNetworkAccessManager::GetOperation + || op == QNetworkAccessManager::HeadOperation)) { + // FIXME Implement a QNetworkReplyCacheImpl instead, see QTBUG-15106 + QNetworkReplyImpl *reply = new QNetworkReplyImpl(this); + QNetworkReplyImplPrivate *priv = reply->d_func(); + priv->manager = this; + priv->backend = new QNetworkAccessCacheBackend(); + priv->backend->manager = this->d_func(); + priv->backend->setParent(reply); + priv->backend->reply = priv; + priv->setup(op, req, outgoingData); + return reply; + } + #ifndef QT_NO_BEARERMANAGEMENT // Return a disabled network reply if network access is disabled. // Except if the scheme is empty or file://. -- cgit v0.12 From 38f7873d8f3104ede6f7e70392f2e1ba2970b508 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 8 Nov 2010 16:56:39 +0000 Subject: Fix some painting issues in QDirectFBPaintEngine Inspired/rewrite of Denis Oliver Kropp's merge request (http://qt.gitorious.org/qt/qt/merge_requests/874) When blitting premultiplied source surfaces one has to set DSBLIT_SRC_PREMULTIPLY. This also reverts the erroneous 6acbf6dce98903310023284e27a65c19f9a829bc Merge-request: 903 Reviewed-by: Donald Carr --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 4869eba..d5697e0 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -55,6 +55,7 @@ #include #include + QT_BEGIN_NAMESPACE class SurfaceCache; @@ -112,7 +113,7 @@ public: static inline int cacheCost(const QImage &img) { return img.width() * img.height() * img.depth() / 8; } #endif - void prepareForBlit(bool alpha); + void prepareForBlit(IDirectFBSurface *surface); IDirectFBSurface *surface; @@ -616,7 +617,7 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, #if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE bool release; IDirectFBSurface *imgSurface = d->getSurface(image, &release); - d->prepareForBlit(QDirectFBScreen::hasAlphaChannel(imgSurface)); + d->prepareForBlit(imgSurface); CLIPPED_PAINT(d->blit(r, imgSurface, sr)); if (release) { #if (Q_DIRECTFB_VERSION >= 0x010000) @@ -655,8 +656,8 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, QRasterPaintEngine::drawImage(r, *img, sr); } else { QDirectFBPaintEnginePrivate::unlock(dfbData); - d->prepareForBlit(pixmap.hasAlphaChannel()); IDirectFBSurface *s = dfbData->directFBSurface(); + d->prepareForBlit(s); CLIPPED_PAINT(d->blit(r, s, sr)); } } @@ -978,7 +979,7 @@ void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode m break; case QPainter::CompositionMode_SourceOver: compositionModeStatus &= ~PorterDuff_AlwaysBlend; - surface->SetPorterDuff(surface, DSPD_NONE); + surface->SetPorterDuff(surface, DSPD_SRC_OVER); break; case QPainter::CompositionMode_DestinationOver: surface->SetPorterDuff(surface, DSPD_DST_OVER); @@ -1031,13 +1032,18 @@ void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints) } } -void QDirectFBPaintEnginePrivate::prepareForBlit(bool alpha) +void QDirectFBPaintEnginePrivate::prepareForBlit(IDirectFBSurface *s) { - DFBSurfaceBlittingFlags blittingFlags = alpha ? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; + DFBSurfaceBlittingFlags blittingFlags = DSBLIT_NOFX; + if (QDirectFBScreen::isPremultiplied(QDirectFBScreen::getImageFormat(s))) + blittingFlags |= DSBLIT_SRC_PREMULTIPLY; + if (QDirectFBScreen::hasAlphaChannel(s)) + blittingFlags |= DSBLIT_BLEND_ALPHACHANNEL; if (opacity != 255) { blittingFlags |= DSBLIT_BLEND_COLORALPHA; + surface->SetColor(surface, 0xff, 0xff, 0xff, opacity); } - surface->SetColor(surface, 0xff, 0xff, 0xff, opacity); + surface->SetBlittingFlags(surface, blittingFlags); } @@ -1154,13 +1160,13 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix QPointF offset = off; Q_ASSERT(transform.type() <= QTransform::TxScale); - prepareForBlit(pixmap.hasAlphaChannel()); QPixmapData *data = pixmap.pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast(data); + IDirectFBSurface *sourceSurface = dfbData->directFBSurface(); + prepareForBlit(sourceSurface); QDirectFBPaintEnginePrivate::unlock(dfbData); const QSize pixmapSize = dfbData->size(); - IDirectFBSurface *sourceSurface = dfbData->directFBSurface(); if (transform.isScaling()) { Q_ASSERT(supportsStretchBlit()); Q_ASSERT(qMin(transform.m11(), transform.m22()) >= 0); -- cgit v0.12 From 551a8648b93055afa92c2938af5cede7495fd7f5 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 8 Nov 2010 19:26:13 +0300 Subject: fix build on mingw > data.cpp:2: error: 'ushort' does not name a type > data.cpp:1133: error: 'ushort' does not name a type and lot of > data.cpp:1276: error: too many initializers for 'StringCollection' when the issue with ushort is fixed (by including qglobal.h, for example) a bunch of some new build errors occurs: > data.cpp:4: error: 'stringCollectionData' was declared 'extern' and later 'static' > data.h:54: error: previous declaration of 'stringCollectionData' > data.cpp:1131: error: redefinition of 'struct StringCollection' > data.h:48: error: previous definition of 'struct StringCollection' > data.cpp:1136: error: invalid type in declaration before '=' token > data.cpp:1136: error: conflicting declaration 'int stringCollection []' > data.h:55: error: 'stringCollection' has a previous declaration as 'StringCollection stringCollection [] > data.cpp:1279: error: 'stringCollectionCount' was declared 'extern' and later 'static' > data.h:56: error: previous declaration of 'stringCollectionCount' Merge-request: 910 Reviewed-By: Thiago Macieira --- tests/benchmarks/corelib/tools/qstring/data.cpp | 18 +++++++----------- tests/benchmarks/corelib/tools/qstring/data.h | 7 ++++++- tests/benchmarks/corelib/tools/qstring/generatelist.pl | 5 ++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/benchmarks/corelib/tools/qstring/data.cpp b/tests/benchmarks/corelib/tools/qstring/data.cpp index 6d1a069..a674336 100644 --- a/tests/benchmarks/corelib/tools/qstring/data.cpp +++ b/tests/benchmarks/corelib/tools/qstring/data.cpp @@ -1,5 +1,7 @@ +#include "data.h" + // This is a generated file - DO NOT EDIT -static const ushort stringCollectionData[] __attribute__((aligned(16))) = { +const ushort stringCollectionData[] __attribute__((aligned(16))) = { // #0 65535, 99, 111, 109, 112, 105, 108, 101, 114, 32, 118, 101, 114, 115, 105, 111, 110, 115, 47, @@ -1123,15 +1125,9 @@ static const ushort stringCollectionData[] __attribute__((aligned(16))) = { 65535, 84, 69, 65, 77, 66, 85, 73, 76, 68, 69, 82, 61, 65535,65534,65533, // 5216 - - }; -static struct StringCollection -{ - int len; - int offset1, offset2; - ushort align1, align2; -} stringCollection[] = { + +const struct StringCollection stringCollection[] = { {18, 1, 29, 3666, 106}, // #0 {18, 53, 77, 106, 1978}, // #1 {20, 97, 125, 2850, 3210}, // #2 @@ -1274,8 +1270,8 @@ static struct StringCollection {12, 5153, 5169, 130, 2930}, // #139 {12, 5185, 5201, 242, 2930}, // #140 }; -static const int stringCollectionCount = 141; -static const int stringCollectionMaxLen = 51; +const int stringCollectionCount = 141; +const int stringCollectionMaxLen = 51; // average comparison length: 12.0922 // cache-line crosses: 6 (2.1%) // alignment histogram: diff --git a/tests/benchmarks/corelib/tools/qstring/data.h b/tests/benchmarks/corelib/tools/qstring/data.h index c7a7467..ce733fb 100644 --- a/tests/benchmarks/corelib/tools/qstring/data.h +++ b/tests/benchmarks/corelib/tools/qstring/data.h @@ -39,6 +39,9 @@ ** ****************************************************************************/ +#ifndef DATA_H +#define DATA_H + #include struct StringCollection @@ -49,5 +52,7 @@ struct StringCollection }; extern const ushort stringCollectionData[]; -extern StringCollection stringCollection[]; +extern const StringCollection stringCollection[]; extern const int stringCollectionCount; + +#endif // DATA_H diff --git a/tests/benchmarks/corelib/tools/qstring/generatelist.pl b/tests/benchmarks/corelib/tools/qstring/generatelist.pl index d027adb..8c8eb20 100644 --- a/tests/benchmarks/corelib/tools/qstring/generatelist.pl +++ b/tests/benchmarks/corelib/tools/qstring/generatelist.pl @@ -160,11 +160,10 @@ while (1) { $totalsize += $len; $maxlen = $len if $len > $maxlen; } -print "\n};\n"; +print "};\n"; close IN; -print "struct StringCollection stringCollection[] = {\n"; - +print "const struct StringCollection stringCollection[] = {\n"; for $i (0..$count-1) { print " {", $data[$i]->{len}, ", ", -- cgit v0.12 From e00af84cc9230df411981d2f3b9296b61d5d1c50 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 8 Nov 2010 14:12:25 -0800 Subject: DFB: Make sure QPixmap::hasAlpha is respected An IDirectFBSurface can have an alpha channel for an opaque QPixmap. This change will make sure we don't blend unless QPixmap::hasAlpha returns true. Merge-request: 913 Reviewed-by: Donald Carr --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 34 +++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index d5697e0..c16a242 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -113,7 +113,11 @@ public: static inline int cacheCost(const QImage &img) { return img.width() * img.height() * img.depth() / 8; } #endif - void prepareForBlit(IDirectFBSurface *surface); + enum BlitFlag { + HasAlpha = 0x1, + Premultiplied = 0x2 + }; + void prepareForBlit(uint blitFlags); IDirectFBSurface *surface; @@ -617,7 +621,12 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, #if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE bool release; IDirectFBSurface *imgSurface = d->getSurface(image, &release); - d->prepareForBlit(imgSurface); + uint blitFlags = 0; + if (image.hasAlphaChannel()) + blitFlags |= QDirectFBPaintEnginePrivate::HasAlpha; + if (QDirectFBScreen::isPremultiplied(image.format())) + blitFlags |= QDirectFBPaintEnginePrivate::Premultiplied; + d->prepareForBlit(blitFlags); CLIPPED_PAINT(d->blit(r, imgSurface, sr)); if (release) { #if (Q_DIRECTFB_VERSION >= 0x010000) @@ -657,7 +666,13 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, } else { QDirectFBPaintEnginePrivate::unlock(dfbData); IDirectFBSurface *s = dfbData->directFBSurface(); - d->prepareForBlit(s); + uint blitFlags = 0; + if (pixmap.hasAlphaChannel()) + blitFlags |= QDirectFBPaintEnginePrivate::HasAlpha; + if (QDirectFBScreen::isPremultiplied(dfbData->pixelFormat())) + blitFlags |= QDirectFBPaintEnginePrivate::Premultiplied; + + d->prepareForBlit(blitFlags); CLIPPED_PAINT(d->blit(r, s, sr)); } } @@ -1032,12 +1047,12 @@ void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints) } } -void QDirectFBPaintEnginePrivate::prepareForBlit(IDirectFBSurface *s) +void QDirectFBPaintEnginePrivate::prepareForBlit(uint flags) { DFBSurfaceBlittingFlags blittingFlags = DSBLIT_NOFX; - if (QDirectFBScreen::isPremultiplied(QDirectFBScreen::getImageFormat(s))) + if (flags & Premultiplied) blittingFlags |= DSBLIT_SRC_PREMULTIPLY; - if (QDirectFBScreen::hasAlphaChannel(s)) + if (flags & HasAlpha) blittingFlags |= DSBLIT_BLEND_ALPHACHANNEL; if (opacity != 255) { blittingFlags |= DSBLIT_BLEND_COLORALPHA; @@ -1164,7 +1179,12 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast(data); IDirectFBSurface *sourceSurface = dfbData->directFBSurface(); - prepareForBlit(sourceSurface); + uint blitFlags = 0; + if (dfbData->hasAlphaChannel()) + blitFlags |= HasAlpha; + if (QDirectFBScreen::isPremultiplied(dfbData->pixelFormat())) + blitFlags |= Premultiplied; + prepareForBlit(blitFlags); QDirectFBPaintEnginePrivate::unlock(dfbData); const QSize pixmapSize = dfbData->size(); if (transform.isScaling()) { -- cgit v0.12 From a55c13c52822f337cc4ad708881fd54d3a1bbb1d Mon Sep 17 00:00:00 2001 From: juhvu Date: Tue, 9 Nov 2010 10:45:18 +1000 Subject: Removed implicity QtGui linking from icd.pro as it is not needed. Task-number: QTBUG-15059 --- src/plugins/bearer/icd/icd.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/bearer/icd/icd.pro b/src/plugins/bearer/icd/icd.pro index 464cc1c..6700cda 100644 --- a/src/plugins/bearer/icd/icd.pro +++ b/src/plugins/bearer/icd/icd.pro @@ -1,7 +1,7 @@ TARGET = qicdbearer include(../../qpluginbase.pri) -QT += network dbus +QT = core network dbus QMAKE_CXXFLAGS *= $$QT_CFLAGS_DBUS $$QT_CFLAGS_CONNSETTINGS LIBS += $$QT_LIBS_CONNSETTINGS -- cgit v0.12 From bb8f085611f4cb91b7bde7220d407948edcc572c Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Tue, 9 Nov 2010 11:19:01 +1000 Subject: get rid of dependency on QtGui Task-number: QTBUG-15059 Reviewed-by: trustme --- src/plugins/bearer/corewlan/corewlan.pro | 2 +- src/plugins/bearer/corewlan/qcorewlanengine.mm | 85 +++++++++++++++----------- 2 files changed, 51 insertions(+), 36 deletions(-) diff --git a/src/plugins/bearer/corewlan/corewlan.pro b/src/plugins/bearer/corewlan/corewlan.pro index 922a501..9cb3955 100644 --- a/src/plugins/bearer/corewlan/corewlan.pro +++ b/src/plugins/bearer/corewlan/corewlan.pro @@ -1,7 +1,7 @@ TARGET = qcorewlanbearer include(../../qpluginbase.pri) -QT = core gui network +QT = core network LIBS += -framework Foundation -framework SystemConfiguration contains(QT_CONFIG, corewlan) { diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index 844e38b..9946b17 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -64,12 +64,17 @@ #include #include -#include #include "private/qcore_mac_p.h" #include #include +inline QString qt_NSStringToQString(const NSString *nsstr) +{ return QCFString::toQString(reinterpret_cast(nsstr)); } + +inline NSString *qt_QStringToNSString(const QString &qstr) +{ return [reinterpret_cast(QCFString::toCFStringRef(qstr)) autorelease]; } + @interface QT_MANGLE_NAMESPACE(QNSListener) : NSObject { @@ -93,11 +98,12 @@ - (id) init { [locker lock]; - QMacCocoaAutoReleasePool pool; + NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; notificationCenter = [NSNotificationCenter defaultCenter]; currentInterface = [CWInterface interfaceWithName:nil]; [notificationCenter addObserver:self selector:@selector(notificationHandler:) name:kCWPowerDidChangeNotification object:nil]; [locker unlock]; + [autoreleasepool release]; return self; } @@ -161,10 +167,10 @@ void QScanThread::quit() void QScanThread::run() { - QMacCocoaAutoReleasePool pool; + NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; QStringList found; mutex.lock(); - CWInterface *currentInterface = [CWInterface interfaceWithName:qt_mac_QStringToNSString(interfaceName)]; + CWInterface *currentInterface = [CWInterface interfaceWithName:qt_QStringToNSString(interfaceName)]; mutex.unlock(); if([currentInterface power]) { @@ -182,14 +188,14 @@ void QScanThread::run() for(uint row=0; row < [apArray count]; row++ ) { apNetwork = [apArray objectAtIndex:row]; - const QString networkSsid = qt_mac_NSStringToQString([apNetwork ssid]); + const QString networkSsid = qt_NSStringToQString([apNetwork ssid]); const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkSsid)); found.append(id); QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined; bool known = isKnownSsid(networkSsid); if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) { - if( networkSsid == qt_mac_NSStringToQString( [currentInterface ssid])) { + if( networkSsid == qt_NSStringToQString( [currentInterface ssid])) { state = QNetworkConfiguration::Active; } } @@ -232,7 +238,7 @@ void QScanThread::run() } if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) { - if( networkSsid == qt_mac_NSStringToQString([currentInterface ssid])) { + if( networkSsid == qt_NSStringToQString([currentInterface ssid])) { state = QNetworkConfiguration::Active; } } @@ -251,6 +257,7 @@ void QScanThread::run() } } emit networksChanged(); + [autoreleasepool release]; } QStringList QScanThread::foundNetwork(const QString &id, const QString &name, const QNetworkConfiguration::StateFlags state, const QString &interfaceName, const QNetworkConfiguration::Purpose purpose) @@ -290,7 +297,7 @@ void QScanThread::getUserConfigurations() { QMutexLocker locker(&mutex); - QMacCocoaAutoReleasePool pool; + NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; userProfiles.clear(); NSArray *wifiInterfaces = [CWInterface supportedInterfaces]; @@ -310,10 +317,10 @@ void QScanThread::getUserConfigurations() NSArray *thisSsidarray = [prefNetDict valueForKey:@"SSID_STR"]; for(NSString *ssidkey in thisSsidarray) { - QString thisSsid = qt_mac_NSStringToQString(ssidkey); + QString thisSsid = qt_NSStringToQString(ssidkey); if(!userProfiles.contains(thisSsid)) { QMap map; - map.insert(thisSsid, qt_mac_NSStringToQString(nsInterfaceName)); + map.insert(thisSsid, qt_NSStringToQString(nsInterfaceName)); userProfiles.insert(thisSsid, map); } } @@ -322,7 +329,7 @@ void QScanThread::getUserConfigurations() // 802.1X user profiles QString userProfilePath = QDir::homePath() + "/Library/Preferences/com.apple.eap.profiles.plist"; - NSDictionary* eapDict = [[[NSDictionary alloc] initWithContentsOfFile:qt_mac_QStringToNSString(userProfilePath)] autorelease]; + NSDictionary* eapDict = [[[NSDictionary alloc] initWithContentsOfFile:qt_QStringToNSString(userProfilePath)] autorelease]; if(eapDict != nil) { NSString *profileStr= @"Profiles"; NSString *nameStr = @"UserDefinedName"; @@ -341,15 +348,15 @@ void QScanThread::getUserConfigurations() QString ssid; for(int i = 0; i < dictSize; i++) { if([nameStr isEqualToString:keys[i]]) { - networkName = qt_mac_NSStringToQString(objects[i]); + networkName = qt_NSStringToQString(objects[i]); } if([networkSsidStr isEqualToString:keys[i]]) { - ssid = qt_mac_NSStringToQString(objects[i]); + ssid = qt_NSStringToQString(objects[i]); } if(!userProfiles.contains(networkName) && !ssid.isEmpty()) { QMap map; - map.insert(ssid, qt_mac_NSStringToQString(nsInterfaceName)); + map.insert(ssid, qt_NSStringToQString(nsInterfaceName)); userProfiles.insert(networkName, map); } } @@ -358,6 +365,7 @@ void QScanThread::getUserConfigurations() } } } + [autoreleasepool release]; } QString QScanThread::getSsidFromNetworkName(const QString &name) @@ -434,7 +442,7 @@ QCoreWlanEngine::~QCoreWlanEngine() void QCoreWlanEngine::initialize() { QMutexLocker locker(&mutex); - QMacCocoaAutoReleasePool pool; + NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; if([[CWInterface supportedInterfaces] count] > 0 && !listener) { listener = [[QT_MANGLE_NAMESPACE(QNSListener) alloc] init]; @@ -446,6 +454,7 @@ void QCoreWlanEngine::initialize() storeSession = NULL; startNetworkChangeLoop(); + [autoreleasepool release]; } @@ -466,11 +475,11 @@ bool QCoreWlanEngine::hasIdentifier(const QString &id) void QCoreWlanEngine::connectToId(const QString &id) { QMutexLocker locker(&mutex); - QMacCocoaAutoReleasePool pool; + NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; QString interfaceString = getInterfaceFromId(id); CWInterface *wifiInterface = - [CWInterface interfaceWithName: qt_mac_QStringToNSString(interfaceString)]; + [CWInterface interfaceWithName: qt_QStringToNSString(interfaceString)]; if ([wifiInterface power]) { NSError *err = nil; @@ -488,9 +497,9 @@ void QCoreWlanEngine::connectToId(const QString &id) NSArray *array = [CW8021XProfile allUser8021XProfiles]; for (NSUInteger i = 0; i < [array count]; ++i) { - const QString networkNameHashCheck = QString::number(qHash(QLatin1String("corewlan:") + qt_mac_NSStringToQString([[array objectAtIndex:i] userDefinedName]))); + const QString networkNameHashCheck = QString::number(qHash(QLatin1String("corewlan:") + qt_NSStringToQString([[array objectAtIndex:i] userDefinedName]))); - const QString ssidHash = QString::number(qHash(QLatin1String("corewlan:") + qt_mac_NSStringToQString([[array objectAtIndex:i] ssid]))); + const QString ssidHash = QString::number(qHash(QLatin1String("corewlan:") + qt_NSStringToQString([[array objectAtIndex:i] ssid]))); if (id == networkNameHashCheck || id == ssidHash) { const QString thisName = scanThread->getSsidFromNetworkName(id); @@ -523,7 +532,7 @@ void QCoreWlanEngine::connectToId(const QString &id) [NSNumber numberWithBool:YES], kCWScanKeyMerge, [NSNumber numberWithInt:kCWScanTypeFast], kCWScanKeyScanType, [NSNumber numberWithInteger:100], kCWScanKeyRestTime, - qt_mac_QStringToNSString(wantedSsid), kCWScanKeySSID, + qt_QStringToNSString(wantedSsid), kCWScanKeySSID, nil]; NSArray *scanArray = [wifiInterface scanForNetworksWithParameters:scanParameters error:&err]; @@ -532,7 +541,7 @@ void QCoreWlanEngine::connectToId(const QString &id) for(uint row=0; row < [scanArray count]; row++ ) { CWNetwork *apNetwork = [scanArray objectAtIndex:row]; - if(wantedSsid == qt_mac_NSStringToQString([apNetwork ssid])) { + if(wantedSsid == qt_NSStringToQString([apNetwork ssid])) { if(!using8021X) { SecKeychainAttribute attributes[3]; @@ -599,18 +608,19 @@ void QCoreWlanEngine::connectToId(const QString &id) return; } } else { - qDebug() <<"associate ERROR"<< qt_mac_NSStringToQString([err localizedDescription ]); + qDebug() <<"associate ERROR"<< qt_NSStringToQString([err localizedDescription ]); } } } //end scan network } else { - qDebug() <<"scan ERROR"<< qt_mac_NSStringToQString([err localizedDescription ]); + qDebug() <<"scan ERROR"<< qt_NSStringToQString([err localizedDescription ]); } emit connectionError(id, InterfaceLookupError); } locker.unlock(); emit connectionError(id, InterfaceLookupError); + [autoreleasepool release]; } void QCoreWlanEngine::disconnectFromId(const QString &id) @@ -618,10 +628,10 @@ void QCoreWlanEngine::disconnectFromId(const QString &id) QMutexLocker locker(&mutex); QString interfaceString = getInterfaceFromId(id); - QMacCocoaAutoReleasePool pool; + NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; CWInterface *wifiInterface = - [CWInterface interfaceWithName: qt_mac_QStringToNSString(interfaceString)]; + [CWInterface interfaceWithName: qt_QStringToNSString(interfaceString)]; [wifiInterface disassociate]; if ([[wifiInterface interfaceState]intValue] != kCWInterfaceStateInactive) { @@ -629,6 +639,7 @@ void QCoreWlanEngine::disconnectFromId(const QString &id) emit connectionError(id, DisconnectionError); locker.relock(); } + [autoreleasepool release]; } void QCoreWlanEngine::requestUpdate() @@ -641,27 +652,30 @@ void QCoreWlanEngine::doRequestUpdate() { QMutexLocker locker(&mutex); - QMacCocoaAutoReleasePool pool; + NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; NSArray *wifiInterfaces = [CWInterface supportedInterfaces]; for (uint row = 0; row < [wifiInterfaces count]; ++row) { - scanThread->interfaceName = qt_mac_NSStringToQString([wifiInterfaces objectAtIndex:row]); + scanThread->interfaceName = qt_NSStringToQString([wifiInterfaces objectAtIndex:row]); scanThread->start(); } locker.unlock(); + [autoreleasepool release]; } bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName) { QMutexLocker locker(&mutex); - + bool haswifi = false; if(hasWifi) { - QMacCocoaAutoReleasePool pool; - CWInterface *defaultInterface = [CWInterface interfaceWithName: qt_mac_QStringToNSString(wifiDeviceName)]; - if([defaultInterface power]) - return true; + NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; + CWInterface *defaultInterface = [CWInterface interfaceWithName: qt_QStringToNSString(wifiDeviceName)]; + if([defaultInterface power]) { + haswifi = true; + } + [autoreleasepool release]; } - return false; + return haswifi; } @@ -853,7 +867,7 @@ quint64 QCoreWlanEngine::bytesReceived(const QString &id) quint64 QCoreWlanEngine::startTime(const QString &id) { QMutexLocker locker(&mutex); - QMacCocoaAutoReleasePool pool; + NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; quint64 timestamp = 0; NSString *filePath = @"/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist"; @@ -884,7 +898,7 @@ quint64 QCoreWlanEngine::startTime(const QString &id) bool ok = false; for(int i = 0; i < dictSize; i++) { if([ssidStr isEqualToString:keys[i]]) { - const QString ident = QString::number(qHash(QLatin1String("corewlan:") + qt_mac_NSStringToQString(objects[i]))); + const QString ident = QString::number(qHash(QLatin1String("corewlan:") + qt_NSStringToQString(objects[i]))); if(ident == id) { ok = true; } @@ -900,6 +914,7 @@ quint64 QCoreWlanEngine::startTime(const QString &id) } } } + [autoreleasepool release]; return timestamp; } -- cgit v0.12 From 8aee86b8ce4700f48b8a30752cb2293860957bb7 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 9 Nov 2010 09:20:36 +0100 Subject: Fix GC-related crash in QScriptValue::setData() Yet another missing API shim. When converting the QScriptValue to JSC, a JSCell may be allocated, which can cause the GC to trigger. If an identifier (JSC::Identifier) is then garbage collected, the destructor will try to remove itself from the currentIdentifierTable(). Because the API shim was missing, the identifier table was 0. It's difficult to create a bulletproof test for this case, but the attached test is a best effort (it crashes on my machine without the fix). Task-number: QTBUG-15144 Reviewed-by: Jedrzej Nowacki --- src/script/api/qscriptvalue.cpp | 1 + tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 13 +++++++++++++ tests/auto/qscriptvalue/tst_qscriptvalue.h | 1 + 3 files changed, 15 insertions(+) diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index f494106..e40458b 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -2036,6 +2036,7 @@ void QScriptValue::setData(const QScriptValue &data) Q_D(QScriptValue); if (!d || !d->isObject()) return; + QScript::APIShim shim(d->engine); JSC::JSValue other = d->engine->scriptValueToJSCValue(data); if (d->jscValue.inherits(&QScriptObject::info)) { QScriptObject *scriptObject = static_cast(JSC::asObject(d->jscValue)); diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 639df36..53e2699 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2253,6 +2253,19 @@ void tst_QScriptValue::getSetData() QVERIFY(!object.data().isValid()); } +void tst_QScriptValue::setData_QTBUG15144() +{ + QScriptEngine eng; + QScriptValue obj = eng.newObject(); + for (int i = 0; i < 10000; ++i) { + // Create an object with property 'fooN' on it, and immediately kill + // the reference to the object so it and the property name become garbage. + eng.evaluate(QString::fromLatin1("o = {}; o.foo%0 = 10; o = null;").arg(i)); + // Setting the data will cause a JS string to be allocated, which could + // trigger a GC. This should not cause a crash. + obj.setData("foodfight"); + } +} class TestScriptClass : public QScriptClass { public: diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.h b/tests/auto/qscriptvalue/tst_qscriptvalue.h index 462749a..aa6bc6c 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.h +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.h @@ -216,6 +216,7 @@ private slots: void getSetProperty(); void arrayElementGetterSetter(); void getSetData(); + void setData_QTBUG15144(); void getSetScriptClass(); void call(); void construct(); -- cgit v0.12 From 0a56b91991a4cce23634173eda4c5bafcd53230b Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 9 Nov 2010 12:39:14 +0100 Subject: Make operator QRectF const MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows us to convert a QGLRect to a QRectF also in const functions. Function is inline and private, no ABI break. Reviewed-by: Samuel Rødal --- src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h b/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h index 46029b9..b8c1018 100644 --- a/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h +++ b/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h @@ -93,7 +93,7 @@ struct QGLRect GLfloat right; GLfloat bottom; - operator QRectF() {return QRectF(left, top, right-left, bottom-top);} + operator QRectF() const {return QRectF(left, top, right-left, bottom-top);} }; class QGL2PEXVertexArray -- cgit v0.12 From 2ec60d5a71a560460c884be36de8fbad467fb69d Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 9 Nov 2010 17:32:15 +0100 Subject: Clear X11 structure before use This squelches valgrind warnings about uninitialized reads Task-number: QT-3973 Reviewed-by: Robert Griebl --- src/gui/kernel/qmotifdnd_x11.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qmotifdnd_x11.cpp b/src/gui/kernel/qmotifdnd_x11.cpp index 3334455..3b79129 100644 --- a/src/gui/kernel/qmotifdnd_x11.cpp +++ b/src/gui/kernel/qmotifdnd_x11.cpp @@ -385,7 +385,10 @@ static void DndReadSourceProperty(Display * dpy, static void DndWriteReceiverProperty(Display * dpy, Window window, unsigned char protocol_style) { - DndReceiverProp receiver_prop ; + DndReceiverProp receiver_prop; + + // squelch potential valgrind errors about uninitialized reads + memset(&receiver_prop, 0, sizeof(receiver_prop)); receiver_prop.byte_order = DndByteOrder() ; receiver_prop.protocol_version = DND_PROTOCOL_VERSION; -- cgit v0.12 From 339f3d9ca43987dc2dba022ec964fa43c702cb12 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 10 Nov 2010 10:50:50 +0100 Subject: Fixed a shell syntax error in configure When you have EPOCROOT environment variable, but compiling for desktop Linux, the configure script showed a shell syntax error and failed to set the install prefix, making "install" target to install to the build directory. Task-number: QTBUG-15008 Reviewed-by: axis Reviewed-by: Oswald Buddenhagen --- configure | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 1b2abf4..a238300 100755 --- a/configure +++ b/configure @@ -3314,12 +3314,9 @@ if [ -z "$QT_INSTALL_PREFIX" ]; then if [ "$PLATFORM" != "$XPLATFORM" ]; then QT_INSTALL_PREFIX="${QT_INSTALL_PREFIX}-${CFG_ARCH}" fi - elif [ -d "$EPOCROOT" ]; then - case "$XPLATFORM" in *symbian*) - QT_INSTALL_PREFIX="$EPOCROOT/epoc32/" - QT_INSTALL_LIBS="$EPOCROOT/epoc32/release/armv5/lib/" - ;; - esac + elif [ -d "$EPOCROOT" ] && echo $XPLATFORM | grep symbian > /dev/null; then + QT_INSTALL_PREFIX="$EPOCROOT/epoc32/" + QT_INSTALL_LIBS="$EPOCROOT/epoc32/release/armv5/lib/" else QT_INSTALL_PREFIX="/usr/local/Trolltech/Qt-${QT_VERSION}" # the default install prefix is /usr/local/Trolltech/Qt-$QT_VERSION fi -- cgit v0.12 From 7e1a598296e89e498fd0c27fc0951f059d1e6ffe Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Wed, 10 Nov 2010 11:10:00 +0100 Subject: fix tst_headers Fix the generator and the generated file to ensure that the string "generated" appears in the first line. --- tests/benchmarks/corelib/tools/qstring/data.cpp | 3 ++- tests/benchmarks/corelib/tools/qstring/generatelist.pl | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/benchmarks/corelib/tools/qstring/data.cpp b/tests/benchmarks/corelib/tools/qstring/data.cpp index a674336..d44a796 100644 --- a/tests/benchmarks/corelib/tools/qstring/data.cpp +++ b/tests/benchmarks/corelib/tools/qstring/data.cpp @@ -1,6 +1,7 @@ +// This is a generated file - DO NOT EDIT + #include "data.h" -// This is a generated file - DO NOT EDIT const ushort stringCollectionData[] __attribute__((aligned(16))) = { // #0 65535, diff --git a/tests/benchmarks/corelib/tools/qstring/generatelist.pl b/tests/benchmarks/corelib/tools/qstring/generatelist.pl index 8c8eb20..48a8518 100644 --- a/tests/benchmarks/corelib/tools/qstring/generatelist.pl +++ b/tests/benchmarks/corelib/tools/qstring/generatelist.pl @@ -103,9 +103,10 @@ sub printUshortArray($$$) { return ($offset + $headpadding, $offset + $headpadding + $len + $tailpadding); } +print "// This is a generated file - DO NOT EDIT\n\n"; + print "#include \"data.h\"\n\n"; -print "// This is a generated file - DO NOT EDIT\n"; print "const ushort stringCollectionData[] __attribute__((aligned(64))) = {\n"; $count = 0; $offset = 0; -- cgit v0.12 From d3a6103783b161d6d35a00cb50fef50e73b6a4b6 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 10 Nov 2010 22:35:50 +0100 Subject: remove pointless assignment of deprecated variable --- tools/qconfig/qconfig.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/qconfig/qconfig.pro b/tools/qconfig/qconfig.pro index efbfcf2..171924f 100644 --- a/tools/qconfig/qconfig.pro +++ b/tools/qconfig/qconfig.pro @@ -6,5 +6,4 @@ build_all:!build_pass { } HEADERS = feature.h featuretreemodel.h graphics.h SOURCES = main.cpp feature.cpp featuretreemodel.cpp -INTERFACES = TARGET = qconfig -- cgit v0.12