Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSynchronizedConnectionBase Class Referenceabstract

A base class for KisSynchronizedConnection. More...

#include <KisSynchronizedConnection.h>

+ Inheritance diagram for KisSynchronizedConnectionBase:

Static Public Member Functions

static int eventType ()
 
static void forceDeliverAllSynchronizedEvents ()
 
static bool isAutoModeForUnittestsEnabled ()
 
static void registerSynchronizedEventBarrier (std::function< void()> callback)
 
static void setAutoModeForUnittestsEnabled (bool value)
 

Protected Member Functions

virtual void deliverEventToReceiver ()=0
 
bool event (QEvent *event) override
 
void postEvent ()
 

Detailed Description

A base class for KisSynchronizedConnection.

This class implements QEvent logic for KisSynchronizedConnection. Since KisSynchronizedConnection is templated, it should be implemented fully inline, but we don't want to expose our interactions with KisApplication. Therefore we implement this logic in a separate non-templated class that will be hidden in kritaglobal.

Definition at line 48 of file KisSynchronizedConnection.h.

Member Function Documentation

◆ deliverEventToReceiver()

◆ event()

bool KisSynchronizedConnectionBase::event ( QEvent * event)
overrideprotected

Definition at line 94 of file KisSynchronizedConnection.cpp.

95{
96 if (event->type() == s_instance->eventType) {
99
100 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(typedEvent->destination == this, false);
102 return true;
103 }
104
105 return QObject::event(event);
106}
virtual void deliverEventToReceiver()=0
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
Event type used for synchronizing connection in KisSynchronizedConnection.

References deliverEventToReceiver(), KisSynchronizedConnectionEvent::destination, event(), and KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE.

◆ eventType()

int KisSynchronizedConnectionBase::eventType ( )
static

Definition at line 60 of file KisSynchronizedConnection.cpp.

61{
62 return s_instance->eventType;
63}

◆ forceDeliverAllSynchronizedEvents()

void KisSynchronizedConnectionBase::forceDeliverAllSynchronizedEvents ( )
static

We need to first make sure that all the events are delivered to the applications object and then make sure they are processed whatever the state of the recursion is (this call is called from python filters only)

Definition at line 81 of file KisSynchronizedConnection.cpp.

82{
89 qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
90 KIS_SAFE_ASSERT_RECOVER_RETURN(s_barrier->callback);
91 s_barrier->callback();
92}
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128

References KIS_SAFE_ASSERT_RECOVER_RETURN.

◆ isAutoModeForUnittestsEnabled()

bool KisSynchronizedConnectionBase::isAutoModeForUnittestsEnabled ( )
static

Definition at line 76 of file KisSynchronizedConnection.cpp.

77{
78 return s_instance->enableAutoModeForUnittests;
79}

◆ postEvent()

void KisSynchronizedConnectionBase::postEvent ( )
protected

TODO: check if we need s_barrier at all now!

TODO: This assert triggers in unittests that don't have a fully-featured KisApplication object. Perhaps we should add a fake callback to KISTEST_MAIN KIS_SAFE_ASSERT_RECOVER_NOOP(s_barrier->callback);

Definition at line 108 of file KisSynchronizedConnection.cpp.

109{
110 if (s_instance->enableAutoModeForUnittests && QThread::currentThread() == this->thread()) {
112
116
117 if (s_barrier->callback) {
118 s_barrier->callback();
119 }
120
122 } else {
123 qApp->postEvent(this, new KisSynchronizedConnectionEvent(this));
124 }
125}

References deliverEventToReceiver().

◆ registerSynchronizedEventBarrier()

void KisSynchronizedConnectionBase::registerSynchronizedEventBarrier ( std::function< void()> callback)
static

Definition at line 65 of file KisSynchronizedConnection.cpp.

66{
67 KIS_SAFE_ASSERT_RECOVER_NOOP(!s_barrier->callback);
68 s_barrier->callback = callback;
69}
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References KIS_SAFE_ASSERT_RECOVER_NOOP.

◆ setAutoModeForUnittestsEnabled()

void KisSynchronizedConnectionBase::setAutoModeForUnittestsEnabled ( bool value)
static

In unittests the connection should work in 'Auto' mode, because most of the actions are executed in the GUI thread, and (usually) don't have an event loop at all

Default value: false

Definition at line 71 of file KisSynchronizedConnection.cpp.

72{
73 s_instance->enableAutoModeForUnittests = value;
74}
float value(const T *src, size_t ch)

References value().


The documentation for this class was generated from the following files: