From 939fdb8f03b998996e532cb89c8e522565c1aecc Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 27 Apr 2010 11:16:10 +0200 Subject: Fix crash when using opengl graphicssystem on desktop Reviewed-By: Eskil Task-number: QTBUG-10225 --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 6 +++++- src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 3 ++- src/opengl/qgl.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 8460430..4461358 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1337,9 +1337,12 @@ void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem) d->drawCachedGlyphs(glyphType, textItem, true); } -void QGL2PaintEngineEx::drawTexture(const QRectF &dest, GLuint textureId, const QSize &size, const QRectF &src) +bool QGL2PaintEngineEx::drawTexture(const QRectF &dest, GLuint textureId, const QSize &size, const QRectF &src) { Q_D(QGL2PaintEngineEx); + if (!d->shaderManager) + return false; + ensureActive(); d->transferMode(ImageDrawingMode); @@ -1354,6 +1357,7 @@ void QGL2PaintEngineEx::drawTexture(const QRectF &dest, GLuint textureId, const d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, state()->renderHints & QPainter::SmoothPixmapTransform, textureId); d->drawTexture(dest, srcRect, size, false); + return true; } void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 30f6634..6ba0c42 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -123,7 +123,6 @@ public: virtual void renderHintsChanged(); virtual void transformChanged(); - virtual void drawTexture(const QRectF &r, GLuint textureId, const QSize &size, const QRectF &sr); virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr); virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints); @@ -136,6 +135,8 @@ public: virtual void drawStaticTextItem(QStaticTextItem *textItem); + bool drawTexture(const QRectF &r, GLuint textureId, const QSize &size, const QRectF &sr); + Type type() const { return OpenGL2; } virtual void setState(QPainterState *s); diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 72ed6be..52efea5 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2774,8 +2774,8 @@ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum text if (!eng->isNativePaintingActive()) { QRectF src(0, 0, target.width(), target.height()); QSize size(target.width(), target.height()); - eng->drawTexture(target, textureId, size, src); - return; + if (eng->drawTexture(target, textureId, size, src)) + return; } } @@ -2850,8 +2850,8 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text QRectF dest(point, QSizeF(textureWidth, textureHeight)); QRectF src(0, 0, textureWidth, textureHeight); QSize size(textureWidth, textureHeight); - eng->drawTexture(dest, textureId, size, src); - return; + if (eng->drawTexture(dest, textureId, size, src)) + return; } } -- cgit v0.12 From 346b680ab51776e6660df635b0921637f727cc75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 27 Apr 2010 15:53:13 +0200 Subject: Fix crash when CoreText fails to shape text for us As a fallback we assume one glyph per character and manually build a list of invalid glyphs with zero advance. Reviewed-and-inspired-by: Simon Hausmann --- src/gui/text/qfontengine_mac.mm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index 0bfdbc0..a6510cb 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -226,8 +226,19 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay QFixed *outAdvances_y = glyphs->advances_y; glyph_t *initialGlyph = outGlyphs; - if (arraySize == 0) - return false; + if (arraySize == 0) { + // CoreText failed to shape the text we gave it, so we assume one glyph + // per character and build a list of invalid glyphs with zero advance + *nglyphs = len; + for (int i = 0; i < len; ++i) { + outGlyphs[i] = 0; + logClusters[i] = i; + outAdvances_x[i] = QFixed(); + outAdvances_y[i] = QFixed(); + outAttributes[i].clusterStart = true; + } + return true; + } const bool rtl = (CTRunGetStatus(static_cast(CFArrayGetValueAtIndex(array, 0))) & kCTRunStatusRightToLeft); -- cgit v0.12 From 83a59e90ebf3aa2b8381f746a2c731426805b649 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Tue, 27 Apr 2010 13:13:42 +0100 Subject: Add unit tests covering most of QVector's API. Similarly to the QList tests, if this breaks, it'll be found out quickly - but it is nice to have tests to pinpoint exactly what, and why. Reviewed-by: Olivier Goffart Merge-Request: 584 --- tests/auto/qvector/tst_qvector.cpp | 600 +++++++++++++++++++++++++++++++++++++ 1 file changed, 600 insertions(+) diff --git a/tests/auto/qvector/tst_qvector.cpp b/tests/auto/qvector/tst_qvector.cpp index ebc19ed..2bc8d15 100644 --- a/tests/auto/qvector/tst_qvector.cpp +++ b/tests/auto/qvector/tst_qvector.cpp @@ -55,10 +55,610 @@ public: virtual ~tst_QVector() {} private slots: + void constructors() const; + void append() const; + void at() const; + void capacity() const; + void clear() const; + void constData() const; + void contains() const; + void count() const; + void data() const; + void empty() const; + void endsWith() const; + void fill() const; + void first() const; + void fromList() const; + void fromStdVector() const; + void indexOf() const; + void insert() const; + void isEmpty() const; + void last() const; + void lastIndexOf() const; + void mid() const; + void prepend() const; + void remove() const; + void size() const; + void startsWith() const; + void toList() const; + void toStdVector() const; + void value() const; + + void testOperators() const; + void outOfMemory(); void QTBUG6416_reserve(); }; +void tst_QVector::constructors() const +{ + // pre-reserve capacity + { + QVector myvec(5); + + QVERIFY(myvec.capacity() == 5); + } + + // default-initialise items + { + QVector myvec(5, 42); + + QVERIFY(myvec.capacity() == 5); + + // make sure all items are initialised ok + foreach (int meaningoflife, myvec) { + QCOMPARE(meaningoflife, 42); + } + } +} + +void tst_QVector::append() const +{ + QVector myvec; + myvec.append(42); + myvec.append(43); + myvec.append(44); + + QVERIFY(myvec.size() == 3); + QCOMPARE(myvec, QVector() << 42 << 43 << 44); +} + +void tst_QVector::at() const +{ + QVector myvec; + myvec << "foo" << "bar" << "baz"; + + QVERIFY(myvec.size() == 3); + QCOMPARE(myvec.at(0), QLatin1String("foo")); + QCOMPARE(myvec.at(1), QLatin1String("bar")); + QCOMPARE(myvec.at(2), QLatin1String("baz")); + + // append an item + myvec << "hello"; + QVERIFY(myvec.size() == 4); + QCOMPARE(myvec.at(0), QLatin1String("foo")); + QCOMPARE(myvec.at(1), QLatin1String("bar")); + QCOMPARE(myvec.at(2), QLatin1String("baz")); + QCOMPARE(myvec.at(3), QLatin1String("hello")); + + // remove an item + myvec.remove(1); + QVERIFY(myvec.size() == 3); + QCOMPARE(myvec.at(0), QLatin1String("foo")); + QCOMPARE(myvec.at(1), QLatin1String("baz")); + QCOMPARE(myvec.at(2), QLatin1String("hello")); +} + +void tst_QVector::capacity() const +{ + QVector myvec; + + // TODO: is this guarenteed? seems a safe assumption, but I suppose preallocation of a + // few items isn't an entirely unforseeable possibility. + QVERIFY(myvec.capacity() == 0); + + // test it gets a size + myvec << "aaa" << "bbb" << "ccc"; + QVERIFY(myvec.capacity() >= 3); + + // make sure it grows ok + myvec << "aaa" << "bbb" << "ccc"; + QVERIFY(myvec.capacity() >= 6); + + // let's try squeeze a bit + myvec.remove(3); + myvec.remove(3); + myvec.remove(3); + // TODO: is this a safe assumption? presumably it won't release memory until shrink(), but can we asser that is true? + QVERIFY(myvec.capacity() >= 6); + myvec.squeeze(); + QVERIFY(myvec.capacity() >= 3); + + myvec.remove(0); + myvec.remove(0); + myvec.remove(0); + // TODO: as above note + QVERIFY(myvec.capacity() >= 3); + myvec.squeeze(); + QVERIFY(myvec.capacity() == 0); +} + +void tst_QVector::clear() const +{ + QVector myvec; + myvec << "aaa" << "bbb" << "ccc"; + + QVERIFY(myvec.size() == 3); + myvec.clear(); + QVERIFY(myvec.size() == 0); + QVERIFY(myvec.capacity() == 0); +} + +void tst_QVector::constData() const +{ + int arr[] = { 42, 43, 44 }; + QVector myvec; + myvec << 42 << 43 << 44; + + QVERIFY(memcmp(myvec.constData(), reinterpret_cast(&arr), sizeof(int) * 3) == 0); +} + +void tst_QVector::contains() const +{ + QVector myvec; + myvec << "aaa" << "bbb" << "ccc"; + + QVERIFY(myvec.contains(QLatin1String("aaa"))); + QVERIFY(myvec.contains(QLatin1String("bbb"))); + QVERIFY(myvec.contains(QLatin1String("ccc"))); + QVERIFY(!myvec.contains(QLatin1String("I don't exist"))); + + // add it and make sure it does :) + myvec.append(QLatin1String("I don't exist")); + QVERIFY(myvec.contains(QLatin1String("I don't exist"))); +} + +void tst_QVector::count() const +{ + // total size + { + // zero size + QVector myvec; + QVERIFY(myvec.count() == 0); + + // grow + myvec.append(42); + QVERIFY(myvec.count() == 1); + myvec.append(42); + QVERIFY(myvec.count() == 2); + + // shrink + myvec.remove(0); + QVERIFY(myvec.count() == 1); + myvec.remove(0); + QVERIFY(myvec.count() == 0); + } + + // count of items + { + QVector myvec; + myvec << "aaa" << "bbb" << "ccc"; + + // initial tests + QVERIFY(myvec.count(QLatin1String("aaa")) == 1); + QVERIFY(myvec.count(QLatin1String("pirates")) == 0); + + // grow + myvec.append(QLatin1String("aaa")); + QVERIFY(myvec.count(QLatin1String("aaa")) == 2); + + // shrink + myvec.remove(0); + QVERIFY(myvec.count(QLatin1String("aaa")) == 1); + } +} + +void tst_QVector::data() const +{ + QVector myvec; + myvec << 42 << 43 << 44; + + // make sure it starts off ok + QCOMPARE(*(myvec.data() + 1), 43); + + // alter it + *(myvec.data() + 1) = 69; + + // check it altered + QCOMPARE(*(myvec.data() + 1), 69); + + int arr[] = { 42, 69, 44 }; + QVERIFY(memcmp(myvec.data(), reinterpret_cast(&arr), sizeof(int) * 3) == 0); +} + +void tst_QVector::empty() const +{ + QVector myvec; + + // starts empty + QVERIFY(myvec.empty()); + + // not empty + myvec.append(1); + QVERIFY(!myvec.empty()); + + // empty again + myvec.remove(0); + QVERIFY(myvec.empty()); +} + +void tst_QVector::endsWith() const +{ + QVector myvec; + + // empty vector + QVERIFY(!myvec.endsWith(1)); + + // add the one, should work + myvec.append(1); + QVERIFY(myvec.endsWith(1)); + + // add something else, fails now + myvec.append(3); + QVERIFY(!myvec.endsWith(1)); + + // remove it again :) + myvec.remove(1); + QVERIFY(myvec.endsWith(1)); +} + +void tst_QVector::fill() const +{ + QVector myvec; + + // resize + myvec.resize(5); + myvec.fill(69); + QCOMPARE(myvec, QVector() << 69 << 69 << 69 << 69 << 69); + + // make sure it can resize itself too + myvec.fill(42, 10); + QCOMPARE(myvec, QVector() << 42 << 42 << 42 << 42 << 42 << 42 << 42 << 42 << 42 << 42); +} + +void tst_QVector::first() const +{ + QVector myvec; + myvec << 69 << 42 << 3; + + // test it starts ok + QCOMPARE(myvec.first(), 69); + + // test removal changes + myvec.remove(0); + QCOMPARE(myvec.first(), 42); + + // test prepend changes + myvec.prepend(23); + QCOMPARE(myvec.first(), 23); +} + +void tst_QVector::fromList() const +{ + QList list; + list << "aaa" << "bbb" << "ninjas" << "pirates"; + + QVector myvec; + myvec = QVector::fromList(list); + + // test it worked ok + QCOMPARE(myvec, QVector() << "aaa" << "bbb" << "ninjas" << "pirates"); + QCOMPARE(list, QList() << "aaa" << "bbb" << "ninjas" << "pirates"); +} + +void tst_QVector::fromStdVector() const +{ + // stl = :( + std::vector svec; + svec.push_back(QLatin1String("aaa")); + svec.push_back(QLatin1String("bbb")); + svec.push_back(QLatin1String("ninjas")); + svec.push_back(QLatin1String("pirates")); + QVector myvec = QVector::fromStdVector(svec); + + // test it converts ok + QCOMPARE(myvec, QVector() << "aaa" << "bbb" << "ninjas" << "pirates"); +} + +void tst_QVector::indexOf() const +{ + QVector myvec; + myvec << "A" << "B" << "C" << "B" << "A"; + + QVERIFY(myvec.indexOf("B") == 1); + QVERIFY(myvec.indexOf("B", 1) == 1); + QVERIFY(myvec.indexOf("B", 2) == 3); + QVERIFY(myvec.indexOf("X") == -1); + QVERIFY(myvec.indexOf("X", 2) == -1); + + // add an X + myvec << "X"; + QVERIFY(myvec.indexOf("X") == 5); + QVERIFY(myvec.indexOf("X", 5) == 5); + QVERIFY(myvec.indexOf("X", 6) == -1); + + // remove first A + myvec.remove(0); + QVERIFY(myvec.indexOf("A") == 3); + QVERIFY(myvec.indexOf("A", 3) == 3); + QVERIFY(myvec.indexOf("A", 4) == -1); +} + +void tst_QVector::insert() const +{ + QVector myvec; + myvec << "A" << "B" << "C"; + + // first position + QCOMPARE(myvec.at(0), QLatin1String("A")); + myvec.insert(0, QLatin1String("X")); + QCOMPARE(myvec.at(0), QLatin1String("X")); + QCOMPARE(myvec.at(1), QLatin1String("A")); + + // middle + myvec.insert(1, QLatin1String("Z")); + QCOMPARE(myvec.at(0), QLatin1String("X")); + QCOMPARE(myvec.at(1), QLatin1String("Z")); + QCOMPARE(myvec.at(2), QLatin1String("A")); + + // end + myvec.insert(5, QLatin1String("T")); + QCOMPARE(myvec.at(5), QLatin1String("T")); + QCOMPARE(myvec.at(4), QLatin1String("C")); + + // insert a lot of garbage in the middle + myvec.insert(2, 2, QLatin1String("infinity")); + QCOMPARE(myvec, QVector() << "X" << "Z" << "infinity" << "infinity" + << "A" << "B" << "C" << "T"); +} + +void tst_QVector::isEmpty() const +{ + QVector myvec; + + // starts ok + QVERIFY(myvec.isEmpty()); + + // not empty now + myvec.append(QLatin1String("hello there")); + QVERIFY(!myvec.isEmpty()); + + // empty again + myvec.remove(0); + QVERIFY(myvec.isEmpty()); +} + +void tst_QVector::last() const +{ + QVector myvec; + myvec << "A" << "B" << "C"; + + // test starts ok + QCOMPARE(myvec.last(), QLatin1String("C")); + + // test it changes ok + myvec.append(QLatin1String("X")); + QCOMPARE(myvec.last(), QLatin1String("X")); + + // and remove again + myvec.remove(3); + QCOMPARE(myvec.last(), QLatin1String("C")); +} + +void tst_QVector::lastIndexOf() const +{ + QVector myvec; + myvec << "A" << "B" << "C" << "B" << "A"; + + QVERIFY(myvec.lastIndexOf("B") == 3); + QVERIFY(myvec.lastIndexOf("B", 2) == 1); + QVERIFY(myvec.lastIndexOf("X") == -1); + QVERIFY(myvec.lastIndexOf("X", 2) == -1); + + // add an X + myvec << "X"; + QVERIFY(myvec.lastIndexOf("X") == 5); + QVERIFY(myvec.lastIndexOf("X", 5) == 5); + QVERIFY(myvec.lastIndexOf("X", 3) == -1); + + // remove first A + myvec.remove(0); + QVERIFY(myvec.lastIndexOf("A") == 3); + QVERIFY(myvec.lastIndexOf("A", 3) == 3); + QVERIFY(myvec.lastIndexOf("A", 2) == -1); +} + +void tst_QVector::mid() const +{ + QVector list; + list << "foo" << "bar" << "baz" << "bak" << "buck" << "hello" << "kitty"; + + QCOMPARE(list.mid(3, 3), QVector() << "bak" << "buck" << "hello"); + QCOMPARE(list.mid(4), QVector() << "buck" << "hello" << "kitty"); +} + +void tst_QVector::prepend() const +{ + QVector myvec; + myvec << "A" << "B" << "C"; + + // starts ok + QVERIFY(myvec.size() == 3); + QCOMPARE(myvec.at(0), QLatin1String("A")); + + // add something + myvec.prepend(QLatin1String("X")); + QCOMPARE(myvec.at(0), QLatin1String("X")); + QCOMPARE(myvec.at(1), QLatin1String("A")); + QVERIFY(myvec.size() == 4); + + // something else + myvec.prepend(QLatin1String("Z")); + QCOMPARE(myvec.at(0), QLatin1String("Z")); + QCOMPARE(myvec.at(1), QLatin1String("X")); + QCOMPARE(myvec.at(2), QLatin1String("A")); + QVERIFY(myvec.size() == 5); + + // clear and append to an empty vector + myvec.clear(); + QVERIFY(myvec.size() == 0); + myvec.prepend(QLatin1String("ninjas")); + QVERIFY(myvec.size() == 1); + QCOMPARE(myvec.at(0), QLatin1String("ninjas")); +} + +void tst_QVector::remove() const +{ + QVector myvec; + myvec << "A" << "B" << "C"; + + // remove middle + myvec.remove(1); + QCOMPARE(myvec, QVector() << "A" << "C"); + + // remove rest + myvec.remove(0, 2); + QCOMPARE(myvec, QVector()); +} + +// ::reserve() is really hard to think of tests for, so not doing it. +// ::resize() is tested in ::capacity(). + +void tst_QVector::size() const +{ + // total size + { + // zero size + QVector myvec; + QVERIFY(myvec.size() == 0); + + // grow + myvec.append(42); + QVERIFY(myvec.size() == 1); + myvec.append(42); + QVERIFY(myvec.size() == 2); + + // shrink + myvec.remove(0); + QVERIFY(myvec.size() == 1); + myvec.remove(0); + QVERIFY(myvec.size() == 0); + } +} + +// ::squeeze() is tested in ::capacity(). + +void tst_QVector::startsWith() const +{ + QVector myvec; + + // empty vector + QVERIFY(!myvec.startsWith(1)); + + // add the one, should work + myvec.prepend(1); + QVERIFY(myvec.startsWith(1)); + + // add something else, fails now + myvec.prepend(3); + QVERIFY(!myvec.startsWith(1)); + + // remove it again :) + myvec.remove(0); + QVERIFY(myvec.startsWith(1)); +} + +void tst_QVector::toList() const +{ + QVector myvec; + myvec << "A" << "B" << "C"; + + // make sure it converts and doesn't modify the original vector + QCOMPARE(myvec.toList(), QList() << "A" << "B" << "C"); + QCOMPARE(myvec, QVector() << "A" << "B" << "C"); +} + +void tst_QVector::toStdVector() const +{ + QVector myvec; + myvec << "A" << "B" << "C"; + + std::vector svec = myvec.toStdVector(); + QCOMPARE(svec.at(0), QLatin1String("A")); + QCOMPARE(svec.at(1), QLatin1String("B")); + QCOMPARE(svec.at(2), QLatin1String("C")); + + QCOMPARE(myvec, QVector() << "A" << "B" << "C"); +} + +void tst_QVector::value() const +{ + QVector myvec; + myvec << "A" << "B" << "C"; + + // valid calls + QCOMPARE(myvec.value(0), QLatin1String("A")); + QCOMPARE(myvec.value(1), QLatin1String("B")); + QCOMPARE(myvec.value(2), QLatin1String("C")); + + // default calls + QCOMPARE(myvec.value(-1), QString()); + QCOMPARE(myvec.value(3), QString()); + + // test calls with a provided default, valid calls + QCOMPARE(myvec.value(0, QLatin1String("default")), QLatin1String("A")); + QCOMPARE(myvec.value(1, QLatin1String("default")), QLatin1String("B")); + QCOMPARE(myvec.value(2, QLatin1String("default")), QLatin1String("C")); + + // test calls with a provided default that will return the default + QCOMPARE(myvec.value(-1, QLatin1String("default")), QLatin1String("default")); + QCOMPARE(myvec.value(3, QLatin1String("default")), QLatin1String("default")); +} + +void tst_QVector::testOperators() const +{ + QVector myvec; + myvec << "A" << "B" << "C"; + QVector myvectwo; + myvectwo << "D" << "E" << "F"; + QVector combined; + combined << "A" << "B" << "C" << "D" << "E" << "F"; + + // != + QVERIFY(myvec != myvectwo); + + // + + QCOMPARE(myvec + myvectwo, combined); + QCOMPARE(myvec, QVector() << "A" << "B" << "C"); + QCOMPARE(myvectwo, QVector() << "D" << "E" << "F"); + + // += + myvec += myvectwo; + QCOMPARE(myvec, combined); + + // == + QVERIFY(myvec == combined); + + // [] + QCOMPARE(myvec[0], QLatin1String("A")); + QCOMPARE(myvec[1], QLatin1String("B")); + QCOMPARE(myvec[2], QLatin1String("C")); + QCOMPARE(myvec[3], QLatin1String("D")); + QCOMPARE(myvec[4], QLatin1String("E")); + QCOMPARE(myvec[5], QLatin1String("F")); +} + + int fooCtor; int fooDtor; -- cgit v0.12 From 3eded761167af317bab4f4d8c1ac0a12433eb03a Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 28 Apr 2010 03:50:42 +0200 Subject: A small mistake when comparing the flag. Qt::NoTextInteraction is equal to 0 so you can't compare using & because it will always be false even if the flag is set. Reviewed-by:janarve --- src/gui/text/qtextcontrol.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 3c596e5..a2ee659 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -885,8 +885,10 @@ void QTextControl::processEvent(QEvent *e, const QPointF &coordinateOffset, QWid void QTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget) { Q_D(QTextControl); - if (d->interactionFlags & Qt::NoTextInteraction) + if (d->interactionFlags == Qt::NoTextInteraction) { + e->ignore(); return; + } d->contextWidget = contextWidget; -- cgit v0.12 From f35b1fd3807c634f5fe60efecd401db7683a37fb Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 28 Apr 2010 11:52:33 +0200 Subject: Revert "Try to use multisampled opengl graphicssystem on all platforms" This reverts commit 5f63f95def838ce72af99dc697ecce092fe7eb69. Fixes GL graphics system on Windows. With the patch, windows would pop up as completely empty. --- src/opengl/qwindowsurface_gl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 92a347b..7efa9bc 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -97,7 +97,6 @@ extern Q_GUI_EXPORT bool qt_win_owndc_required; QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL) : QGraphicsSystem(), m_useX11GL(useX11GL) { - QGLWindowSurface::surfaceFormat.setSampleBuffers(true); #if defined(Q_WS_X11) && !defined(QT_OPENGL_ES) // only override the system defaults if the user hasn't already // picked a visual -- cgit v0.12 From 18480fd6cec52722d9d096991790e32837a7ebd8 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 28 Apr 2010 11:05:29 +0200 Subject: Null pointer check Fixes crash for certain SVGs Reviewed-by: Kim --- src/svg/qsvghandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index b6e771f..d545440 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -3751,7 +3751,7 @@ bool QSvgHandler::characters(const QStringRef &str) QCss::Parser(css).parse(&sheet); m_selector->styleSheets.append(sheet); return true; - } else if (m_skipNodes.isEmpty() || m_skipNodes.top() == Unknown) + } else if (m_skipNodes.isEmpty() || m_skipNodes.top() == Unknown || m_nodes.isEmpty()) return true; if (m_nodes.top()->type() == QSvgNode::TEXT || m_nodes.top()->type() == QSvgNode::TEXTAREA) { -- cgit v0.12 From a8065da96b96fcc4baeca7615c2a4195c05cbc03 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 26 Apr 2010 15:16:34 +0200 Subject: QUrl: parsing of host name with an undercore. This is not supposed to be allowed, but it work with other browsers Rask-number: QTBUG-7434 Reviewed-by: Thiago Reviewed-by: Markus Goetz --- src/corelib/io/qurl.cpp | 4 +++- tests/auto/qurl/tst_qurl.cpp | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index a60f206..4e580dd 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -2997,7 +2997,9 @@ bool qt_check_std3rules(const QChar *uc, int len) // only LDH is present if (c == '-' || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') - || (c >= 'a' && c <= 'z')) + || (c >= 'a' && c <= 'z') + //underscore is not supposed to be allowed, but other browser accept it (QTBUG-7434) + || c == '_') continue; return false; diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index b7cbdb8..fa42adc 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -1632,6 +1632,10 @@ void tst_QUrl::toString_data() QTest::newRow("nopath_task31320") << QString::fromLatin1("host://protocol") << uint(QUrl::None) << QString::fromLatin1("host://protocol"); + + QTest::newRow("underscore_QTBUG-7434") << QString::fromLatin1("http://foo_bar.host.com/rss.php") + << uint(QUrl::None) + << QString::fromLatin1("http://foo_bar.host.com/rss.php"); } void tst_QUrl::toString() @@ -3244,7 +3248,6 @@ void tst_QUrl::std3violations_data() QTest::newRow("question") << "foo?bar" << true; QTest::newRow("at") << "foo@bar" << true; QTest::newRow("backslash") << "foo\\bar" << false; - QTest::newRow("underline") << "foo_bar" << false; // these characters are transformed by NFKC to non-LDH characters QTest::newRow("dot-like") << QString::fromUtf8("foo\342\200\244bar") << false; // U+2024 ONE DOT LEADER @@ -3289,6 +3292,7 @@ void tst_QUrl::std3deviations_data() QTest::newRow("ending-dot") << "example.com."; QTest::newRow("ending-dot3002") << QString("example.com") + QChar(0x3002); + QTest::newRow("underline") << "foo_bar"; //QTBUG-7434 } void tst_QUrl::std3deviations() -- cgit v0.12 From 8bde410a6d0b1510d182a365d769db182b1c07dd Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 28 Apr 2010 14:12:59 +0200 Subject: Fixed the sizehint for cols/rows in qtableview It could return wrong values because we were not always checking the right cols/rows. Reviewed-By: gabi Task-Number: QTBUG-10169 --- src/gui/itemviews/qtableview.cpp | 8 ++++---- tests/auto/qtableview/tst_qtableview.cpp | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index 80334a6..4492e53 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -2145,8 +2145,8 @@ int QTableView::sizeHintForRow(int row) const ensurePolished(); - int left = qMax(0, columnAt(0)); - int right = columnAt(d->viewport->width()); + int left = qMax(0, d->horizontalHeader->visualIndexAt(0)); + int right = d->horizontalHeader->visualIndexAt(d->viewport->width()); if (right == -1) // the table don't have enough columns to fill the viewport right = d->model->columnCount(d->root) - 1; @@ -2204,8 +2204,8 @@ int QTableView::sizeHintForColumn(int column) const ensurePolished(); - int top = qMax(0, rowAt(0)); - int bottom = rowAt(d->viewport->height()); + int top = qMax(0, d->verticalHeader->visualIndexAt(0)); + int bottom = d->verticalHeader->visualIndexAt(d->viewport->height()); if (!isVisible() || bottom == -1) // the table don't have enough rows to fill the viewport bottom = d->model->rowCount(d->root) - 1; diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 2062e8e..3e5d077 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -202,6 +202,7 @@ private slots: void taskQTBUG_8585_crashForNoGoodReason(); void taskQTBUG_7774_RtoLVisualRegionForSelection(); void taskQTBUG_8777_scrollToSpans(); + void taskQTBUG_10169_sizeHintForRow(); void mouseWheel_data(); void mouseWheel(); @@ -478,6 +479,11 @@ public: return QTableView::selectedIndexes(); } + int sizeHintForRow(int row) const + { + return QTableView::sizeHintForRow(row); + } + bool checkSignalOrder; public slots: void currentChanged(QModelIndex , QModelIndex ) { @@ -4042,5 +4048,20 @@ void tst_QTableView::taskQTBUG_8777_scrollToSpans() QVERIFY(table.verticalScrollBar()->value() > 10); } +void tst_QTableView::taskQTBUG_10169_sizeHintForRow() +{ + QtTestTableView tableView; + QStandardItemModel model(1, 3); + model.setData(model.index(0, 0), "Word wrapping text goes here."); + tableView.setModel(&model); + tableView.verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); + const int orderedHeight = tableView.sizeHintForRow(0); + tableView.horizontalHeader()->moveSection(2, 0); + const int reorderedHeight = tableView.sizeHintForRow(0); + + //the order of the columns shouldn't matter. + QCOMPARE(orderedHeight, reorderedHeight); +} + QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" -- cgit v0.12 From f2d647aa0a203e3598b37abcd69c65aec0d3ef21 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 28 Apr 2010 14:18:25 +0200 Subject: Fix crash in styles example when running with opengl graphicssystem When drawing text using glyphs, the shader manager will select the "MaskFragmentShader" which requires a varying called "textureCoords" which is used to sample the glyph from the glyph texture. That's fine, except when you try to use one of the pattern brushes or a texture brush, because the src pixel fragment shader snippets for those brushes also sample from a texture (the brush texture) and name the verying they use "textureCoords" too. This led to textureCoords being defined twice, which in turn caused a shader compile error which then casued the seg-fault. This patch simply renames the varying used to pass the coordinates for the brush texture so it doesn't conflict. Reviewed-By: Kim Task-Number: QTBUG-9522 --- src/opengl/gl2paintengineex/qglengineshadersource_p.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index 3379296..8dba951 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -282,7 +282,7 @@ static const char* const qglslPositionWithTextureBrushVertexShader = "\n\ uniform mediump vec2 halfViewportSize; \n\ uniform highp vec2 invertedTextureSize; \n\ uniform highp mat3 brushTransform; \n\ - varying highp vec2 textureCoords; \n\ + varying highp vec2 brushTextureCoords; \n\ void setPosition(void) \n\ { \n\ highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ @@ -292,7 +292,7 @@ static const char* const qglslPositionWithTextureBrushVertexShader = "\n\ mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ - textureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \n\ + brushTextureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \n\ }\n"; static const char* const qglslAffinePositionWithTextureBrushVertexShader @@ -303,28 +303,28 @@ static const char* const qglslAffinePositionWithTextureBrushVertexShader // we emulate GL_REPEAT by only taking the fractional part of the texture coords. // TODO: Special case POT textures which don't need this emulation static const char* const qglslTextureBrushSrcFragmentShader = "\n\ - varying highp vec2 textureCoords; \n\ + varying highp vec2 brushTextureCoords; \n\ uniform lowp sampler2D brushTexture; \n\ lowp vec4 srcPixel() { \n\ - return texture2D(brushTexture, fract(textureCoords)); \n\ + return texture2D(brushTexture, fract(brushTextureCoords)); \n\ }\n"; #else static const char* const qglslTextureBrushSrcFragmentShader = "\n\ - varying highp vec2 textureCoords; \n\ + varying highp vec2 brushTextureCoords; \n\ uniform lowp sampler2D brushTexture; \n\ lowp vec4 srcPixel() \n\ { \n\ - return texture2D(brushTexture, textureCoords); \n\ + return texture2D(brushTexture, brushTextureCoords); \n\ }\n"; #endif static const char* const qglslTextureBrushSrcWithPatternFragmentShader = "\n\ - varying highp vec2 textureCoords; \n\ + varying highp vec2 brushTextureCoords; \n\ uniform lowp vec4 patternColor; \n\ uniform lowp sampler2D brushTexture; \n\ lowp vec4 srcPixel() \n\ { \n\ - return patternColor * (1.0 - texture2D(brushTexture, textureCoords).r); \n\ + return patternColor * (1.0 - texture2D(brushTexture, brushTextureCoords).r); \n\ }\n"; // Solid Fill Brush -- cgit v0.12