瀏覽代碼

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

Lasse Öörni 12 年之前
父節點
當前提交
4f5e060a6a
共有 3 個文件被更改,包括 9 次插入6 次删除
  1. 8 0
      Engine/Core/Context.cpp
  2. 0 6
      Engine/Engine/Engine.cpp
  3. 1 0
      Engine/Graphics/Direct3D9/D3D9GraphicsImpl.cpp

+ 8 - 0
Engine/Core/Context.cpp

@@ -61,6 +61,14 @@ 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();
     factories_.Clear();
 }

+ 0 - 6
Engine/Engine/Engine.cpp

@@ -95,12 +95,6 @@ Engine::Engine(Context* context) :
 
 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)

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

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