summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/tools/qhash.h5
-rw-r--r--src/corelib/tools/qlinkedlist.h5
-rw-r--r--src/corelib/tools/qlist.h5
-rw-r--r--src/corelib/tools/qmap.h5
-rw-r--r--src/corelib/tools/qshareddata.h20
-rw-r--r--src/corelib/tools/qvector.h5
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp4
-rw-r--r--src/gui/painting/qpainter.cpp7
-rw-r--r--src/gui/text/qtextengine.cpp19
-rw-r--r--src/gui/text/qtextlayout.cpp24
-rw-r--r--tests/auto/collections/tst_collections.cpp129
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp26
12 files changed, 219 insertions, 35 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 0777f06..c7e4bc1 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -589,10 +589,11 @@ template <class Key, class T>
Q_INLINE_TEMPLATE QHash<Key, T> &QHash<Key, T>::operator=(const QHash<Key, T> &other)
{
if (d != other.d) {
- other.d->ref.ref();
+ QHashData *o = other.d;
+ o->ref.ref();
if (!d->ref.deref())
freeData(d);
- d = other.d;
+ d = o;
if (!d->sharable)
detach_helper();
}
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index d145fe3..9b3efa3 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -312,10 +312,11 @@ template <typename T>
QLinkedList<T> &QLinkedList<T>::operator=(const QLinkedList<T> &l)
{
if (d != l.d) {
- l.d->ref.ref();
+ QLinkedListData *o = l.d;
+ o->ref.ref();
if (!d->ref.deref())
free(d);
- d = l.d;
+ d = o;
if (!d->sharable)
detach_helper();
}
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 722744c..d843cbe 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -424,10 +424,11 @@ template <typename T>
Q_INLINE_TEMPLATE QList<T> &QList<T>::operator=(const QList<T> &l)
{
if (d != l.d) {
- l.d->ref.ref();
+ QListData::Data *o = l.d;
+ o->ref.ref();
if (!d->ref.deref())
free(d);
- d = l.d;
+ d = o;
if (!d->sharable)
detach_helper();
}
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index e4b73a1..1c2aad3 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -426,10 +426,11 @@ template <class Key, class T>
Q_INLINE_TEMPLATE QMap<Key, T> &QMap<Key, T>::operator=(const QMap<Key, T> &other)
{
if (d != other.d) {
- other.d->ref.ref();
+ QMapData* o = other.d;
+ o->ref.ref();
if (!d->ref.deref())
freeData(d);
- d = other.d;
+ d = o;
if (!d->sharable)
detach_helper();
}
diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h
index 7e9934d..6483c90 100644
--- a/src/corelib/tools/qshareddata.h
+++ b/src/corelib/tools/qshareddata.h
@@ -95,9 +95,10 @@ public:
if (o.d != d) {
if (o.d)
o.d->ref.ref();
- if (d && !d->ref.deref())
- delete d;
+ T *old = d;
d = o.d;
+ if (old && !old->ref.deref())
+ delete old;
}
return *this;
}
@@ -105,9 +106,10 @@ public:
if (o != d) {
if (o)
o->ref.ref();
- if (d && !d->ref.deref())
- delete d;
+ T *old = d;
d = o;
+ if (old && !old->ref.deref())
+ delete old;
}
return *this;
}
@@ -174,9 +176,10 @@ public:
if (o.d != d) {
if (o.d)
o.d->ref.ref();
- if (d && !d->ref.deref())
- delete d;
+ T *old = d;
d = o.d;
+ if (old && !old->ref.deref())
+ delete old;
}
return *this;
}
@@ -184,9 +187,10 @@ public:
if (o != d) {
if (o)
o->ref.ref();
- if (d && !d->ref.deref())
- delete d;
+ T *old = d;
d = o;
+ if (old && !old->ref.deref())
+ delete old;
}
return *this;
}
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index c2e2485..b762b8a 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -377,10 +377,11 @@ inline void QVector<T>::replace(int i, const T &t)
template <typename T>
QVector<T> &QVector<T>::operator=(const QVector<T> &v)
{
- v.d->ref.ref();
+ QVectorData *o = v.d;
+ o->ref.ref();
if (!d->ref.deref())
free(p);
- d = v.d;
+ d = o;
if (!d->sharable)
detach_helper();
return *this;
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index a98ce6f..3c23884 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -5126,7 +5126,9 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool
q->update(itemBoundingRect.translated(item->d_ptr->sceneTransform.dx(),
item->d_ptr->sceneTransform.dy()));
} else {
- q->update(item->d_ptr->sceneTransform.mapRect(itemBoundingRect));
+ QRectF rect = item->d_ptr->sceneTransform.mapRect(itemBoundingRect);
+ if (!rect.isEmpty())
+ q->update(rect);
}
} else {
QRectF dirtyRect;
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index b694d9c..be90006 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -5862,10 +5862,13 @@ void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText
return;
}
- if (d->extended->type() == QPaintEngine::OpenGL2 && !staticText_d->untransformedCoordinates) {
+ bool paintEngineSupportsTransformations = d->extended->type() == QPaintEngine::OpenGL2
+ || d->extended->type() == QPaintEngine::OpenVG;
+
+ if (paintEngineSupportsTransformations && !staticText_d->untransformedCoordinates) {
staticText_d->untransformedCoordinates = true;
staticText_d->needsRelayout = true;
- } else if (d->extended->type() != QPaintEngine::OpenGL2 && staticText_d->untransformedCoordinates) {
+ } else if (!paintEngineSupportsTransformations && staticText_d->untransformedCoordinates) {
staticText_d->untransformedCoordinates = false;
staticText_d->needsRelayout = true;
}
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 5670e29..8d6dd6c 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1561,14 +1561,19 @@ bool QTextEngine::isRightToLeft() const
int QTextEngine::findItem(int strPos) const
{
itemize();
-
- // ##### use binary search
- int item;
- for (item = layoutData->items.size()-1; item > 0; --item) {
- if (layoutData->items[item].position <= strPos)
- break;
+ int left = 0;
+ int right = layoutData->items.size()-1;
+ while(left <= right) {
+ int middle = ((right-left)/2)+left;
+ if (strPos > layoutData->items[middle].position)
+ left = middle+1;
+ else if(strPos < layoutData->items[middle].position)
+ right = middle-1;
+ else {
+ return middle;
+ }
}
- return item;
+ return right;
}
QFixed QTextEngine::width(int from, int len) const
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 7d5fa43..f432b7e 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1217,7 +1217,7 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRang
bool hasText = (selection.format.foreground().style() != Qt::NoBrush);
bool hasBackground= (selection.format.background().style() != Qt::NoBrush);
-
+
if (hasBackground) {
selection.format.setProperty(ObjectSelectionBrush, selection.format.property(QTextFormat::BackgroundBrush));
// don't just clear the property, set an empty brush that overrides a potential
@@ -1731,7 +1731,7 @@ namespace {
};
inline bool LineBreakHelper::checkFullOtherwiseExtend(QScriptLine &line)
-{
+{
LB_DEBUG("possible break width %f, spacew=%f", tmpData.textWidth.toReal(), spaceData.textWidth.toReal());
QFixed newWidth = calculateNewWidth(line);
@@ -1797,13 +1797,23 @@ void QTextLine::layout_helper(int maxGlyphs)
bool breakany = (wrapMode == QTextOption::WrapAnywhere);
lbh.manualWrap = (wrapMode == QTextOption::ManualWrap || wrapMode == QTextOption::NoWrap);
- // #### binary search!
int item = -1;
- int newItem;
- for (newItem = eng->layoutData->items.size()-1; newItem > 0; --newItem) {
- if (eng->layoutData->items[newItem].position <= line.from)
+ int newItem = -1;
+ int left = 0;
+ int right = eng->layoutData->items.size()-1;
+ while(left <= right) {
+ int middle = ((right-left)/2)+left;
+ if (line.from > eng->layoutData->items[middle].position)
+ left = middle+1;
+ else if(line.from < eng->layoutData->items[middle].position)
+ right = middle-1;
+ else {
+ newItem = middle;
break;
+ }
}
+ if (newItem == -1)
+ newItem = right;
LB_DEBUG("from: %d: item=%d, total %d, width available %f", line.from, newItem, eng->layoutData->items.size(), line.width.toReal());
@@ -1975,7 +1985,7 @@ void QTextLine::layout_helper(int maxGlyphs)
}
LB_DEBUG("reached end of line");
lbh.checkFullOtherwiseExtend(line);
-found:
+found:
if (lbh.rightBearing > 0 && !lbh.whiteSpaceOrObject) // If right bearing has not yet been adjusted
lbh.adjustRightBearing();
line.textAdvance = line.textWidth;
diff --git a/tests/auto/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp
index d092c34..f81535e 100644
--- a/tests/auto/collections/tst_collections.cpp
+++ b/tests/auto/collections/tst_collections.cpp
@@ -165,6 +165,7 @@ private slots:
void containerTypedefs();
void forwardDeclared();
void alignment();
+ void QTBUG13079_collectionInsideCollection();
};
struct LargeStatic {
@@ -3589,5 +3590,133 @@ void tst_Collections::alignment()
}
#endif
+#ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
+
+template<template<class> class C>
+struct QTBUG13079_Node {
+ C<QTBUG13079_Node> children;
+ QString s;
+
+ ~QTBUG13079_Node() {
+ children.begin(); //play with memory
+ }
+};
+template<template<class> class C> void QTBUG13079_collectionInsideCollectionImpl()
+{
+ C<QTBUG13079_Node<C> > nodeList;
+ nodeList << QTBUG13079_Node<C>();
+ nodeList.first().s = "parent";
+ nodeList.first().children << QTBUG13079_Node<C>();
+ nodeList.first().children.first().s = "child";
+
+ nodeList = nodeList.first().children;
+ QCOMPARE(nodeList.first().s, QString::fromLatin1("child"));
+
+ nodeList = nodeList.first().children;
+ QCOMPARE(nodeList.count(), 0);
+ nodeList << QTBUG13079_Node<C>();
+}
+
+template<template<class, class> class C>
+struct QTBUG13079_NodeAssoc {
+ C<int, QTBUG13079_NodeAssoc> children;
+ QString s;
+
+ ~QTBUG13079_NodeAssoc() {
+ children.begin(); //play with memory
+ }
+};
+template<template<class, class> class C> void QTBUG13079_collectionInsideCollectionAssocImpl()
+{
+ C<int, QTBUG13079_NodeAssoc<C> > nodeMap;
+ nodeMap[18] = QTBUG13079_NodeAssoc<C>();
+ nodeMap[18].s = "parent";
+ nodeMap[18].children[12] = QTBUG13079_NodeAssoc<C>();
+ nodeMap[18].children[12].s = "child";
+
+ nodeMap = nodeMap[18].children;
+ QCOMPARE(nodeMap[12].s, QString::fromLatin1("child"));
+
+ nodeMap = nodeMap[12].children;
+ QCOMPARE(nodeMap.count(), 0);
+ nodeMap[42] = QTBUG13079_NodeAssoc<C>();
+}
+
+
+static quint32 qHash(const QTBUG13079_Node<QSet> &)
+{
+ return 0;
+}
+
+bool operator==(const QTBUG13079_Node<QSet> &a, const QTBUG13079_Node<QSet> &b)
+{
+ return a.s == b.s && a.children == b.children;
+}
+
+template<template<class> class C>
+struct QTBUG13079_NodePtr : QSharedData {
+ C<QTBUG13079_NodePtr> child;
+ QTBUG13079_NodePtr *next;
+ QString s;
+
+ QTBUG13079_NodePtr() : next(0) {}
+ ~QTBUG13079_NodePtr() {
+ next = child.data(); //play with memory
+ }
+};
+template<template<class> class C> void QTBUG13079_collectionInsidePtrImpl()
+{
+ typedef C<QTBUG13079_NodePtr<C> > Ptr;
+ {
+ Ptr nodePtr;
+ nodePtr = Ptr(new QTBUG13079_NodePtr<C>());
+ nodePtr->s = "parent";
+ nodePtr->child = Ptr(new QTBUG13079_NodePtr<C>());
+ nodePtr->child->s = "child";
+ nodePtr = nodePtr->child;
+ QCOMPARE(nodePtr->s, QString::fromLatin1("child"));
+ nodePtr = nodePtr->child;
+ QVERIFY(!nodePtr);
+ }
+ {
+ Ptr nodePtr;
+ nodePtr = Ptr(new QTBUG13079_NodePtr<C>());
+ nodePtr->s = "parent";
+ nodePtr->next = new QTBUG13079_NodePtr<C>();
+ nodePtr->next->s = "next";
+ nodePtr = Ptr(nodePtr->next);
+ QCOMPARE(nodePtr->s, QString::fromLatin1("next"));
+ nodePtr = Ptr(nodePtr->next);
+ QVERIFY(!nodePtr);
+ }
+}
+
+#endif
+
+void tst_Collections::QTBUG13079_collectionInsideCollection()
+{
+#ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
+ QTBUG13079_collectionInsideCollectionImpl<QVector>();
+ QTBUG13079_collectionInsideCollectionImpl<QStack>();
+ QTBUG13079_collectionInsideCollectionImpl<QList>();
+ QTBUG13079_collectionInsideCollectionImpl<QLinkedList>();
+ QTBUG13079_collectionInsideCollectionImpl<QQueue>();
+
+ {
+ QSet<QTBUG13079_Node<QSet> > nodeSet;
+ nodeSet << QTBUG13079_Node<QSet>();
+ nodeSet = nodeSet.begin()->children;
+ QCOMPARE(nodeSet.count(), 0);
+ }
+
+ QTBUG13079_collectionInsideCollectionAssocImpl<QMap>();
+ QTBUG13079_collectionInsideCollectionAssocImpl<QHash>();
+
+ QTBUG13079_collectionInsidePtrImpl<QSharedPointer>();
+ QTBUG13079_collectionInsidePtrImpl<QExplicitlySharedDataPointer>();
+ QTBUG13079_collectionInsidePtrImpl<QSharedDataPointer>();
+#endif
+}
+
QTEST_APPLESS_MAIN(tst_Collections)
#include "tst_collections.moc"
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index 903977c..7ee2a48 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -276,6 +276,7 @@ private slots:
void isActive();
void siblingIndexAlwaysValid();
void removeFullyTransparentItem();
+ void zeroScale();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -4564,5 +4565,30 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts()
}
}
+void tst_QGraphicsScene::zeroScale()
+{
+ //should not crash
+ QGraphicsScene scene;
+ scene.setSceneRect(-100, -100, 100, 100);
+ QGraphicsView view(&scene);
+
+ ChangedListener cl;
+ connect(&scene, SIGNAL(changed(const QList<QRectF> &)), &cl, SLOT(changed(const QList<QRectF> &)));
+
+ QGraphicsRectItem *rect1 = new QGraphicsRectItem(0, 0, 0.0000001, 0.00000001);
+ scene.addItem(rect1);
+ rect1->setRotation(82);
+ rect1->setScale(0.00000001);
+
+ QApplication::processEvents();
+ QCOMPARE(cl.changes.count(), 1);
+ QGraphicsRectItem *rect2 = new QGraphicsRectItem(-0.0000001, -0.0000001, 0.0000001, 0.0000001);
+ rect2->setScale(0.00000001);
+ scene.addItem(rect2);
+ rect1->setPos(20,20);
+ QApplication::processEvents();
+ QCOMPARE(cl.changes.count(), 2);
+}
+
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"