# HG changeset patch # User Sebastien Jodogne # Date 1448457866 -3600 # Node ID f0f8a94c0858edeb93bb88792dd28f494b1e2cf6 # Parent b530c3dfe2a6b97828b4b4e13f212f7f40fe4123 only one modality worklist handler at once diff -r b530c3dfe2a6 -r f0f8a94c0858 Plugins/Engine/OrthancPlugins.cpp --- a/Plugins/Engine/OrthancPlugins.cpp Wed Nov 25 14:14:32 2015 +0100 +++ b/Plugins/Engine/OrthancPlugins.cpp Wed Nov 25 14:24:26 2015 +0100 @@ -278,7 +278,6 @@ typedef std::list RestCallbacks; typedef std::list OnStoredCallbacks; typedef std::list OnChangeCallbacks; - typedef std::list WorklistCallbacks; typedef std::map Properties; PluginsManager manager_; @@ -286,12 +285,12 @@ RestCallbacks restCallbacks_; OnStoredCallbacks onStoredCallbacks_; OnChangeCallbacks onChangeCallbacks_; - WorklistCallbacks worklistCallbacks_; + OrthancPluginWorklistCallback worklistCallback_; std::auto_ptr storageArea_; boost::recursive_mutex restCallbackMutex_; boost::recursive_mutex storedCallbackMutex_; boost::recursive_mutex changeCallbackMutex_; - boost::recursive_mutex worklistCallbackMutex_; + boost::mutex worklistCallbackMutex_; boost::recursive_mutex invokeServiceMutex_; Properties properties_; int argc_; @@ -301,6 +300,7 @@ PImpl() : context_(NULL), + worklistCallback_(NULL), argc_(1), argv_(NULL) { @@ -339,13 +339,11 @@ currentQuery_ = &query; { - boost::recursive_mutex::scoped_lock lock(that_.pimpl_->worklistCallbackMutex_); + boost::mutex::scoped_lock lock(that_.pimpl_->worklistCallbackMutex_); - for (PImpl::WorklistCallbacks::const_iterator - callback = that_.pimpl_->worklistCallbacks_.begin(); - callback != that_.pimpl_->worklistCallbacks_.end(); ++callback) + if (that_.pimpl_->worklistCallback_) { - OrthancPluginErrorCode error = (*callback) + OrthancPluginErrorCode error = that_.pimpl_->worklistCallback_ (reinterpret_cast(&answers), reinterpret_cast(this), remoteAet.c_str(), @@ -718,8 +716,18 @@ const _OrthancPluginWorklistCallback& p = *reinterpret_cast(parameters); - LOG(INFO) << "Plugin has registered an modality worklist callback"; - pimpl_->worklistCallbacks_.push_back(p.callback); + boost::mutex::scoped_lock lock(pimpl_->worklistCallbackMutex_); + + if (pimpl_->worklistCallback_ != NULL) + { + LOG(ERROR) << "Can only register one plugin to handle modality worklists"; + throw OrthancException(ErrorCode_Plugin); + } + else + { + LOG(INFO) << "Plugin has registered an modality worklist callback"; + pimpl_->worklistCallback_ = p.callback; + } } @@ -2137,8 +2145,8 @@ bool OrthancPlugins::HasWorklistHandler() { - boost::recursive_mutex::scoped_lock lock(pimpl_->worklistCallbackMutex_); - return !pimpl_->worklistCallbacks_.empty(); + boost::mutex::scoped_lock lock(pimpl_->worklistCallbackMutex_); + return pimpl_->worklistCallback_ != NULL; } }