int error = pthread_create( mThread, NULL, InternalThreadEntryFunc, this );
DALI_ASSERT_ALWAYS( !error && "Return code from pthread_create() in RenderThread" );
- mSurface->StartRender();
+ if( mSurface )
+ {
+ mSurface->StartRender();
+ }
}
void RenderThread::Stop()
{
DALI_LOG_INFO( gRenderLogFilter, Debug::Verbose, "RenderThread::Stop()\n");
- // shutdown the render thread and destroy the opengl context
- if( mThread )
+ if( mSurface )
{
// Tell surface we have stopped rendering
mSurface->StopRender();
+ // The surface will be destroyed soon; this pointer will become invalid
+ mSurface = NULL;
+ }
+
+ // shutdown the render thread and destroy the opengl context
+ if( mThread )
+ {
// wait for the thread to finish
pthread_join(*mThread, NULL);
mSurfaceReplaced = true;
}
-
void RenderThread::ShutdownEgl()
{
// inform core of context destruction
mCore.ContextDestroyed();
- // give a chance to destroy the OpenGL surface that created externally
- mSurface->DestroyEglSurface( *mEGL );
+ if( mSurface )
+ {
+ // give a chance to destroy the OpenGL surface that created externally
+ mSurface->DestroyEglSurface( *mEGL );
+ }
// delete the GL context / egl surface
mEGL->TerminateGles();
bool RenderThread::PreRender()
{
- bool success = mSurface->PreRender( *mEGL, mGLES );
+ bool success( false );
+ if( mSurface )
+ {
+ success = mSurface->PreRender( *mEGL, mGLES );
+ }
+
if( success )
{
mGLES.PreRender();
// Inform the gl implementation that rendering has finished before informing the surface
mGLES.PostRender(timeDelta);
- // Inform the surface that rendering this frame has finished.
- mSurface->PostRender( *mEGL, mGLES, mDisplayConnection, timeDelta, mSurfaceReplaced );
+ if( mSurface )
+ {
+ // Inform the surface that rendering this frame has finished.
+ mSurface->PostRender( *mEGL, mGLES, mDisplayConnection, timeDelta, mSurfaceReplaced );
+ }
mSurfaceReplaced = false;
}
-
} // namespace Adaptor
} // namespace Internal
mName(),
mStylesheet( stylesheet ),
mEnvironmentOptions(),
- mInitialized( false ),
mSlotDelegate( this )
{
// Get mName from environment options
mFramework->Quit();
// This will trigger OnTerminate(), below, after the main loop has completed.
- mInitialized = false;
}
void Application::OnInit()
Dali::StyleMonitor::Get().SetTheme( mStylesheet );
}
- mInitialized = true;
-
// Wire up the LifecycleController
Dali::LifecycleController lifecycleController = Dali::LifecycleController::Get();
// we've been told to quit by AppCore, ecore_x_destroy has been called, need to quit synchronously
// delete the window as ecore_x has been destroyed by AppCore
+ if( mAdaptor )
+ {
+ // Ensure that the render-thread is not using the surface(window) after we delete it
+ mAdaptor->Stop();
+ }
+
mWindow.Reset();
- mInitialized = false;
}
void Application::OnPause()