mirror of
https://github.com/overte-org/overte.git
synced 2025-08-14 15:10:18 +02:00
Made overlays thread safe for write operations, which solved a script
crash.
This commit is contained in:
parent
5eeef647cf
commit
3a45104793
2 changed files with 4 additions and 3 deletions
|
@ -96,7 +96,6 @@ void Overlays::render3D() {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: make multi-threaded safe
|
||||
unsigned int Overlays::addOverlay(const QString& type, const QScriptValue& properties) {
|
||||
unsigned int thisID = 0;
|
||||
bool created = false;
|
||||
|
@ -140,6 +139,7 @@ unsigned int Overlays::addOverlay(const QString& type, const QScriptValue& prope
|
|||
}
|
||||
|
||||
if (created) {
|
||||
QWriteLocker lock(&_lock);
|
||||
thisID = _nextOverlayID;
|
||||
_nextOverlayID++;
|
||||
if (is3D) {
|
||||
|
@ -152,9 +152,9 @@ unsigned int Overlays::addOverlay(const QString& type, const QScriptValue& prope
|
|||
return thisID;
|
||||
}
|
||||
|
||||
// TODO: make multi-threaded safe
|
||||
bool Overlays::editOverlay(unsigned int id, const QScriptValue& properties) {
|
||||
Overlay* thisOverlay = NULL;
|
||||
QWriteLocker lock(&_lock);
|
||||
if (_overlays2D.contains(id)) {
|
||||
thisOverlay = _overlays2D[id];
|
||||
} else if (_overlays3D.contains(id)) {
|
||||
|
@ -167,9 +167,9 @@ bool Overlays::editOverlay(unsigned int id, const QScriptValue& properties) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// TODO: make multi-threaded safe
|
||||
void Overlays::deleteOverlay(unsigned int id) {
|
||||
Overlay* overlayToDelete;
|
||||
QWriteLocker lock(&_lock);
|
||||
if (_overlays2D.contains(id)) {
|
||||
overlayToDelete = _overlays2D.take(id);
|
||||
} else if (_overlays3D.contains(id)) {
|
||||
|
|
|
@ -45,6 +45,7 @@ private:
|
|||
QList<Overlay*> _overlaysToDelete;
|
||||
unsigned int _nextOverlayID;
|
||||
QGLWidget* _parent;
|
||||
QReadWriteLock _lock;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue