Mercurial > hg > orthanc-stone
diff Applications/Generic/NativeStoneApplicationContext.cpp @ 385:6cc3ce74dc05
using message broker in widgets
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 07 Nov 2018 20:49:41 +0100 |
parents | 8eb4fe74000f |
children | e33659decec5 |
line wrap: on
line diff
--- a/Applications/Generic/NativeStoneApplicationContext.cpp Wed Nov 07 16:17:02 2018 +0100 +++ b/Applications/Generic/NativeStoneApplicationContext.cpp Wed Nov 07 20:49:41 2018 +0100 @@ -24,9 +24,9 @@ namespace OrthancStone { - IWidget& NativeStoneApplicationContext::SetCentralWidget(IWidget* widget) // Takes ownership + IWidget& NativeStoneApplicationContext::GlobalMutexLocker::SetCentralWidget(IWidget* widget) { - centralViewport_->SetCentralWidget(widget); + that_.centralViewport_.SetCentralWidget(widget); return *widget; } @@ -37,7 +37,7 @@ { { GlobalMutexLocker locker(*that); - that->GetCentralViewport().UpdateContent(); + locker.GetCentralViewport().UpdateContent(); } boost::this_thread::sleep(boost::posix_time::milliseconds(that->updateDelayInMs_)); @@ -45,8 +45,9 @@ } - NativeStoneApplicationContext::NativeStoneApplicationContext() : - centralViewport_(new OrthancStone::WidgetViewport()), + NativeStoneApplicationContext::NativeStoneApplicationContext(MessageBroker& broker) : + broker_(broker), + centralViewport_(broker), stopped_(true), updateDelayInMs_(100) // By default, 100ms between each refresh of the content { @@ -56,7 +57,10 @@ void NativeStoneApplicationContext::Start() { - if (centralViewport_->HasUpdateContent()) + boost::mutex::scoped_lock lock(globalMutex_); + + if (stopped_ && + centralViewport_.HasUpdateContent()) { stopped_ = false; updateThread_ = boost::thread(UpdateThread, this);