Commit 0d2db543 authored by Christian Heine's avatar Christian Heine
Browse files

[FIX] closing of dock widgets does no longer dispose GL widget

parent 2e2376d9
......@@ -141,7 +141,6 @@ void WMainWindow::setupGUI()
setMenuBar( m_menuBar );
m_mainGLWidget = boost::shared_ptr< WQtGLWidget >( new WQtGLWidget( "main", this, WGECamera::ORTHOGRAPHIC ) );
m_mainGLWidget->initialize();
setCentralWidget( m_mainGLWidget.get() );
// initially 3 navigation views
......
......@@ -39,7 +39,6 @@ WQtCustomDockWidget::WQtCustomDockWidget( std::string title, QWidget* parent, WG
resize( 1024, 768 );
m_glWidget = boost::shared_ptr< WQtGLWidget >( new WQtGLWidget( title, this, projectionMode ) );
m_glWidget->initialize();
m_scene = new WGEGroupNode();
m_scene->setDataVariance( osg::Object::DYNAMIC );
m_glWidget->getViewer()->setScene( m_scene );
......@@ -72,11 +71,3 @@ bool WQtCustomDockWidget::decreaseUseCount()
}
return shouldClose;
}
void WQtCustomDockWidget::closeEvent( QCloseEvent* event )
{
// forward events
m_glWidget->close();
event->accept();
}
......@@ -76,13 +76,6 @@ public:
bool decreaseUseCount();
protected:
/**
* Event handler for close events
*
* \param event the event description.
*/
virtual void closeEvent( QCloseEvent* event );
private:
/**
* the included GL widget
......
......@@ -41,9 +41,7 @@
WQtGLWidget::WQtGLWidget( std::string nameOfViewer, QWidget* parent, WGECamera::ProjectionMode projectionMode )
: QGLWidget( parent ),
m_nameOfViewer( nameOfViewer ),
m_recommendedSize(),
m_isInitialized( new WConditionOneShot(), false ),
m_firstPaint( false )
m_recommendedSize()
{
m_recommendedSize.setWidth( 200 );
m_recommendedSize.setHeight( 200 );
......@@ -55,36 +53,18 @@ WQtGLWidget::WQtGLWidget( std::string nameOfViewer, QWidget* parent, WGECamera::
setAttribute( Qt::WA_NoSystemBackground );
setFocusPolicy( Qt::ClickFocus );
connect( &m_Timer, SIGNAL( timeout() ), this, SLOT( updateGL() ) );
m_Timer.start( 10 );
}
WQtGLWidget::~WQtGLWidget()
{
// cleanup
if ( m_isInitialized() )
{
m_Viewer.reset();
}
}
void WQtGLWidget::initialize()
{
if ( m_isInitialized() )
{
return;
}
// create viewer
m_Viewer = WKernel::getRunningKernel()->getGraphicsEngine()->createViewer(
m_nameOfViewer, x(), y(), width(), height(), m_initialProjectionMode );
m_isInitialized( true );
connect( &m_Timer, SIGNAL( timeout() ), this, SLOT( updateGL() ) );
m_Timer.start( 10 );
}
const WBoolFlag& WQtGLWidget::isInitialized() const
WQtGLWidget::~WQtGLWidget()
{
return m_isInitialized;
WKernel::getRunningKernel()->getGraphicsEngine()->closeViewer( m_nameOfViewer );
m_Viewer.reset();
}
QSize WQtGLWidget::sizeHint() const
......@@ -145,7 +125,6 @@ void WQtGLWidget::setCameraManipulator( WQtGLWidget::CameraManipulators manipula
void WQtGLWidget::setBgColor( WColor bgColor )
{
assert( m_Viewer );
m_Viewer->setBgColor( bgColor );
}
......@@ -159,15 +138,6 @@ boost::shared_ptr< WGEViewer > WQtGLWidget::getViewer() const
return m_Viewer;
}
void WQtGLWidget::closeEvent( QCloseEvent* event )
{
// forward events
WKernel::getRunningKernel()->getGraphicsEngine()->closeViewer( m_nameOfViewer );
event->accept();
}
void WQtGLWidget::paintGL()
{
m_Viewer->paint();
......
......@@ -35,7 +35,6 @@
#include <boost/signals2/signal.hpp>
#include "../../graphicsEngine/WGECamera.h"
#include "../../common/WFlag.h"
class WGEViewer;
class WColor;
......@@ -66,11 +65,6 @@ public:
*/
virtual ~WQtGLWidget();
/**
* Since the widget is not visible during construction, the OSG thread may cause errors, so we use a post constructor.
*/
virtual void initialize();
/**
* returns the recommended size for the widget to allow
* parent widgets to give it a proper initial layout
......@@ -112,13 +106,6 @@ public:
*/
boost::shared_ptr< WGEViewer > getViewer() const;
/**
* Determines whether the widget is properly initialized.
*
* \return flag - initialized.
*/
const WBoolFlag& isInitialized() const;
protected:
/**
* The viewer to the scene.
......@@ -138,13 +125,6 @@ protected:
*/
virtual void mouseDoubleClickEvent( QMouseEvent* event );
/**
* Event handler for close events.
*
* \param event the event description.
*/
virtual void closeEvent( QCloseEvent* event );
/**
* QT Callback for handling repaints.
*/
......@@ -230,11 +210,6 @@ private:
*/
QSize m_recommendedSize;
/**
* True when initialized.
*/
WBoolFlag m_isInitialized;
/**
* True when the widget got drawn the very first time.
*/
......
......@@ -51,7 +51,6 @@ WQtNavGLWidget::WQtNavGLWidget( QString title, QWidget* parent, std::string slid
m_layout = new QVBoxLayout();
m_glWidget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( title.toStdString(), panel, WGECamera::ORTHOGRAPHIC ) );
m_glWidget->initialize();
setMinimumSize( 160, 240 );
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
......@@ -76,14 +75,6 @@ WQtNavGLWidget::~WQtNavGLWidget()
}
}
void WQtNavGLWidget::closeEvent( QCloseEvent* event )
{
// forward events
m_glWidget->close();
event->accept();
}
void WQtNavGLWidget::setSliderTitle( std::string title )
{
m_sliderTitle = QString( title.c_str() );
......
......@@ -80,14 +80,6 @@ public:
void setSliderProperty( WPropInt prop );
protected:
/**
* Event handler for close events.
*
* \param event the event description.
*/
virtual void closeEvent( QCloseEvent* event );
private:
/**
......
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