File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 3
3
4
4
#include < QWidget>
5
5
#include < QThread>
6
+ #include < QSemaphore>
7
+ #include < QSemaphoreReleaser>
6
8
#include < QtConcurrent/QtConcurrent>
7
9
#include " bitcontainerpreview.h"
8
10
#include " pluginactionprogress.h"
@@ -14,6 +16,8 @@ class HOBBITSWIDGETSSHARED_EXPORT AbstractParameterEditor : public QWidget
14
16
Q_OBJECT
15
17
16
18
public:
19
+ AbstractParameterEditor () : m_previewSem(2 ) {}
20
+
17
21
virtual QString title () = 0;
18
22
19
23
virtual bool setParameters (QJsonObject parameters) = 0;
@@ -26,7 +30,11 @@ class HOBBITSWIDGETSSHARED_EXPORT AbstractParameterEditor : public QWidget
26
30
void previewBits (QSharedPointer<BitContainerPreview> container,
27
31
QSharedPointer<PluginActionProgress> progress)
28
32
{
29
- QMutexLocker (&this ->m_previewLock );
33
+ if (!this ->m_previewSem .tryAcquire ()) {
34
+ return ;
35
+ }
36
+ QSemaphoreReleaser releaser (&this ->m_previewSem );
37
+ QMutexLocker locker (&this ->m_previewLock );
30
38
if (QThread::currentThread () == this ->thread ()) {
31
39
// Called from UI thread
32
40
previewBitsImpl (container, progress);
@@ -76,6 +84,7 @@ protected slots:
76
84
77
85
private:
78
86
QMutex m_previewLock;
87
+ QSemaphore m_previewSem;
79
88
};
80
89
81
90
#endif // ABSTRACTPARAMETEREDITOR_H
You can’t perform that action at this time.
0 commit comments