Browse Source

Fixed possible subsystem deinitialization order error.
Fixed uninitialized variable in GraphicsImpl, which caused crash when exiting before opening the rendering window.

Lasse Öörni 12 years ago
parent
commit
4f5e060a6a

+ 8 - 0
Engine/Core/Context.cpp

@@ -61,6 +61,14 @@ Context::Context() :
 
 
 Context::~Context()
 Context::~Context()
 {
 {
+    // Remove subsystems that use SDL in reverse order of construction, so that Graphics can shut down SDL last
+    /// \todo Context should not need to know about subsystems
+    RemoveSubsystem("Audio");
+    RemoveSubsystem("UI");
+    RemoveSubsystem("Input");
+    RemoveSubsystem("Renderer");
+    RemoveSubsystem("Graphics");
+    
     subsystems_.Clear();
     subsystems_.Clear();
     factories_.Clear();
     factories_.Clear();
 }
 }

+ 0 - 6
Engine/Engine/Engine.cpp

@@ -95,12 +95,6 @@ Engine::Engine(Context* context) :
 
 
 Engine::~Engine()
 Engine::~Engine()
 {
 {
-    // Remove subsystems that use SDL in reverse order of construction
-    context_->RemoveSubsystem<Audio>();
-    context_->RemoveSubsystem<UI>();
-    context_->RemoveSubsystem<Input>();
-    context_->RemoveSubsystem<Renderer>();
-    context_->RemoveSubsystem<Graphics>();
 }
 }
 
 
 bool Engine::Initialize(const VariantMap& parameters)
 bool Engine::Initialize(const VariantMap& parameters)

+ 1 - 0
Engine/Graphics/Direct3D9/D3D9GraphicsImpl.cpp

@@ -35,6 +35,7 @@ GraphicsImpl::GraphicsImpl() :
     interface_(0),
     interface_(0),
     device_(0),
     device_(0),
     defaultColorSurface_(0),
     defaultColorSurface_(0),
+    defaultDepthStencilSurface_(0),
     adapter_(D3DADAPTER_DEFAULT),
     adapter_(D3DADAPTER_DEFAULT),
     deviceType_(D3DDEVTYPE_HAL)
     deviceType_(D3DDEVTYPE_HAL)
 {
 {