Skip to content

Commit

Permalink
Stop the render thread before deleting the QSGCanvas.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gunnar Sletta committed May 11, 2011
1 parent ad5aeed commit 97e553d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/declarative/items/qsgcanvas.cpp
Expand Up @@ -106,6 +106,19 @@ QSGRootItem::QSGRootItem()
{
}

void QSGCanvasPrivate::stopRenderingThread()
{
if (thread->isRunning()) {
mutex.lock();
exitThread = true;
wait.wakeOne();
wait.wait(&mutex);
exitThread = false;
mutex.unlock();
thread->wait();
}
}

void QSGCanvasPrivate::_q_animationStarted()
{
#ifdef THREAD_DEBUG
Expand Down Expand Up @@ -239,15 +252,8 @@ void QSGCanvas::hideEvent(QHideEvent *e)
{
Q_D(QSGCanvas);

if (d->threadedRendering) {
d->mutex.lock();
d->exitThread = true;
d->wait.wakeOne();
d->wait.wait(&d->mutex);
d->exitThread = false;
d->mutex.unlock();
d->thread->wait();
}
if (d->threadedRendering)
d->stopRenderingThread();

d->animationDriver->uninstall();

Expand Down Expand Up @@ -916,6 +922,9 @@ QSGCanvas::~QSGCanvas()
{
Q_D(QSGCanvas);

if (d->threadedRendering)
d->stopRenderingThread();

// ### should we change ~QSGItem to handle this better?
// manually cleanup for the root item (item destructor only handles these when an item is parented)
QSGItemPrivate *rootItemPrivate = QSGItemPrivate::get(d->rootItem);
Expand Down
2 changes: 2 additions & 0 deletions src/declarative/items/qsgcanvas_p.h
Expand Up @@ -115,6 +115,8 @@ class QSGCanvasPrivate : public QGLWidgetPrivate
void sendHoverEvent(QEvent::Type, QSGItem *, QGraphicsSceneHoverEvent *);
void clearHover();

void stopRenderingThread();

QDeclarativeGuard<QSGItem> hoverItem;
enum FocusOption {
DontChangeFocusProperty = 0x01,
Expand Down

0 comments on commit 97e553d

Please sign in to comment.