From 5a5337879fa4bfeacc1fe11e4b617ba623f22273 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 11 Sep 2009 10:18:12 +0200 Subject: Clean up properly in the QPF1 font engine We have to munmap() what we have mmap()ed Reviewed-by: Gunnar Reviewed-by: Jeremy --- src/gui/text/qfontengine_qws.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/text/qfontengine_qws.cpp b/src/gui/text/qfontengine_qws.cpp index 62a674a..888e1be 100644 --- a/src/gui/text/qfontengine_qws.cpp +++ b/src/gui/text/qfontengine_qws.cpp @@ -381,6 +381,8 @@ class QFontEngineQPF1Data public: QPFFontMetrics fm; QPFGlyphTree *tree; + void *mmapStart; + size_t mmapLength; }; @@ -410,6 +412,8 @@ QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn) QT_CLOSE(f); d = new QFontEngineQPF1Data; + d->mmapStart = data; + d->mmapLength = st.st_size; memcpy(reinterpret_cast(&d->fm),data,sizeof(d->fm)); data += sizeof(d->fm); @@ -431,6 +435,8 @@ QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn) QFontEngineQPF1::~QFontEngineQPF1() { + if (d->mmapStart) + munmap(d->mmapStart, d->mmapLength); delete d->tree; delete d; } -- cgit v0.12 From 3d4a2cd013f9e62788adf902a57ae8e2f31fccc7 Mon Sep 17 00:00:00 2001 From: Iain Date: Fri, 11 Sep 2009 11:19:23 +0200 Subject: Fix compile errors (missing uncaught_exception definition) on Symbian^3 When using STDCPP in Symbian^3, the definition for uncaught_exception *must* be provided before any attempt to include e32base.h is made. This is because STDCPP support disables the standard Symbian definition of uncaught_exception, so the version from needs to be used instead. Reviewed-by: Jason Barron --- src/s60main/qts60main.cpp | 1 + src/s60main/qts60main_mcrt0.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/s60main/qts60main.cpp b/src/s60main/qts60main.cpp index a919593..725b17c 100644 --- a/src/s60main/qts60main.cpp +++ b/src/s60main/qts60main.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ // INCLUDE FILES +#include // must be before e32base.h so uncaught_exception gets defined #include #include diff --git a/src/s60main/qts60main_mcrt0.cpp b/src/s60main/qts60main_mcrt0.cpp index 9439d2a..d30e07a 100644 --- a/src/s60main/qts60main_mcrt0.cpp +++ b/src/s60main/qts60main_mcrt0.cpp @@ -48,8 +48,8 @@ // EPOC32 version of crt0.c for C programs which always want multi-threaded support #include +#include // must be before e32base.h so uncaught_exception gets defined #include -#include #include "estlib.h" // Needed for QT_TRYCATCH_LEAVING. -- cgit v0.12 From ed501bfc4a6510b70dc0bba17ab3da9921ab9f9f Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 10 Sep 2009 11:15:02 +0200 Subject: Fix autotests on QMenuBar We have mousemove events but we were missing the mouse press ones. --- tests/auto/qmenubar/tst_qmenubar.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp index c74bbcb..07aa9f4 100644 --- a/tests/auto/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/qmenubar/tst_qmenubar.cpp @@ -1545,22 +1545,27 @@ void tst_QMenuBar::task256322_highlight() win.show(); QTest::qWait(200); + QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center()); QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(file).center()); - QTest::mouseClick(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center()); + QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center()); QTRY_VERIFY(menu.isVisible()); QVERIFY(!menu2.isVisible()); QCOMPARE(win.menuBar()->activeAction(), file); + QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file2).center()); QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(file2).center()); QTRY_VERIFY(!menu.isVisible()); QVERIFY(menu2.isVisible()); QCOMPARE(win.menuBar()->activeAction(), file2); + QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file2).center()); QPoint nothingCenter = win.menuBar()->actionGeometry(nothing).center(); + QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, nothingCenter); QTest::mouseMove(win.menuBar(), nothingCenter); QTRY_VERIFY(!menu2.isVisible()); QVERIFY(!menu.isVisible()); QCOMPARE(win.menuBar()->activeAction(), nothing); + QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, nothingCenter); } void tst_QMenuBar::menubarSizeHint() -- cgit v0.12 From 26da6385e1d687cc9aef375cc9b5fb4f6fc353d0 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 11 Sep 2009 11:34:15 +0200 Subject: animations now display a warning if they don't have a end value also improved the autotests --- src/corelib/animation/qpropertyanimation.cpp | 4 ++-- tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index d6ded62..861bd9f 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -273,9 +273,9 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState, if (oldState == Stopped) { d->setDefaultStartEndValue(d->targetValue->property(d->propertyName.constData())); //let's check if we have a start value and an end value - if (d->direction == Forward && !startValue().isValid() && !d->defaultStartEndValue.isValid()) + if (!startValue().isValid() && (d->direction == Backward || !d->defaultStartEndValue.isValid())) qWarning("QPropertyAnimation::updateState: starting an animation without start value"); - if (d->direction == Backward && !endValue().isValid() && !d->defaultStartEndValue.isValid()) + if (!endValue().isValid() && (d->direction == Forward || !d->defaultStartEndValue.isValid())) qWarning("QPropertyAnimation::updateState: starting an animation without end value"); } } else if (hash.value(key) == this) { diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 60bc39e..bea399c 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -473,6 +473,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() { //normal case: the animation finishes and is deleted QPointer anim = new QPropertyAnimation(&o, "ole"); + anim->setEndValue(100); QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim->start(QVariantAnimation::DeleteWhenStopped); QTest::qWait(anim->duration() + 50); @@ -482,10 +483,12 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() { QPointer anim = new QPropertyAnimation(&o, "ole"); + anim->setEndValue(100); QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim->start(QVariantAnimation::DeleteWhenStopped); QTest::qWait(anim->duration()/2); QPointer anim2 = new QPropertyAnimation(&o, "ole"); + anim2->setEndValue(100); QCOMPARE(runningSpy.count(), 1); QCOMPARE(anim->state(), QVariantAnimation::Running); @@ -634,6 +637,7 @@ void tst_QPropertyAnimation::playForwardBackward() QCOMPARE(o.property("ole").toInt(), 0); QPropertyAnimation anim(&o, "ole"); + anim.setStartValue(0); anim.setEndValue(100); anim.start(); QTest::qWait(anim.duration() + 50); @@ -906,6 +910,7 @@ void tst_QPropertyAnimation::operationsInStates() QObject o; o.setProperty("ole", 42); QPropertyAnimation anim(&o, "ole"); + anim.setEndValue(100); QSignalSpy spy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim.stop(); -- cgit v0.12 From 92789fabd6728820b244d23d7477f2a224a33f94 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 11 Sep 2009 11:44:26 +0200 Subject: small optimization for variant handling in animations Just one test less --- src/corelib/animation/qpropertyanimation.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 861bd9f..b64d7df 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -106,13 +106,19 @@ void QPropertyAnimationPrivate::updateMetaProperty() return; } + //propertyType will be set to a valid type only if there is a Q_PROPERTY + //otherwise it will be set to QVariant::Invalid at the end of this function propertyType = targetValue->property(propertyName).userType(); propertyIndex = targetValue->metaObject()->indexOfProperty(propertyName); - if (propertyIndex == -1 && !targetValue->dynamicPropertyNames().contains(propertyName)) - qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); if (propertyType != QVariant::Invalid) convertValues(propertyType); + if (propertyIndex == -1) { + //there is no Q_PROPERTY on the object + propertyType = QVariant::Invalid; + if (!targetValue->dynamicPropertyNames().contains(propertyName)) + qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); + } } void QPropertyAnimationPrivate::updateProperty(const QVariant &newValue) @@ -125,7 +131,7 @@ void QPropertyAnimationPrivate::updateProperty(const QVariant &newValue) return; } - if (propertyIndex != -1 && newValue.userType() == propertyType) { + if (newValue.userType() == propertyType) { //no conversion is needed, we directly call the QObject::qt_metacall void *data = const_cast(newValue.constData()); targetValue->qt_metacall(QMetaObject::WriteProperty, propertyIndex, &data); -- cgit v0.12 From e59d4e9f0b147409a8a2732ee3f29f8e7768349a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 10 Sep 2009 15:34:05 +0200 Subject: Enabled use of graphics system with old GL engine for testing. Reviewed-by: Trond --- src/plugins/graphicssystems/opengl/main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/opengl/main.cpp b/src/plugins/graphicssystems/opengl/main.cpp index 0562132..c28b09a 100644 --- a/src/plugins/graphicssystems/opengl/main.cpp +++ b/src/plugins/graphicssystems/opengl/main.cpp @@ -41,6 +41,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -53,11 +54,18 @@ public: QStringList QGLGraphicsSystemPlugin::keys() const { - return QStringList(QLatin1String("OpenGL")); + QStringList list; + list << QLatin1String("OpenGL") << QLatin1String("OpenGL1"); + return list; } QGraphicsSystem* QGLGraphicsSystemPlugin::create(const QString& system) { + if (system.toLower() == QLatin1String("opengl1")) { + QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); + return new QGLGraphicsSystem; + } + if (system.toLower() == QLatin1String("opengl")) return new QGLGraphicsSystem; -- cgit v0.12 From 47d6e83659f23de6bf4d0a37cb30c325dcacefc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 11 Sep 2009 10:53:39 +0200 Subject: Fixed clipping bugs in GL2 graphics system with oxygen style. QGL2PaintEngineEx::clip() needs to call ensureActive() to make sure the engine is active and synced before doing any clipping operations. We also need to set needsSync to false before entering setState() since otherwise we end up in an infinite loop in the case where replayClipOperations() again calls QGL2PaintEngineEx::clip(). Reviewed-by: Tom --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 4427ee9..e32bbbd 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1405,8 +1405,8 @@ void QGL2PaintEngineEx::ensureActive() glViewport(0, 0, d->width, d->height); glDepthMask(false); glDepthFunc(GL_LESS); - setState(state()); d->needsSync = false; + setState(state()); } } @@ -1519,6 +1519,8 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) // qDebug("QGL2PaintEngineEx::clip()"); Q_D(QGL2PaintEngineEx); + ensureActive(); + if (op == Qt::ReplaceClip && !d->hasClipOperations()) op = Qt::IntersectClip; -- cgit v0.12 From a5a27973b1e4df62217ed510229b0d8dfa70e354 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Fri, 11 Sep 2009 12:19:48 +0200 Subject: Doc: QHeaderView::section:checked was left out of stylesheet docs. Task-number: 254741 Reviewed-by: Trust Me --- doc/src/snippets/code/doc_src_stylesheet.qdoc | 5 +++++ doc/src/widgets-and-layouts/stylesheet.qdoc | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/src/snippets/code/doc_src_stylesheet.qdoc b/doc/src/snippets/code/doc_src_stylesheet.qdoc index f79f7ff..1c0440c 100644 --- a/doc/src/snippets/code/doc_src_stylesheet.qdoc +++ b/doc/src/snippets/code/doc_src_stylesheet.qdoc @@ -1007,6 +1007,11 @@ QHeaderView::section { border: 1px solid #6c6c6c; } +QHeaderView::section:checked +{ + background-color: red; +} + /* style the sort indicator */ QHeaderView::down-arrow { image: url(down_arrow.png); diff --git a/doc/src/widgets-and-layouts/stylesheet.qdoc b/doc/src/widgets-and-layouts/stylesheet.qdoc index c40795a..d2538f4 100644 --- a/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -840,7 +840,8 @@ \l{#first-ps}{:first}, \l{#last-ps}{:last}, \l{#only-one-ps}{:only-one}, \l{#next-selected-ps}{:next-selected}, \l{#previous-selected-ps}{:previous-selected}, - \l{#selected-ps}{:selected} pseudo states. + \l{#selected-ps}{:selected}, + and \l{#checked-ps}{:checked} pseudo states. Sort indicator in can be styled using the \l{#up-arrow-sub}{::up-arrow} and the -- cgit v0.12 From e2411ebd04bf9a55e6e3b24cc7886e597521d473 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Thu, 10 Sep 2009 16:14:59 +0200 Subject: Out of memory fix for qUncompress qUncompress shouldn't crash when running out of memory, since it might deal with buffers which are not under user control (same behavior as Qt 4.5). It will however throw a std::bad_alloc exception if Qt is compiled with exception handling. Reviewed-by: Harald Fernengel Reviewed-by: Ralf Engels Reviewed-by: Lars Knoll --- src/corelib/tools/qbytearray.cpp | 54 +++++++++++++++++++------------- src/corelib/tools/qbytearray.h | 1 + tests/auto/qbytearray/tst_qbytearray.cpp | 16 ++++++++-- 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 6d55ef9..d8557e5 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -47,6 +47,7 @@ #include "qlocale.h" #include "qlocale_p.h" #include "qunicodetables_p.h" +#include "qscopedpointer.h" #ifndef QT_NO_DATASTREAM #include #endif @@ -535,38 +536,49 @@ QByteArray qUncompress(const uchar* data, int nbytes) ulong expectedSize = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | (data[3] ); ulong len = qMax(expectedSize, 1ul); - QByteArray baunzip; - int res; - do { - QT_TRY { - baunzip.resize(len); - res = ::uncompress((uchar*)baunzip.data(), &len, - (uchar*)data+4, nbytes-4); - } QT_CATCH (const std::bad_alloc &) { - res = Z_MEM_ERROR; + QScopedPointer d; + + forever { + ulong alloc = len; + d.reset(q_check_ptr(static_cast(qRealloc(d.data(), sizeof(QByteArray::Data) + alloc)))); + if (!d) { + // we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS + qWarning("qUncompress: could not allocate enough memory to uncompress data"); + return QByteArray(); } + int res = ::uncompress((uchar*)d->array, &len, + (uchar*)data+4, nbytes-4); + switch (res) { case Z_OK: - if ((int)len != baunzip.size()) - baunzip.resize(len); - break; + if (len != alloc) { + d.reset(q_check_ptr(static_cast(qRealloc(d.data(), sizeof(QByteArray::Data) + len)))); + if (!d) { + // we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS + qWarning("qUncompress: could not allocate enough memory to uncompress data"); + return QByteArray(); + } + } + d->ref = 1; + d->alloc = d->size = len; + d->data = d->array; + + return QByteArray(d.take(), 0, 0); + case Z_MEM_ERROR: qWarning("qUncompress: Z_MEM_ERROR: Not enough memory"); - break; + return QByteArray(); + case Z_BUF_ERROR: len *= 2; - break; + continue; + case Z_DATA_ERROR: qWarning("qUncompress: Z_DATA_ERROR: Input data is corrupted"); - break; + return QByteArray(); } - } while (res == Z_BUF_ERROR); - - if (res != Z_OK) - baunzip = QByteArray(); - - return baunzip; + } } #endif diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 191f6a2..9621dbf 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -372,6 +372,7 @@ private: friend class QByteRef; friend class QString; + friend QByteArray qUncompress(const uchar *data, int nbytes); public: typedef Data * DataPtr; inline DataPtr &data_ptr() { return d; } diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp index 44cfe4a..b0bf3df 100644 --- a/tests/auto/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/qbytearray/tst_qbytearray.cpp @@ -236,6 +236,7 @@ void tst_QByteArray::qUncompress_data() void tst_QByteArray::qUncompress() { QFETCH(QByteArray, in); + QFETCH(QByteArray, out); #if defined Q_OS_HPUX && !defined __ia64 && defined Q_CC_GNU QSKIP("Corrupt data causes this tests to lock up on HP-UX / PA-RISC with gcc", SkipAll); @@ -245,9 +246,20 @@ void tst_QByteArray::qUncompress() QSKIP("Corrupt data causes this test to lock up on QNX", SkipAll); #endif - QTEST(::qUncompress(in), "out"); + QByteArray res; + QT_TRY { + res = ::qUncompress(in); + } QT_CATCH(const std::bad_alloc &) { + res = QByteArray(); + } + QCOMPARE(res, out); - QTEST(::qUncompress(in + "blah"), "out"); + QT_TRY { + res = ::qUncompress(in + "blah"); + } QT_CATCH(const std::bad_alloc &) { + res = QByteArray(); + } + QCOMPARE(res, out); } #endif -- cgit v0.12 From 42beaa8e1e422a41efe1a398b55db044827f336c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 11 Sep 2009 13:21:35 +0200 Subject: Skip pointless test It is planned that this test will do something sensible in the future. Reviewed-by: Jesper --- tests/auto/qtwidgets/tst_qtwidgets.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/qtwidgets/tst_qtwidgets.cpp b/tests/auto/qtwidgets/tst_qtwidgets.cpp index 12bc02f..a765bde 100644 --- a/tests/auto/qtwidgets/tst_qtwidgets.cpp +++ b/tests/auto/qtwidgets/tst_qtwidgets.cpp @@ -72,6 +72,8 @@ tst_QtWidgets::~tst_QtWidgets() void tst_QtWidgets::snapshot() { + QSKIP("Jesper will fix this test when he has time.", SkipAll); +#if 0 StyleWidget widget(0, Qt::X11BypassWindowManagerHint); widget.show(); @@ -100,6 +102,7 @@ void tst_QtWidgets::snapshot() } QVERIFY2(ftp.error() == QFtp::NoError, ftp.errorString().toLocal8Bit().constData()); QVERIFY(!ftp.hasPendingCommands()); +#endif } -- cgit v0.12