Skip to content

Commit 71443b1

Browse files
committed
Lock render method with mutex. Usefull e.g. for globe plugin which renders in threads
1 parent 8e5cd40 commit 71443b1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/core/qgsmaprenderer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#include <QDomDocument>
3535
#include <QDomNode>
36+
#include <QMutexLocker>
3637
#include <QPainter>
3738
#include <QListIterator>
3839
#include <QSettings>
@@ -214,6 +215,9 @@ void QgsMapRenderer::adjustExtentToSize()
214215

215216
void QgsMapRenderer::render( QPainter* painter )
216217
{
218+
//Lock render method for concurrent threads (e.g. from globe)
219+
QMutexLocker renderLock( &mRenderMutex );
220+
217221
//flag to see if the render context has changed
218222
//since the last time we rendered. If it hasnt changed we can
219223
//take some shortcuts with rendering

src/core/qgsmaprenderer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#ifndef QGSMAPRENDER_H
1717
#define QGSMAPRENDER_H
1818

19+
#include <QMutex>
1920
#include <QSize>
2021
#include <QStringList>
2122
#include <QVector>
@@ -318,6 +319,9 @@ class CORE_EXPORT QgsMapRenderer : public QObject
318319

319320
//! Labeling engine (NULL by default)
320321
QgsLabelingEngineInterface* mLabelingEngine;
322+
323+
//! Locks rendering loop for concurrent draws
324+
QMutex mRenderMutex;
321325
};
322326

323327
#endif

0 commit comments

Comments
 (0)