Allow SelectionSubscriber to start/stop outside initialisation phase
This commit is contained in:
@@ -69,12 +69,19 @@ bool SelectionSubscriber::receive(const Event& event) {
|
||||
return: True if the participant is able to continue
|
||||
--------------------------------------------------------------------*/
|
||||
bool SelectionSubscriber::start() {
|
||||
if (m_isStarted)
|
||||
return true;
|
||||
m_isStarted = true;
|
||||
#ifdef ARCHICAD
|
||||
return (ACAPI_Notification_CatchSelectionChange(selectionCallback) == NoError);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
} //SelectionSubscriber::start
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Stop participation (release resources etc)
|
||||
--------------------------------------------------------------------*/
|
||||
void SelectionSubscriber::stop() {
|
||||
#ifdef ARCHICAD
|
||||
ACAPI_Notification_CatchSelectionChange(nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace speckle::event {
|
||||
Get the event subscription list
|
||||
@return The subscription list (an empty list will put the subscriber into a suspended state)
|
||||
*/
|
||||
virtual Subscription subscription() const override;
|
||||
Subscription subscription() const override;
|
||||
|
||||
// MARK: - Functions (mutating)
|
||||
|
||||
@@ -44,24 +44,24 @@ namespace speckle::event {
|
||||
@param event The incoming event
|
||||
@return True if the event should be closed
|
||||
*/
|
||||
virtual bool receive(const active::event::Event& event) override;
|
||||
bool receive(const active::event::Event& event) override;
|
||||
|
||||
protected:
|
||||
/*!
|
||||
Start the participant operation
|
||||
@return True if the participant is able to continue
|
||||
*/
|
||||
virtual bool start() override;
|
||||
bool start() override;
|
||||
/*!
|
||||
Stop participation (release resources etc)
|
||||
*/
|
||||
void stop() override;
|
||||
/*!
|
||||
Handle a selection change
|
||||
@param event The selection event
|
||||
@return True if the event should be closed
|
||||
*/
|
||||
virtual bool handle(const SelectionEvent& event) = 0;
|
||||
|
||||
private:
|
||||
///True if a selection change subscriber has already started (only one is required - there are no variants)
|
||||
static bool m_isStarted;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user