Skip to content

Commit 5dc3058

Browse files
committed
Register/Unregister: ensure sink exists in the list or not before registering and unregistering
1 parent 5aa8fea commit 5dc3058

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Launcher.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,26 @@ class Launcher : public PluginHost::IPlugin {
169169

170170
public:
171171
void Register(IProcessState* observer) {
172+
ASSERT(observer != nullptr);
173+
172174
_adminLock.Lock();
173-
ASSERT (std::find(_callbacks.begin(), _callbacks.end(), observer) == _callbacks.end());
175+
auto found = std::find(_callbacks.begin(), _callbacks.end(), observer);
176+
ASSERT (found == _callbacks.end());
177+
174178
if (_callbacks.empty()) {
175179
const bool opened = Open();
176180
DEBUG_VARIABLE(opened);
177181
ASSERT(opened);
178182
}
179-
_callbacks.push_back(observer);
183+
if (found == _callbacks.end()) {
184+
_callbacks.push_back(observer);
185+
}
186+
180187
_adminLock.Unlock();
181188
}
182189
void Unregister(IProcessState* observer) {
190+
ASSERT(observer != nullptr);
191+
183192
_adminLock.Lock();
184193
auto found = std::find(_callbacks.begin(), _callbacks.end(), observer);
185194
ASSERT(found != _callbacks.end());

0 commit comments

Comments
 (0)