diff data/model/Model.cpp @ 1500:9d37c8cf9686 avoid-pointer-keys

Provide model id
author Chris Cannam
date Mon, 13 Aug 2018 16:45:29 +0100
parents 48e9f538e6e9
children d3814e07b8aa
line wrap: on
line diff
--- a/data/model/Model.cpp	Mon Aug 13 15:37:41 2018 +0100
+++ b/data/model/Model.cpp	Mon Aug 13 16:45:29 2018 +0100
@@ -40,6 +40,20 @@
     }
 }
 
+int
+Model::getNextId()
+{
+    static int nextId = 0;
+    static QMutex mutex;
+    QMutexLocker locker(&mutex);
+    int i = nextId;
+    if (nextId == INT_MAX) {
+        nextId = INT_MIN;
+    }
+    ++nextId;
+    return i;
+}
+
 void
 Model::setSourceModel(Model *model)
 {