Commit 3b5e183cabab69c667db1730665d1c94f2a9f5b8

Authored by Scott
1 parent d36f82be

Move cache limit from destuctor to write

openbr/plugins/gallery/lmdb.cpp
@@ -17,6 +17,8 @@ class lmdbGallery : public Gallery @@ -17,6 +17,8 @@ class lmdbGallery : public Gallery
17 Q_OBJECT 17 Q_OBJECT
18 Q_PROPERTY(bool remap READ get_remap WRITE set_remap RESET reset_remap STORED false) 18 Q_PROPERTY(bool remap READ get_remap WRITE set_remap RESET reset_remap STORED false)
19 BR_PROPERTY(bool, remap, true) 19 BR_PROPERTY(bool, remap, true)
  20 + Q_PROPERTY(int cacheLimit READ get_cacheLimit WRITE set_cacheLimit RESET reset_cacheLimit STORED false)
  21 + BR_PROPERTY(int, cacheLimit, 10000)
20 22
21 TemplateList readBlock(bool *done) 23 TemplateList readBlock(bool *done)
22 { 24 {
@@ -169,6 +171,9 @@ class lmdbGallery : public Gallery @@ -169,6 +171,9 @@ class lmdbGallery : public Gallery
169 QMutexLocker lock(&dataLock); 171 QMutexLocker lock(&dataLock);
170 data.append(t); 172 data.append(t);
171 dataWait.wakeAll(); 173 dataWait.wakeAll();
  174 +
  175 + if (cacheLimit != -1 && data.size() > cacheLimit)
  176 + QThread::msleep(1);
172 } 177 }
173 178
174 ~lmdbGallery() 179 ~lmdbGallery()