SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
Add logic to new servers to ensure that operation and resource observers are called on the main thread. More...
#include <pqSMTKCallObserversOnMainThreadBehavior.h>
Signals | |
void | resourceEvent (QString resourceId, int event, QPrivateSignal) |
Signal that a resource rsrc has been added or removed from the manager. | |
void | operationEvent (QString opId, int event, QString resultName, QPrivateSignal) |
Signal that an operator op has been created, is about to run, or has run with the included result. | |
void | selectionEvent (QString selectionId, QString str, QPrivateSignal) |
Signal that a selection has been made. | |
Static Public Member Functions | |
static pqSMTKCallObserversOnMainThreadBehavior * | instance (QObject *parent=nullptr) |
Protected Slots | |
void | forceObserversToBeCalledOnMainThread (pqSMTKWrapper *rsrcMgr, pqServer *server) |
Mutate the logic of the server's operation and resource Observers to be called on the main thread, rather than the thread from which the observation was requested. | |
Protected Member Functions | |
pqSMTKCallObserversOnMainThreadBehavior (QObject *parent=nullptr) | |
Add logic to new servers to ensure that operation and resource observers are called on the main thread.
Qt requires that all methods that affect the GUI be performed on the application's main thread. Many of the registered Observer functions for both operations and resources are designed to affect the GUI. Rather than connect GUI-modifying logic to a signal triggered by an observer, we mutate the behavior of the operation and resource Observer calling logic to ensure that all Observer functors are called on the main thread, regardless of which thread performs the observation.
The logic that allows us to ensure that observations are called on the main thread uses Qt's signals and slots to relay the observation request between threads. Because SMTK's Operation and Resource classes are not wrapped for Qt's signal/slot relay, we instead hold a map of calling Operations and Resources and pass an associated unique id between threads.