Commit c22f6aa7 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[FIX] fixes crash when closing the main view and then closing OW

parent cb42dc70
......@@ -41,12 +41,13 @@
#include <osgDB/ReadFile>
#include "exceptions/WGEInitFailed.h"
#include "WGE2DManipulator.h"
#include "WGEGroupNode.h"
#include "WGENoOpManipulator.h"
#include "WGEZoomTrackballManipulator.h"
#include "WGraphicsEngine.h"
#include "WPickHandler.h"
#include "exceptions/WGEInitFailed.h"
#include "../common/WConditionOneShot.h"
#include "../common/WThreadedRunner.h"
......@@ -64,7 +65,8 @@ WGEViewer::WGEViewer( std::string name, osg::ref_ptr<osg::Referenced> wdata, int
m_inAnimationMode( false ),
m_effectHorizon( new WGEViewerEffectHorizon() ),
m_effectVignette( new WGEViewerEffectVignette() ),
m_effectImageOverlay( new WGEViewerEffectImageOverlay() )
m_effectImageOverlay( new WGEViewerEffectImageOverlay() ),
m_paused( false )
{
try
{
......@@ -396,3 +398,12 @@ void WGEViewer::setEffectsActiveDefault( bool activeByDefault )
getVignette()->setEnabledByDefault( activeByDefault );
}
void WGEViewer::setPaused( bool pause )
{
m_paused = pause;
}
bool WGEViewer::getPaused() const
{
return m_paused;
}
......@@ -307,6 +307,19 @@ public:
*/
WProperties::SPtr getProperties() const;
/**
* Pause rendering. This does not free the viewer. It simply pauses rendering.
*
* \param pause true to pause.
*/
void setPaused( bool pause = true );
/**
* Query whether the view is paused or not.
*
* \return true if paused
*/
bool getPaused() const;
protected:
/**
* The OpenSceneGraph view used in this (Composite)Viewer.
......@@ -452,6 +465,11 @@ private:
* Update throw setting of the manipulator (if supported).
*/
void updateThrowing();
/**
* Flag denoting whether the view is paused or not
*/
bool m_paused;
};
#endif // WGEVIEWER_H
......@@ -288,7 +288,6 @@ void WGraphicsEngine::applyViewerListUpdates()
}
m_removeViewers.clear();
m_viewersUpdate = false;
lock.unlock();
// notify all of them
for( std::vector< WCondition::SPtr >::iterator it = m_viewerUpdateNotifiers.begin(); it != m_viewerUpdateNotifiers.end(); ++it )
......@@ -296,6 +295,7 @@ void WGraphicsEngine::applyViewerListUpdates()
( *it )->notify();
}
m_viewerUpdateNotifiers.clear();
lock.unlock();
}
}
......
......@@ -139,11 +139,16 @@ WQtGLDockWidget::WQtGLDockWidget( QString viewTitle, QString dockTitle, QWidget*
WQtGLDockWidget::~WQtGLDockWidget()
{
// cleanup
delete m_screenCapture;
m_screenCapture = NULL;
}
void WQtGLDockWidget::saveSettings()
{
m_screenCapture->saveSettings();
if( m_screenCapture )
{
m_screenCapture->saveSettings();
}
WQtDockWidget::saveSettings();
// optional:
......@@ -217,17 +222,13 @@ void WQtGLDockWidget::handleVisibilityChange( bool visible )
void WQtGLDockWidget::closeEvent( QCloseEvent *event )
{
event->accept();
m_glWidget->setPaused( true );
WQtDockWidget::closeEvent( event );
delete m_screenCapture;
m_screenCapture = NULL;
m_glWidget->close();
}
void WQtGLDockWidget::showEvent( QShowEvent* event )
{
m_glWidget->getViewer()->setClosed( false );
m_glWidget->setPaused( false );
WQtDockWidget::showEvent( event );
}
......
......@@ -240,7 +240,10 @@ void WQtGLWidget::paintGL()
{
if( m_Viewer )
{
m_Viewer->paint();
if( !m_Viewer->getPaused() )
{
m_Viewer->paint();
}
}
}
......@@ -265,8 +268,14 @@ void WQtGLWidget::paintGL()
{
// m_Viewer->paint();
#ifdef IS_A_QGLWIDGET
// if the parent is a GL widget, issue parent method.
WQtGLWidgetParent::paintGL();
if( m_Viewer )
{
if( !m_Viewer->getPaused() )
{
// if the parent is a GL widget, issue parent method.
WQtGLWidgetParent::paintGL();
}
}
#endif
}
......@@ -580,3 +589,13 @@ QAction* WQtGLWidget::getCameraResetAction()
{
return m_cameraResetAction;
}
void WQtGLWidget::setPaused( bool pause )
{
getViewer()->setPaused( pause );
}
bool WQtGLWidget::getPaused() const
{
return getViewer()->getPaused();
}
......@@ -150,6 +150,20 @@ public:
*/
virtual void cleanUp();
/**
* Pause rendering. This does not free the viewer. It simply pauses rendering.
*
* \param pause true to pause.
*/
void setPaused( bool pause = true );
/**
* Query whether the view is paused or not.
*
* \return true if paused
*/
bool getPaused() const;
signals:
/**
......
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