mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Undo "Revert "do not use QThread::create""
This reverts commit 4b86849356.
This commit is contained in:
parent
acd2e2863a
commit
2f77d99161
|
|
@ -1569,7 +1569,7 @@ void SwitcherData::Start()
|
|||
{
|
||||
if (!(th && th->isRunning())) {
|
||||
stop = false;
|
||||
switcher->th = QThread::create([]() { switcher->Thread(); });
|
||||
switcher->th = new SwitcherThread();
|
||||
switcher->th->start((QThread::Priority)switcher->threadPriority);
|
||||
}
|
||||
}
|
||||
|
|
@ -1582,6 +1582,8 @@ void SwitcherData::Stop()
|
|||
transitionCv.notify_one();
|
||||
cv.notify_one();
|
||||
th->wait();
|
||||
delete th;
|
||||
th = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -253,11 +253,14 @@ struct TimeSwitch {
|
|||
|
||||
typedef enum { NO_SWITCH = 0, SWITCH = 1, RANDOM_SWITCH = 2 } NoMatch;
|
||||
|
||||
class SwitcherThread;
|
||||
|
||||
/********************************************************************************
|
||||
* SwitcherData
|
||||
********************************************************************************/
|
||||
struct SwitcherData {
|
||||
QThread* th = nullptr;
|
||||
SwitcherThread *th;
|
||||
|
||||
condition_variable cv;
|
||||
mutex m;
|
||||
bool transitionActive = false;
|
||||
|
|
@ -482,3 +485,10 @@ struct SwitcherData {
|
|||
}
|
||||
inline ~SwitcherData() { Stop(); }
|
||||
};
|
||||
|
||||
extern SwitcherData *switcher;
|
||||
class SwitcherThread : public QThread {
|
||||
public:
|
||||
explicit SwitcherThread(){};
|
||||
void run() { switcher->Thread(); };
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user