Commit 357c8978 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[FIX] - this should fix the startup crash on ATI cards

parent 0221328c
......@@ -179,6 +179,8 @@ void WGraphicsEngine::threadMain()
WLogger::getLogger()->addLogMessage( "Starting Graphics Engine", "GE", LL_INFO );
#ifndef __APPLE__
// NOTE: this is needed here since the viewer might start without any widgets being initialized properly.
m_startThreadingCondition.wait();
m_running = true;
m_viewer->startThreading();
m_viewer->run();
......@@ -195,6 +197,11 @@ void WGraphicsEngine::notifyStop()
#endif
}
void WGraphicsEngine::finalizeStartup()
{
m_startThreadingCondition.notify();
}
void WGraphicsEngine::requestShaderReload()
{
m_reloadShadersSignal();
......
......@@ -45,6 +45,7 @@
#include <osgViewer/Viewer>
#include "../common/WThreadedRunner.h"
#include "../common/WConditionOneShot.h"
#include "../common/WColor.h"
#include "../common/math/linearAlgebra/WLinearAlgebra.h"
#include "WGEGraphicsWindow.h"
......@@ -144,6 +145,11 @@ public:
*/
static bool isRunning();
/**
* Function notifies the viewer threads (if any) to start. This should only be called AFTER the OpenGL widgets/windows have been initialized.
*/
void finalizeStartup();
protected:
/**
......@@ -196,6 +202,11 @@ private:
* True if graphics engine is running.
*/
bool m_running;
/**
* This condition is fired externally if all the GUI startup is done to ensure all OGL stuff is initialized prior to OSG threading startup.
*/
WConditionOneShot m_startThreadingCondition;
};
/**
......
......@@ -56,7 +56,8 @@ WQtGLWidget::WQtGLWidget( std::string nameOfViewer, QWidget* parent, WGECamera::
QWidget( parent ),
#endif
m_nameOfViewer( nameOfViewer ),
m_recommendedSize()
m_recommendedSize(),
m_firstPaint( true )
{
m_recommendedSize.setWidth( 200 );
m_recommendedSize.setHeight( 200 );
......@@ -138,7 +139,13 @@ boost::shared_ptr< WGEViewer > WQtGLWidget::getViewer() const
void WQtGLWidget::paintEvent( QPaintEvent* /*event*/ )
{
// m_Viewer->paint();
if ( m_firstPaint )
{
// it is important to let the GE know that there now is an completely initialized widget -> allowing GE startup to complete
// This is needed as on some machines, the OSG crashes if the GL widget is not fully initialized.
m_firstPaint = false;
WKernel::getRunningKernel()->getGraphicsEngine()->finalizeStartup();
}
}
#ifdef __APPLE__
......
......@@ -244,6 +244,11 @@ private:
* Holds the recommended size for the widget
*/
QSize m_recommendedSize;
/**
* This flag is set to true if the first paint call occured. See the paint method for details.
*/
bool m_firstPaint;
};
#endif // WQTGLWIDGET_H
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