summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-02-24 19:07:34 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-02-24 19:07:34 (GMT)
commit4ef9e81c777affd140dbda97645b31b7658c7280 (patch)
treebbf07db11604e1c2541cf8abbea6465b729864f0
parent677f1b4af363845189d93bf564ab9ba97eb160e0 (diff)
parent45b205692e457bf39a245436b7db0bb03bd27bbd (diff)
downloadQt-4ef9e81c777affd140dbda97645b31b7658c7280.zip
Qt-4ef9e81c777affd140dbda97645b31b7658c7280.tar.gz
Qt-4ef9e81c777affd140dbda97645b31b7658c7280.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Fixed translucent window rendering on 16 bit X11. GV: Update issues if drawItems() is overridden and IndirectPainting is used. More pedantry. Fix grammar. Doc: QFutureWatcher: specify that calls to setFuture should happen after the connections
-rw-r--r--src/corelib/concurrent/qfuturewatcher.cpp7
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp27
-rw-r--r--src/gui/image/qnativeimage.cpp2
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp26
4 files changed, 59 insertions, 3 deletions
diff --git a/src/corelib/concurrent/qfuturewatcher.cpp b/src/corelib/concurrent/qfuturewatcher.cpp
index 3065205..3b808b8 100644
--- a/src/corelib/concurrent/qfuturewatcher.cpp
+++ b/src/corelib/concurrent/qfuturewatcher.cpp
@@ -499,6 +499,13 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event)
/*! \fn void QFutureWatcher::setFuture(const QFuture<T> &future)
Starts watching the given \a future.
+
+ One of the signals might be emitted for the current state of the
+ \a future. For example, if the future is already stopped, the
+ finished signal will be emitted.
+
+ To avoid a race condition, it is important to call this function
+ \i after doing the connections.
*/
/*! \fn QFuture<T> QFutureWatcher::future() const
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 06b7438..1ced3d7 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -3400,6 +3400,13 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
if (!d->scene->d_func()->painterStateProtection)
painter.setWorldTransform(viewTransform);
} else {
+ // Make sure we don't have unpolished items before we draw
+ if (!d->scene->d_func()->unpolishedItems.isEmpty())
+ d->scene->d_func()->_q_polishItems();
+ // We reset updateAll here (after we've issued polish events)
+ // so that we can discard update requests coming from polishEvent().
+ d->scene->d_func()->updateAll = false;
+
// Find all exposed items
bool allItems = false;
QList<QGraphicsItem *> itemList = d->findItems(d->exposedRegion, &allItems, viewTransform);
@@ -3408,9 +3415,25 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
const int numItems = itemList.size();
QGraphicsItem **itemArray = &itemList[0]; // Relies on QList internals, but is perfectly valid.
QStyleOptionGraphicsItem *styleOptionArray = d->allocStyleOptionsArray(numItems);
+ QTransform transform(Qt::Uninitialized);
for (int i = 0; i < numItems; ++i) {
- itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], viewTransform,
- d->exposedRegion, allItems);
+ QGraphicsItem *item = itemArray[i];
+ QGraphicsItemPrivate *itemd = item->d_ptr.data();
+ itemd->initStyleOption(&styleOptionArray[i], viewTransform, d->exposedRegion, allItems);
+ // Cache the item's area in view coordinates.
+ // Note that we have to do this here in case the base class implementation
+ // (QGraphicsScene::drawItems) is not called. If it is, we'll do this
+ // operation twice, but that's the price one has to pay for using indirect
+ // painting :-/.
+ const QRectF brect = adjustedItemEffectiveBoundingRect(item);
+ if (!itemd->itemIsUntransformable()) {
+ transform = item->sceneTransform();
+ if (viewTransformed)
+ transform *= viewTransform;
+ } else {
+ transform = item->deviceTransform(viewTransform);
+ }
+ itemd->paintedViewBoundingRects.insert(d->viewport, transform.mapRect(brect).toRect());
}
// Draw the items.
drawItems(&painter, numItems, itemArray, styleOptionArray);
diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp
index 2226901..8446387 100644
--- a/src/gui/image/qnativeimage.cpp
+++ b/src/gui/image/qnativeimage.cpp
@@ -182,7 +182,7 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /*
qWarning() << "Error while marking the shared memory segment to be destroyed";
ok = (xshminfo.shmaddr != (char*)-1);
if (ok)
- image = QImage((uchar *)xshmimg->data, width, height, systemFormat());
+ image = QImage((uchar *)xshmimg->data, width, height, format);
}
xshminfo.readOnly = false;
if (ok)
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 59bffeb..c77f76d 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -218,6 +218,7 @@ private slots:
void update();
void inputMethodSensitivity();
void inputContextReset();
+ void indirectPainting();
// task specific tests below me
void task172231_untransformableItems();
@@ -3799,6 +3800,31 @@ void tst_QGraphicsView::inputContextReset()
QCOMPARE(inputContext.resets, 0);
}
+void tst_QGraphicsView::indirectPainting()
+{
+ class MyScene : public QGraphicsScene
+ { public:
+ MyScene() : QGraphicsScene(), drawCount(0) {}
+ void drawItems(QPainter *, int, QGraphicsItem **, const QStyleOptionGraphicsItem *, QWidget *)
+ { ++drawCount; }
+ int drawCount;
+ };
+
+ MyScene scene;
+ QGraphicsItem *item = scene.addRect(0, 0, 50, 50);
+
+ QGraphicsView view(&scene);
+ view.setOptimizationFlag(QGraphicsView::IndirectPainting);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QTest::qWait(100);
+
+ scene.drawCount = 0;
+ item->setPos(20, 20);
+ QApplication::processEvents();
+ QTRY_VERIFY(scene.drawCount > 0);
+}
+
void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged()
{
QGraphicsView view;