Use QEvent::registerEventType for custom event types
This commit is contained in:
parent
0ea27ae051
commit
632626b192
1 changed files with 6 additions and 4 deletions
|
|
@ -18,8 +18,10 @@
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kProcessorEvent = QEvent::Type(QEvent::User + 1);
|
auto ProcessorEventType() {
|
||||||
static_assert(kProcessorEvent < QEvent::MaxUser);
|
static const auto Result = QEvent::Type(QEvent::registerEventType());
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
QMutex ProcessorMutex;
|
QMutex ProcessorMutex;
|
||||||
MainQueueProcessor *ProcessorInstance/* = nullptr*/;
|
MainQueueProcessor *ProcessorInstance/* = nullptr*/;
|
||||||
|
|
@ -47,7 +49,7 @@ void PushToMainQueueGeneric(void (*callable)(void*), void *argument) {
|
||||||
MainQueueProcessState.store(ProcessState::Waiting);
|
MainQueueProcessState.store(ProcessState::Waiting);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto event = std::make_unique<QEvent>(kProcessorEvent);
|
auto event = std::make_unique<QEvent>(ProcessorEventType());
|
||||||
|
|
||||||
QMutexLocker lock(&ProcessorMutex);
|
QMutexLocker lock(&ProcessorMutex);
|
||||||
if (ProcessorInstance) {
|
if (ProcessorInstance) {
|
||||||
|
|
@ -94,7 +96,7 @@ MainQueueProcessor::MainQueueProcessor() {
|
||||||
|
|
||||||
bool MainQueueProcessor::event(QEvent *event) {
|
bool MainQueueProcessor::event(QEvent *event) {
|
||||||
if constexpr (Platform::UseMainQueueGeneric()) {
|
if constexpr (Platform::UseMainQueueGeneric()) {
|
||||||
if (event->type() == kProcessorEvent) {
|
if (event->type() == ProcessorEventType()) {
|
||||||
DrainMainQueueGeneric();
|
DrainMainQueueGeneric();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue