Commit 69475ba5 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - the GUI now offers a condition variable for isInitialized- flag

parent cffe6b28
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include "../common/WConditionOneShot.h"
#include "WGUI.h"
WGUI::WGUI( int argc, char** argv ): boost::enable_shared_from_this< WGUI >()
......@@ -36,11 +38,16 @@ WGUI::~WGUI()
{
}
bool WGUI::isInitalized()
bool WGUI::isInitialized() const
{
return m_isInitialized;
}
const WCondition& WGUI::waitInitialized() const
{
return m_isInitializedCondition;
}
void WGUI::slotAddDatasetToBrowser( boost::shared_ptr< WModule > module )
{
addDatasetToBrowser( module, 0 );
......
......@@ -31,6 +31,8 @@
#include <boost/shared_ptr.hpp>
#include "../common/WThreadedRunner.h"
#include "../common/WCondition.h"
#include "../common/WConditionOneShot.h"
#include "../kernel/WModule.h"
#include "qt4/signalslib.hpp"
......@@ -71,7 +73,14 @@ public:
*
* \return true if initialized.
*/
virtual bool isInitalized();
virtual bool isInitialized() const;
/**
* Gives other threads the possibility to wait for this condition to come true.
*
* \return Reference to the condition.
*/
virtual const WCondition& waitInitialized() const;
/**
* Runs the GUI. All initialization should be done here.
......@@ -114,6 +123,11 @@ protected:
*/
bool m_isInitialized;
/**
* Condition should be fired when "isInitialized" got true.
*/
WConditionOneShot m_isInitializedCondition;
/**
* Number of command line arguments given.
*/
......
......@@ -75,6 +75,7 @@ int WQt4Gui::run()
// now we are initialized
m_isInitialized = true;
m_isInitializedCondition.notify();
// run
// NOTE: kernel shutdown is implemented in WMainWindow
......
......@@ -36,6 +36,7 @@
#include "WModule.h"
#include "WModuleFactory.h"
#include "../common/WException.h"
#include "../common/WCondition.h"
#include "../graphicsEngine/WGraphicsEngine.h"
......@@ -126,10 +127,7 @@ void WKernel::threadMain()
WLogger::getLogger()->addLogMessage( "Starting Kernel", "Kernel", LL_DEBUG );
// wait for GUI to be initialized properly
// TODO(ebaum): this loop is ugly, will be replaced by some kind of one-shot condition
while ( !m_gui->isInitalized() )
{
}
m_gui->waitInitialized().wait();
// default modules
m_moduleContainer->add( m_moduleFactory->create( m_moduleFactory->getPrototypeByName( "Navigation Slice Module" ) ) , true );
......
......@@ -142,7 +142,7 @@ void WMCoordinateSystem::updateGeometry()
boost::shared_lock< boost::shared_mutex > slock;
slock = boost::shared_lock< boost::shared_mutex >( m_updateLock );
// *******************************************************************************************************
if ( !m_properties->getValue< bool > ( "textureChanged" ) || !WKernel::getRunningKernel()->getGui()->isInitalized() )
if ( !m_properties->getValue< bool > ( "textureChanged" ) || !WKernel::getRunningKernel()->getGui()->isInitialized() )
{
return;
}
......
......@@ -294,7 +294,7 @@ void WMNavSlices::updateTextures()
boost::shared_lock<boost::shared_mutex> slock;
slock = boost::shared_lock<boost::shared_mutex>( m_updateLock );
if ( m_properties->getValue< bool >( "textureChanged" ) && WKernel::getRunningKernel()->getGui()->isInitalized() )
if ( m_properties->getValue< bool >( "textureChanged" ) && WKernel::getRunningKernel()->getGui()->isInitialized() )
{
m_properties->setValue( "textureChanged", false );
std::vector< boost::shared_ptr< WModule > > datasetList = WKernel::getRunningKernel()->getGui()->getDataSetList( 0 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment