Commit bd7b239a authored by ledig's avatar ledig
Browse files

[FIX] Fixed Thread crashes with WPropertyManager and removed scoped_lock.unlock

parent 183a4ff0
......@@ -129,7 +129,7 @@ boost::shared_ptr<WGEViewer> WGraphicsEngine::createViewer( std::string name, os
// store it in viewer list
boost::mutex::scoped_lock lock( m_viewersLock );
assert( m_viewers.insert( make_pair( name, viewer ) ).second == true );
m_viewersLock.unlock();
//m_viewersLock.unlock();
return viewer;
}
......@@ -143,7 +143,7 @@ void WGraphicsEngine::closeViewer( const std::string name )
m_viewers.erase( name );
}
m_viewersLock.unlock();
//m_viewersLock.unlock();
}
boost::shared_ptr< WGEViewer > WGraphicsEngine::getViewerByName( std::string name )
......@@ -152,7 +152,7 @@ boost::shared_ptr< WGEViewer > WGraphicsEngine::getViewerByName( std::string nam
boost::shared_ptr< WGEViewer > out = m_viewers.count( name ) > 0 ?
m_viewers[name] :
boost::shared_ptr< WGEViewer >();
m_viewersLock.unlock();
//m_viewersLock.unlock();
return out;
}
......
......@@ -300,7 +300,7 @@ void WMainWindow::closeEvent( QCloseEvent* e )
{
it->second->close();
}
m_customDockWidgetsLock.unlock();
//m_customDockWidgetsLock.unlock();
// finally close
e->accept();
......@@ -337,7 +337,7 @@ void WMainWindow::customEvent( QEvent* event )
widget = m_customDockWidgets[title];
widget->increaseUseCount();
}
m_customDockWidgetsLock.unlock();
//m_customDockWidgetsLock.unlock();
ocdwEvent->getFlag()->set( widget );
}
......@@ -354,7 +354,7 @@ boost::shared_ptr< WQtCustomDockWidget > WMainWindow::getCustomDockWidget( std::
boost::shared_ptr< WQtCustomDockWidget > out = m_customDockWidgets.count( title ) > 0 ?
m_customDockWidgets[title] :
boost::shared_ptr< WQtCustomDockWidget >();
m_customDockWidgetsLock.unlock();
//m_customDockWidgetsLock.unlock();
return out;
}
......@@ -370,7 +370,7 @@ void WMainWindow::closeCustomDockWidget( std::string title )
m_customDockWidgets.erase( title );
}
}
m_customDockWidgetsLock.unlock();
//m_customDockWidgetsLock.unlock();
}
void WMainWindow::slotActivateModule( QString module )
......
......@@ -25,6 +25,8 @@
#include <iostream>
#include <string>
#include <boost/thread/locks.hpp>
#include "WPropertyManager.h"
WPropertyManager::WPropertyManager()
......@@ -37,11 +39,16 @@ WPropertyManager::~WPropertyManager()
void WPropertyManager::connectProperties( boost::shared_ptr< WProperties > properties )
{
// make sure only one property gets connected at a time
boost::mutex::scoped_lock lock( m_PropertiesLock );
m_connectedProperties.push_back( properties );
}
void WPropertyManager::slotBoolChanged( QString name, bool value )
{
boost::mutex::scoped_lock lock( m_PropertiesLock );
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
m_connectedProperties[i]->setValue( name.toStdString(), value );
......@@ -50,6 +57,8 @@ void WPropertyManager::slotBoolChanged( QString name, bool value )
void WPropertyManager::slotIntChanged( QString name, int value )
{
boost::mutex::scoped_lock lock( m_PropertiesLock );
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
m_connectedProperties[i]->setValue( name.toStdString(), value );
......@@ -58,6 +67,8 @@ void WPropertyManager::slotIntChanged( QString name, int value )
void WPropertyManager::slotFloatChanged( QString name, float value )
{
boost::mutex::scoped_lock lock( m_PropertiesLock );
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
m_connectedProperties[i]->setValue( name.toStdString(), value );
......@@ -66,6 +77,8 @@ void WPropertyManager::slotFloatChanged( QString name, float value )
void WPropertyManager::slotStringChanged( QString name, QString value )
{
boost::mutex::scoped_lock lock( m_PropertiesLock );
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
m_connectedProperties[i]->setValue( name.toStdString(), value.toStdString() );
......
......@@ -28,6 +28,8 @@
#include <string>
#include <vector>
#include <boost/thread/mutex.hpp>
#include <QtCore/QObject>
#include "../../common/WProperties.h"
......@@ -97,6 +99,10 @@ public slots:
protected:
private:
/**
* Mutex used to lock the properties.
*/
boost::mutex m_PropertiesLock;
/**
* List of all properties actually connected with this manager instance.
......
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