From 452e13b5407fa4c36f9a573c305d41f551762b93 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Fri, 20 May 2011 14:22:39 +1000 Subject: Notify when the TextInput cursorRectangle property changes within pre-edit Anything that updates the horizontal scroll is also likely to change the position of the cursor rectangle and the micro focus. So group these actions together and ensure they're done before emitting cursorPositionChanged() so positionToRectangle() returns a valid value from that handler. Change-Id: I5fadc58efb148a8dabe88a94381c86cd64dba3bd Task-number: QTBUG-19089 Reviewed-by: Martin Jones (cherry picked from commit a0b2fc44ff8752193cacde52276b1822741f5374) --- .../graphicsitems/qdeclarativetextinput.cpp | 54 ++++++++-------------- .../graphicsitems/qdeclarativetextinput_p.h | 5 +- 2 files changed, 23 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 98ec2050e9..b456d07c02 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -236,11 +236,11 @@ void QDeclarativeTextInput::setFont(const QFont &font) if (oldFont != d->font) { d->control->setFont(d->font); + updateSize(); + updateCursorRectangle(); if(d->cursorItem){ d->cursorItem->setHeight(QFontMetrics(d->font).height()); - moveCursor(); } - updateSize(); } emit fontChanged(d->sourceFont); } @@ -359,8 +359,7 @@ void QDeclarativeTextInput::setHAlign(HAlignment align) bool forceAlign = d->hAlignImplicit && d->effectiveLayoutMirror; d->hAlignImplicit = false; if (d->setHAlign(align, forceAlign) && isComponentComplete()) { - updateRect(); - d->updateHorizontalScroll(); + updateCursorRectangle(); } } @@ -369,8 +368,7 @@ void QDeclarativeTextInput::resetHAlign() Q_D(QDeclarativeTextInput); d->hAlignImplicit = true; if (d->determineHorizontalAlignment() && isComponentComplete()) { - updateRect(); - d->updateHorizontalScroll(); + updateCursorRectangle(); } } @@ -423,8 +421,7 @@ void QDeclarativeTextInputPrivate::mirrorChange() Q_Q(QDeclarativeTextInput); if (q->isComponentComplete()) { if (!hAlignImplicit && (hAlign == QDeclarativeTextInput::AlignRight || hAlign == QDeclarativeTextInput::AlignLeft)) { - q->updateRect(); - updateHorizontalScroll(); + q->updateCursorRectangle(); emit q->effectiveHorizontalAlignmentChanged(); } } @@ -683,7 +680,7 @@ void QDeclarativeTextInput::setAutoScroll(bool b) d->autoScroll = b; //We need to repaint so that the scrolling is taking into account. updateSize(true); - d->updateHorizontalScroll(); + updateCursorRectangle(); emit autoScrollChanged(d->autoScroll); } @@ -947,10 +944,6 @@ void QDeclarativeTextInput::setCursorDelegate(QDeclarativeComponent* c) d->cursorComponent = c; if(!c){ //note that the components are owned by something else - disconnect(d->control, SIGNAL(cursorPositionChanged(int,int)), - this, SLOT(moveCursor())); - disconnect(d->control, SIGNAL(updateMicroFocus()), - this, SLOT(moveCursor())); delete d->cursorItem; }else{ d->startCreatingCursor(); @@ -962,10 +955,6 @@ void QDeclarativeTextInput::setCursorDelegate(QDeclarativeComponent* c) void QDeclarativeTextInputPrivate::startCreatingCursor() { Q_Q(QDeclarativeTextInput); - q->connect(control, SIGNAL(cursorPositionChanged(int,int)), - q, SLOT(moveCursor()), Qt::UniqueConnection); - q->connect(control, SIGNAL(updateMicroFocus()), - q, SLOT(moveCursor()), Qt::UniqueConnection); if(cursorComponent->isReady()){ q->createCursor(); }else if(cursorComponent->isLoading()){ @@ -1001,15 +990,6 @@ void QDeclarativeTextInput::createCursor() d->cursorItem->setHeight(d->control->height()-1); // -1 to counter QLineControl's +1 which is not consistent with Text. } -void QDeclarativeTextInput::moveCursor() -{ - Q_D(QDeclarativeTextInput); - if(!d->cursorItem) - return; - d->updateHorizontalScroll(); - d->cursorItem->setX(d->control->cursorToX() - d->hscroll); -} - /*! \qmlmethod rect TextInput::positionToRectangle(int pos) @@ -1118,8 +1098,6 @@ void QDeclarativeTextInput::inputMethodEvent(QInputMethodEvent *ev) ev->ignore(); } else { d->control->processInputMethodEvent(ev); - updateSize(); - d->updateHorizontalScroll(); } } if (!ev->isAccepted()) @@ -1297,7 +1275,7 @@ void QDeclarativeTextInput::geometryChanged(const QRectF &newGeometry, Q_D(QDeclarativeTextInput); if (newGeometry.width() != oldGeometry.width()) { updateSize(); - d->updateHorizontalScroll(); + updateCursorRectangle(); } QDeclarativePaintedItem::geometryChanged(newGeometry, oldGeometry); } @@ -1643,7 +1621,6 @@ void QDeclarativeTextInput::moveCursorSelection(int position) { Q_D(QDeclarativeTextInput); d->control->moveCursor(position, true); - d->updateHorizontalScroll(); } /*! @@ -1901,7 +1878,7 @@ void QDeclarativeTextInputPrivate::init() canPaste = !control->isReadOnly() && QApplication::clipboard()->text().length() != 0; #endif // QT_NO_CLIPBOARD q->connect(control, SIGNAL(updateMicroFocus()), - q, SLOT(updateMicroFocus())); + q, SLOT(updateCursorRectangle())); q->connect(control, SIGNAL(displayTextChanged(QString)), q, SLOT(updateRect())); q->updateSize(); @@ -1917,9 +1894,7 @@ void QDeclarativeTextInputPrivate::init() void QDeclarativeTextInput::cursorPosChanged() { Q_D(QDeclarativeTextInput); - d->updateHorizontalScroll(); - updateRect();//TODO: Only update rect between pos's - updateMicroFocus(); + updateCursorRectangle(); emit cursorPositionChanged(); d->control->resetCursorBlinkTimer(); @@ -1935,6 +1910,17 @@ void QDeclarativeTextInput::cursorPosChanged() } } +void QDeclarativeTextInput::updateCursorRectangle() +{ + Q_D(QDeclarativeTextInput); + d->updateHorizontalScroll(); + updateRect();//TODO: Only update rect between pos's + updateMicroFocus(); + emit cursorRectangleChanged(); + if (d->cursorItem) + d->cursorItem->setX(d->control->cursorToX() - d->hscroll); +} + void QDeclarativeTextInput::selectionChanged() { Q_D(QDeclarativeTextInput); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h index aaf8859150..8b7fff9cfb 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h @@ -75,7 +75,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextInput : public QDeclarativeImplicitSizeP Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged) Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged) Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged) - Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorPositionChanged) + Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged) Q_PROPERTY(QDeclarativeComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged) Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged) Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged) @@ -221,6 +221,7 @@ public: Q_SIGNALS: void textChanged(); void cursorPositionChanged(); + void cursorRectangleChanged(); void selectionStartChanged(); void selectionEndChanged(); void selectedTextChanged(); @@ -279,8 +280,8 @@ private Q_SLOTS: void q_textChanged(); void selectionChanged(); void createCursor(); - void moveCursor(); void cursorPosChanged(); + void updateCursorRectangle(); void updateRect(const QRect &r = QRect()); void q_canPasteChanged(); -- cgit v1.2.3 From a081f12ad755d186596e1b4b98bf908be342c874 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 9 Jun 2011 12:55:49 +0200 Subject: Use the Qt 4 function for updatesEnabled() Change-Id: I78bf3b8acff54b83493aebc480e7f9b4f32c1c70 --- src/declarative/items/qsgcanvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp index e10c57d015..614c826563 100644 --- a/src/declarative/items/qsgcanvas.cpp +++ b/src/declarative/items/qsgcanvas.cpp @@ -223,7 +223,7 @@ void QSGCanvas::paintEvent(QPaintEvent *) if (d->animationDriver->isRunning()) update(); } else { - if (isUpdatesEnabled()) { + if (updatesEnabled()) { d->thread->paint(); setUpdatesEnabled(false); } -- cgit v1.2.3 From 7b28a7eebeb8cbe5d356fc9b24651a36d73ab1ad Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 10 Jun 2011 16:07:33 +1000 Subject: Add delegate property to ItemParticle Also add burst(n,x,y) to ParticleEmitter, and a demo that uses both. --- src/declarative/particles/qsgitemparticle.cpp | 78 ++++++++++++++++-------- src/declarative/particles/qsgitemparticle_p.h | 23 ++++++- src/declarative/particles/qsgmodelparticle.cpp | 2 + src/declarative/particles/qsgparticleemitter.cpp | 7 +++ src/declarative/particles/qsgparticleemitter_p.h | 1 + 5 files changed, 83 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/declarative/particles/qsgitemparticle.cpp b/src/declarative/particles/qsgitemparticle.cpp index 819c823155..498dd90a87 100644 --- a/src/declarative/particles/qsgitemparticle.cpp +++ b/src/declarative/particles/qsgitemparticle.cpp @@ -42,14 +42,22 @@ #include "qsgitemparticle_p.h" #include #include +#include +#include #include QT_BEGIN_NAMESPACE QSGItemParticle::QSGItemParticle(QSGItem *parent) : - QSGParticlePainter(parent), m_fade(true) + QSGParticlePainter(parent), m_fade(true), m_delegate(0) { setFlag(QSGItem::ItemHasContents); + QTimer* manageDelegates = new QTimer(this);//TODO: don't leak + connect(manageDelegates, SIGNAL(timeout()), + this, SLOT(tick())); + manageDelegates->setInterval(16); + manageDelegates->setSingleShot(false); + manageDelegates->start(); } @@ -79,33 +87,54 @@ void QSGItemParticle::give(QSGItem *item) void QSGItemParticle::load(QSGParticleData* d) { - if(m_pendingItems.isEmpty()) - return; int pos = particleTypeIndex(d); - if(m_items[pos]){ - if(m_stasis.contains(m_items[pos])) - qWarning() << "Current model particles prefers overwrite:false"; - //remove old item from the particle that is dying to make room for this one - m_items[pos]->setOpacity(0.); + m_data[pos] = d; + m_loadables << pos; +} + +void QSGItemParticle::tick() +{ + foreach(QSGItem* item, m_deletables){ + if(m_fade) + item->setOpacity(0.); QSGItemParticleAttached* mpa; - if((mpa = qobject_cast(qmlAttachedPropertiesObject(m_items[pos], false)))) + if((mpa = qobject_cast(qmlAttachedPropertiesObject(item)))) mpa->detach();//reparent as well? - m_items[pos] = 0; - m_data[pos] = 0; + //TODO: Delete iff we created it m_activeCount--; + m_deletables.removeAll(item); } - m_items[pos] = m_pendingItems.front(); - m_pendingItems.pop_front(); - m_items[pos]->setX(d->curX() - m_items[pos]->width()/2); - m_items[pos]->setY(d->curY() - m_items[pos]->height()/2); - QSGItemParticleAttached* mpa = qobject_cast(qmlAttachedPropertiesObject(m_items[pos])); - if(mpa){ - mpa->m_mp = this; - mpa->attach(); + + foreach(int pos, m_loadables){ + if(m_stasis.contains(m_items[pos])) + qWarning() << "Current model particles prefers overwrite:false"; + //remove old item from the particle that is dying to make room for this one + if(m_items[pos]){ + m_deletables << m_items[pos]; + m_activeCount--; + } + m_items[pos] = 0; + if(!m_pendingItems.isEmpty()){ + m_items[pos] = m_pendingItems.front(); + m_pendingItems.pop_front(); + }else if(m_delegate){ + m_items[pos] = qobject_cast(m_delegate->create(qmlContext(this))); + } + if(m_items[pos]){ + m_items[pos]->setX(m_data[pos]->curX() - m_items[pos]->width()/2);//TODO: adjust for system? + m_items[pos]->setY(m_data[pos]->curY() - m_items[pos]->height()/2); + QSGItemParticleAttached* mpa = qobject_cast(qmlAttachedPropertiesObject(m_items[pos])); + if(mpa){ + mpa->m_mp = this; + mpa->attach(); + } + m_items[pos]->setParentItem(this); + if(m_fade) + m_items[pos]->setOpacity(0.); + m_activeCount++; + } + m_loadables.removeAll(pos); } - m_items[pos]->setParentItem(this); - m_data[pos] = d; - m_activeCount++; } void QSGItemParticle::reload(QSGParticleData* d) @@ -173,10 +202,7 @@ void QSGItemParticle::prepareNextFrame() continue; } if(t >= 1.0){//Usually happens from load - item->setOpacity(0.); - QSGItemParticleAttached* mpa; - if((mpa = qobject_cast(qmlAttachedPropertiesObject(m_items[i])))) - mpa->detach();//reparent as well? + m_deletables << item; m_items[i] = 0; m_data[i] = 0; m_activeCount--; diff --git a/src/declarative/particles/qsgitemparticle_p.h b/src/declarative/particles/qsgitemparticle_p.h index fa3516b631..3b7db519de 100644 --- a/src/declarative/particles/qsgitemparticle_p.h +++ b/src/declarative/particles/qsgitemparticle_p.h @@ -55,8 +55,8 @@ class QSGItemParticleAttached; class QSGItemParticle : public QSGParticlePainter { Q_OBJECT - Q_PROPERTY(bool fade READ fade WRITE setFade NOTIFY fadeChanged) + Q_PROPERTY(QDeclarativeComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) public: explicit QSGItemParticle(QSGItem *parent = 0); @@ -69,9 +69,16 @@ public: virtual int count(); static QSGItemParticleAttached *qmlAttachedProperties(QObject *object); + QDeclarativeComponent* delegate() const + { + return m_delegate; + } + signals: void fadeChanged(); + void delegateChanged(QDeclarativeComponent* arg); + public slots: //TODO: Add a follow mode, where moving the delegate causes the logical particle to go with it? void freeze(QSGItem* item); @@ -80,11 +87,22 @@ public slots: void give(QSGItem* item);//give from modelparticle void setFade(bool arg){if(arg == m_fade) return; m_fade = arg; emit fadeChanged();} + void setDelegate(QDeclarativeComponent* arg) + { + if (m_delegate != arg) { + m_delegate = arg; + emit delegateChanged(arg); + } + } + protected: virtual void reset(); void prepareNextFrame(); +private slots: + void tick(); private: - QList > m_deletables; + QList m_deletables; + QList< int > m_loadables; int m_particleCount; bool m_fade; @@ -96,6 +114,7 @@ private: QSet m_stasis; qreal m_lastT; int m_activeCount; + QDeclarativeComponent* m_delegate; }; class QSGItemParticleAttached : public QObject diff --git a/src/declarative/particles/qsgmodelparticle.cpp b/src/declarative/particles/qsgmodelparticle.cpp index 704b9a298c..b0b4fa4ad2 100644 --- a/src/declarative/particles/qsgmodelparticle.cpp +++ b/src/declarative/particles/qsgmodelparticle.cpp @@ -177,6 +177,7 @@ void QSGModelParticle::processPending() foreach(QSGItem* item, m_deletables){ item->setOpacity(0.); m_model->release(item); + m_deletables.removeAll(item); } foreach(int pos, m_requests){ @@ -189,6 +190,7 @@ void QSGModelParticle::processPending() mpa->attach(); } m_items[pos]->setParentItem(this); + m_requests.removeAll(pos); } } diff --git a/src/declarative/particles/qsgparticleemitter.cpp b/src/declarative/particles/qsgparticleemitter.cpp index 20f3c6bb4b..143338f798 100644 --- a/src/declarative/particles/qsgparticleemitter.cpp +++ b/src/declarative/particles/qsgparticleemitter.cpp @@ -121,6 +121,13 @@ void QSGParticleEmitter::burst(int num) m_burstQueue << qMakePair(num, QPointF(x(), y())); } +void QSGParticleEmitter::burst(int num, qreal x, qreal y) +{ + if(!particleCount()) + qWarning() << "burst called on an emitter with a particle count of zero"; + m_burstQueue << qMakePair(num, QPointF(x, y)); +} + void QSGParticleEmitter::setMaxParticleCount(int arg) { if (m_maxParticleCount != arg) { diff --git a/src/declarative/particles/qsgparticleemitter_p.h b/src/declarative/particles/qsgparticleemitter_p.h index 9fafd9d43d..65aca0c83e 100644 --- a/src/declarative/particles/qsgparticleemitter_p.h +++ b/src/declarative/particles/qsgparticleemitter_p.h @@ -142,6 +142,7 @@ signals: public slots: void pulse(qreal seconds); void burst(int num); + void burst(int num, qreal x, qreal y); void setEmitting(bool arg); -- cgit v1.2.3 From 53bbcf5038a9ec5c5381e25968cb51b76cf4a2d6 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 10 Jun 2011 13:40:48 +0200 Subject: Disable vsync animations by default Change-Id: Ia614915ddb96f5c51e9883885479f1269ab361ed --- src/declarative/items/qsgcanvas.cpp | 72 ++++++++++++++++++++++++++++++------- src/declarative/items/qsgcanvas.h | 3 ++ src/declarative/items/qsgcanvas_p.h | 2 ++ 3 files changed, 64 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp index 3a88fbb790..950797a27e 100644 --- a/src/declarative/items/qsgcanvas.cpp +++ b/src/declarative/items/qsgcanvas.cpp @@ -174,7 +174,7 @@ void QSGCanvas::paintEvent(QPaintEvent *) int lastFrame = frameTimer.restart(); #endif - if (d->animationDriver->isRunning()) + if (d->animationDriver && d->animationDriver->isRunning()) d->animationDriver->advance(); #ifdef FRAME_TIMING @@ -222,7 +222,7 @@ void QSGCanvas::paintEvent(QPaintEvent *) QDeclarativeDebugTrace::endRange(QDeclarativeDebugTrace::Painting); - if (d->animationDriver->isRunning()) + if (d->animationDriver && d->animationDriver->isRunning()) update(); } else { if (isUpdatesEnabled()) { @@ -252,12 +252,14 @@ void QSGCanvas::showEvent(QShowEvent *e) if (!d->contextFailed) { if (d->threadedRendering) { - if (!d->animationDriver) { - d->animationDriver = d->context->createAnimationDriver(this); - connect(d->animationDriver, SIGNAL(started()), d->thread, SLOT(animationStarted()), Qt::DirectConnection); - connect(d->animationDriver, SIGNAL(stopped()), d->thread, SLOT(animationStopped()), Qt::DirectConnection); + if (d->vsyncAnimations) { + if (!d->animationDriver) { + d->animationDriver = d->context->createAnimationDriver(this); + connect(d->animationDriver, SIGNAL(started()), d->thread, SLOT(animationStarted()), Qt::DirectConnection); + connect(d->animationDriver, SIGNAL(stopped()), d->thread, SLOT(animationStopped()), Qt::DirectConnection); + } + d->animationDriver->install(); } - d->animationDriver->install(); d->thread->startRenderThread(); setUpdatesEnabled(true); } else { @@ -265,11 +267,14 @@ void QSGCanvas::showEvent(QShowEvent *e) if (!d->context || !d->context->isReady()) { d->initializeSceneGraph(); - d->animationDriver = d->context->createAnimationDriver(this); - connect(d->animationDriver, SIGNAL(started()), this, SLOT(update())); + if (d->vsyncAnimations) { + d->animationDriver = d->context->createAnimationDriver(this); + connect(d->animationDriver, SIGNAL(started()), this, SLOT(update())); + } } - d->animationDriver->install(); + if (d->animationDriver) + d->animationDriver->install(); } } } @@ -283,12 +288,52 @@ void QSGCanvas::hideEvent(QHideEvent *e) d->thread->stopRenderThread(); } - d->animationDriver->uninstall(); + if (d->animationDriver) + d->animationDriver->uninstall(); } QGLWidget::hideEvent(e); } + + +/*! + Sets weither this canvas should use vsync driven animations. + + This option can only be set on one single QSGCanvas, and that it's + vsync signal will then be used to drive all animations in the + process. + + This feature is primarily useful for single QSGCanvas, QML-only + applications. + + \warning Enabling vsync on multiple QSGCanvas instances has + undefined behavior. + */ +void QSGCanvas::setVSyncAnimations(bool enabled) +{ + Q_D(QSGCanvas); + if (isVisible()) { + qWarning("QSGCanvas::setVSyncAnimations: Cannot be changed when widget is shown"); + return; + } + d->vsyncAnimations = enabled; +} + + + +/*! + Returns true if this canvas should use vsync driven animations; + otherwise returns false. + */ +bool QSGCanvas::vsyncAnimations() const +{ + Q_D(const QSGCanvas); + return d->vsyncAnimations; +} + + + void QSGCanvas::focusOutEvent(QFocusEvent *event) { Q_D(QSGCanvas); @@ -384,6 +429,7 @@ QSGCanvasPrivate::QSGCanvasPrivate() , threadedRendering(false) , animationRunning(false) , renderThreadAwakened(false) + , vsyncAnimations(false) , thread(0) , animationDriver(0) { @@ -958,7 +1004,7 @@ bool QSGCanvas::event(QEvent *e) d->thread->syncAlreadyHappened = false; - if (d->animationRunning) { + if (d->animationRunning && d->animationDriver) { #ifdef THREAD_DEBUG qDebug("GUI: Advancing animations...\n"); #endif @@ -2053,7 +2099,7 @@ void QSGCanvasRenderThread::run() // but we don't want to lock an extra time. wake(); - if (!d->animationRunning && !isExternalUpdatePending) { + if (!d->animationRunning && !isExternalUpdatePending && !shouldExit) { #ifdef THREAD_DEBUG printf(" RenderThread: nothing to do, going to sleep...\n"); #endif diff --git a/src/declarative/items/qsgcanvas.h b/src/declarative/items/qsgcanvas.h index d0d0c79d5e..8913e41b86 100644 --- a/src/declarative/items/qsgcanvas.h +++ b/src/declarative/items/qsgcanvas.h @@ -75,6 +75,9 @@ public: QSGEngine *sceneGraphEngine() const; + void setVSyncAnimations(bool enabled); + bool vsyncAnimations() const; + QImage grabFrameBuffer(); Q_SIGNALS: diff --git a/src/declarative/items/qsgcanvas_p.h b/src/declarative/items/qsgcanvas_p.h index 9b2683cc38..7f7182ee52 100644 --- a/src/declarative/items/qsgcanvas_p.h +++ b/src/declarative/items/qsgcanvas_p.h @@ -160,6 +160,8 @@ public: uint animationRunning: 1; uint renderThreadAwakened : 1; + uint vsyncAnimations : 1; + QSGCanvasRenderThread *thread; QSize widgetSize; QSize viewportSize; -- cgit v1.2.3 From e05d75b690fab95259afae8f295df8e9df242115 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 8 Jun 2011 11:01:26 +0200 Subject: QDeclarativeDebug: Fix QJSDebugService if launched with ',block' If the debugger is launched in blocking mode the service will be enabled from the start. Reviewed-by: Thorbjorn Lindeijer (cherry picked from commit c038e3505309bb954123493cb5f96c73e114f3d0) --- src/declarative/debugger/qjsdebuggeragent.cpp | 13 ++++++++++++- src/declarative/debugger/qjsdebuggeragent_p.h | 2 ++ src/declarative/debugger/qjsdebugservice.cpp | 10 ++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/declarative/debugger/qjsdebuggeragent.cpp b/src/declarative/debugger/qjsdebuggeragent.cpp index 9b76592c48..dff637b7da 100644 --- a/src/declarative/debugger/qjsdebuggeragent.cpp +++ b/src/declarative/debugger/qjsdebuggeragent.cpp @@ -56,7 +56,7 @@ class QJSDebuggerAgentPrivate { public: QJSDebuggerAgentPrivate(QJSDebuggerAgent *q) - : q(q), state(NoState) + : q(q), state(NoState), isInitialized(false) {} void continueExec(); @@ -79,6 +79,7 @@ public: QHash fileNameToBreakpoints; QStringList watchExpressions; QSet knownObjectIds; + bool isInitialized; }; namespace { @@ -252,6 +253,14 @@ QJSDebuggerAgent::~QJSDebuggerAgent() delete d; } +/*! + Indicates whether the agent got the list of breakpoints. + */ +bool QJSDebuggerAgent::isInitialized() const +{ + return d->isInitialized; +} + void QJSDebuggerAgent::setBreakpoints(const JSAgentBreakpoints &breakpoints) { d->breakpoints = breakpoints; @@ -259,6 +268,8 @@ void QJSDebuggerAgent::setBreakpoints(const JSAgentBreakpoints &breakpoints) d->fileNameToBreakpoints.clear(); foreach (const JSAgentBreakpointData &bp, breakpoints) d->fileNameToBreakpoints.insertMulti(fileName(QString::fromUtf8(bp.fileUrl)), bp); + + d->isInitialized = true; } void QJSDebuggerAgent::setWatchExpressions(const QStringList &watchExpressions) diff --git a/src/declarative/debugger/qjsdebuggeragent_p.h b/src/declarative/debugger/qjsdebuggeragent_p.h index 5aa3c9ccbc..309588eb2f 100644 --- a/src/declarative/debugger/qjsdebuggeragent_p.h +++ b/src/declarative/debugger/qjsdebuggeragent_p.h @@ -145,6 +145,8 @@ public: QJSDebuggerAgent(QDeclarativeEngine *engine, QObject *parent = 0); ~QJSDebuggerAgent(); + bool isInitialized() const; + void setBreakpoints(const JSAgentBreakpoints &); void setWatchExpressions(const QStringList &); diff --git a/src/declarative/debugger/qjsdebugservice.cpp b/src/declarative/debugger/qjsdebugservice.cpp index 4ce2c906bc..ad84f656f7 100644 --- a/src/declarative/debugger/qjsdebugservice.cpp +++ b/src/declarative/debugger/qjsdebugservice.cpp @@ -71,6 +71,16 @@ void QJSDebugService::addEngine(QDeclarativeEngine *engine) Q_ASSERT(!m_engines.contains(engine)); m_engines.append(engine); + + if (status() == Enabled && !m_engines.isEmpty() && !m_agent) { + m_agent = new QJSDebuggerAgent(engine, engine); + connect(m_agent, SIGNAL(stopped(bool,QString)), + this, SLOT(executionStopped(bool,QString))); + + while (!m_agent->isInitialized()) { + waitForMessage(); + } + } } void QJSDebugService::removeEngine(QDeclarativeEngine *engine) -- cgit v1.2.3 From 434df838c11063dfea95b1d26d0576ea661d10ba Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 8 Jun 2011 20:51:07 +0200 Subject: QDeclarativeDebug: Don't hang if started with ',block' argument Fixes regression introduced in a59261454071 Reviewed-by: Christiaan Janssen (cherry picked from commit e3b5de8651586cf5484fd8ab217cddf17f0fe01e) --- src/declarative/debugger/qpacketprotocol.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/declarative/debugger/qpacketprotocol.cpp b/src/declarative/debugger/qpacketprotocol.cpp index a40a9ab8a6..9caaa79011 100644 --- a/src/declarative/debugger/qpacketprotocol.cpp +++ b/src/declarative/debugger/qpacketprotocol.cpp @@ -198,6 +198,8 @@ public Q_SLOTS: packets.append(inProgress); inProgressSize = -1; inProgress.clear(); + + waitingForPacket = false; emit readyRead(); } else return; -- cgit v1.2.3 From 7b22f02961a97c0fa07127ea3ff26b8435a617b8 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 14 Jun 2011 14:09:30 +1000 Subject: Safer cleanup in model/item particle --- src/declarative/particles/qsgitemparticle.cpp | 4 ++-- src/declarative/particles/qsgmodelparticle.cpp | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/declarative/particles/qsgitemparticle.cpp b/src/declarative/particles/qsgitemparticle.cpp index 498dd90a87..42f0062148 100644 --- a/src/declarative/particles/qsgitemparticle.cpp +++ b/src/declarative/particles/qsgitemparticle.cpp @@ -102,8 +102,8 @@ void QSGItemParticle::tick() mpa->detach();//reparent as well? //TODO: Delete iff we created it m_activeCount--; - m_deletables.removeAll(item); } + m_deletables.clear(); foreach(int pos, m_loadables){ if(m_stasis.contains(m_items[pos])) @@ -133,8 +133,8 @@ void QSGItemParticle::tick() m_items[pos]->setOpacity(0.); m_activeCount++; } - m_loadables.removeAll(pos); } + m_loadables.clear(); } void QSGItemParticle::reload(QSGParticleData* d) diff --git a/src/declarative/particles/qsgmodelparticle.cpp b/src/declarative/particles/qsgmodelparticle.cpp index b0b4fa4ad2..f87c0d31b9 100644 --- a/src/declarative/particles/qsgmodelparticle.cpp +++ b/src/declarative/particles/qsgmodelparticle.cpp @@ -177,21 +177,23 @@ void QSGModelParticle::processPending() foreach(QSGItem* item, m_deletables){ item->setOpacity(0.); m_model->release(item); - m_deletables.removeAll(item); } + m_deletables.clear(); foreach(int pos, m_requests){ - m_items[pos] = m_model->item(m_available.first()); - m_idx[pos] = m_available.first(); - m_available.pop_front(); - QSGModelParticleAttached* mpa = qobject_cast(qmlAttachedPropertiesObject(m_items[pos])); - if(mpa){ - mpa->m_mp = this; - mpa->attach(); + if(!m_available.isEmpty()){ + m_items[pos] = m_model->item(m_available.first()); + m_idx[pos] = m_available.first(); + m_available.pop_front(); + QSGModelParticleAttached* mpa = qobject_cast(qmlAttachedPropertiesObject(m_items[pos])); + if(mpa){ + mpa->m_mp = this; + mpa->attach(); + } + m_items[pos]->setParentItem(this); } - m_items[pos]->setParentItem(this); - m_requests.removeAll(pos); } + m_requests.clear(); } void QSGModelParticle::reload(QSGParticleData* d) -- cgit v1.2.3