callData->args[0] = QV4::Primitive::fromUInt32(s);
f->call(callData);
if (scope.hasException()) {
- ctx->catchException();
QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
- QQmlEnginePrivate::warning(QQmlEnginePrivate::get(v8->engine()), error);
+ QQmlEnginePrivate::warning(QQmlEnginePrivate::get(d()->v8->engine()), error);
}
}
}
QOffscreenSurface *surface;
};
+class QQuickContext2DTextureCleanup : public QRunnable
+{
+public:
+ QQuickContext2DTexture *texture;
+ void run() Q_DECL_OVERRIDE { delete texture; }
+};
+
+ QMutex QQuickContext2D::mutex;
+
QQuickContext2D::QQuickContext2D(QObject *parent)
: QQuickCanvasContext(parent)
, m_buffer(new QQuickContext2DCommandBuffer)
cleaner->moveToThread(m_texture->thread());
cleaner->deleteLater();
} else {
- m_texture->deleteLater();
+ if (m_canvas->window()) {
+ QQuickContext2DTextureCleanup *c = new QQuickContext2DTextureCleanup;
+ c->texture = m_texture;
+ m_canvas->window()->scheduleRenderJob(c, QQuickWindow::AfterSynchronizingStage);
+ } else {
- delete m_texture;
++ m_texture->deleteLater();
+ }
}
} else {
// Image based does not have GL resources, but must still be deleted
void QQuickContext2DFBOTexture::grabImage(const QRectF& rf)
{
Q_ASSERT(rf.isValid());
- if (!m_fbo) {
- m_context->setGrabbedImage(QImage());
- return;
- }
-
- QImage grabbed;
- {
- GLAcquireContext ctx(m_context->glContext(), m_context->surface());
- grabbed = m_fbo->toImage().scaled(m_fboSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).mirrored().copy(rf.toRect());
+ QQuickContext2D::mutex.lock();
+ if (m_context) {
+ if (!m_fbo) {
+ m_context->setGrabbedImage(QImage());
+ } else {
+ QImage grabbed;
+ GLAcquireContext ctx(m_gl, m_surface);
- grabbed = m_fbo->toImage().mirrored().copy(rf.toRect());
++ grabbed = m_fbo->toImage().scaled(m_fboSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).mirrored().copy(rf.toRect());
+ m_context->setGrabbedImage(grabbed);
+ }
}
-
- m_context->setGrabbedImage(grabbed);
+ QQuickContext2D::mutex.unlock();
}
void QQuickContext2DFBOTexture::compositeTile(QQuickContext2DTile* tile)