Workspace 6.21.5
Static Public Member Functions | List of all members
StillExecutingChecker Class Reference

Checks that an Updatable object's execution thread is stopped. More...

#include <Workspace/Presentation/stillexecutingchecker.h>

Static Public Member Functions

static bool canAllowTask (DataExecution::Updatable &updatable, bool promptAndStop=true)
 
static ExecutionActiondisableActionWhileExecuting (DataExecution::Updatable &updatable, QAction &action)
 
static bool isRunning (DataExecution::Updatable &updatable)
 

Detailed Description

A number of tasks require that a workspace not be executing to be safe. Examples include adding or removing an operation, connection or an element of an input array, or even changing the data type of a polymorphic operation. This class provides a convenient way to check that an object's execution thread is not running and to warn the user if it is, providing them with the opportunity to halt execution and continue or to cancel the requested action.

Member Function Documentation

◆ canAllowTask()

bool canAllowTask ( DataExecution::Updatable updatable,
bool  promptAndStop = true 
)
static
Parameters
updatableThe object whose execution thread is to be checked.
promptAndStopAsk the user and stop if executing, otherwise do a silent 'pause' execution that the caller is responsible for restarting. See saveWorkspace()
Returns
True if the execution thread for updatable is not running when the function returns (it does not imply that the execution thread was not running when it was first called).

If the execution thread is still running when this function is called, it will show a dialog informing the user it needs to be halted. The user can then cancel the requested task, in which case the function returns false, or they can let the checker ask for execution to be stopped. After waiting for a few seconds, if the execution thread is still running the checker will ask the user again. This process continues until either the execution thread halts or the user decides to cancel the task they were about to do.

See also
isRunning()

◆ disableActionWhileExecuting()

ExecutionAction * disableActionWhileExecuting ( DataExecution::Updatable updatable,
QAction &  action 
)
static
Parameters
updatableThe object whose execution thread should control whether the specified action should be allowed. If there is no execution thread associated with updatable, this function has no effect.
actionThis action will be disabled while the execution thread for updatable is running.
Returns
This function adds a new action as a child of action and returns that child. The child action will monitor the execution thread and will enable or disable action as appropriate. It will also ensure that action the correct enabled/disabled state before returning. If updatable has no execution thread, a null pointer will be returned.

◆ isRunning()

bool isRunning ( DataExecution::Updatable updatable)
static
Parameters
updatableThe object whose execution thread is to be checked.
Returns
True if the execution thread for updatable is running.

This function differs from canAllowTask() in that it merely checks the current execution state without offering the user any means to stop it if it is running.

See also
canAllowTask()