Browse Source

Subsystem cleanup

Josh Engebretson 10 years ago
parent
commit
b76c964070
39 changed files with 200 additions and 15 deletions
  1. 27 0
      Source/Atomic/Graphics/Direct3D9/D3D9Graphics.cpp
  2. 5 0
      Source/Atomic/Graphics/Direct3D9/D3D9Graphics.h
  3. 1 1
      Source/AtomicEditor/Source/AEApplication.cpp
  4. 8 4
      Source/AtomicEditor/Source/AEEditor.cpp
  5. 4 0
      Source/AtomicEditor/Source/AEEvents.h
  6. 6 1
      Source/AtomicEditor/Source/AEJavascript.cpp
  7. 1 0
      Source/AtomicEditor/Source/AEJavascript.h
  8. 8 0
      Source/AtomicEditor/Source/AEPreferences.cpp
  9. 2 1
      Source/AtomicEditor/Source/AEPreferences.h
  10. 6 0
      Source/AtomicEditor/Source/Build/BuildSystem.cpp
  11. 1 0
      Source/AtomicEditor/Source/Build/BuildSystem.h
  12. 8 0
      Source/AtomicEditor/Source/License/AELicenseSystem.cpp
  13. 1 0
      Source/AtomicEditor/Source/License/AELicenseSystem.h
  14. 7 0
      Source/AtomicEditor/Source/License/AEVersionCheck.cpp
  15. 1 0
      Source/AtomicEditor/Source/License/AEVersionCheck.h
  16. 6 0
      Source/AtomicEditor/Source/Net/CurlManager.cpp
  17. 1 0
      Source/AtomicEditor/Source/Net/CurlManager.h
  18. 6 0
      Source/AtomicEditor/Source/Player/AEPlayer.cpp
  19. 1 0
      Source/AtomicEditor/Source/Player/AEPlayer.h
  20. 8 1
      Source/AtomicEditor/Source/Project/ProjectUtils.cpp
  21. 5 0
      Source/AtomicEditor/Source/Project/ProjectUtils.h
  22. 7 0
      Source/AtomicEditor/Source/Resources/AEResourceOps.cpp
  23. 2 0
      Source/AtomicEditor/Source/Resources/AEResourceOps.h
  24. 10 1
      Source/AtomicEditor/Source/Subprocess/AESubprocessSystem.cpp
  25. 1 0
      Source/AtomicEditor/Source/Subprocess/AESubprocessSystem.h
  26. 9 1
      Source/AtomicEditor/Source/Tools/External/AEExternalTooling.cpp
  27. 2 0
      Source/AtomicEditor/Source/Tools/External/AEExternalTooling.h
  28. 7 0
      Source/AtomicEditor/Source/UI/Modal/UIModalOps.cpp
  29. 2 0
      Source/AtomicEditor/Source/UI/Modal/UIModalOps.h
  30. 6 0
      Source/AtomicEditor/Source/UI/UIConsoleWidget.cpp
  31. 2 0
      Source/AtomicEditor/Source/UI/UIConsoleWidget.h
  32. 9 2
      Source/AtomicEditor/Source/UI/UIErrorsWidget.cpp
  33. 3 0
      Source/AtomicEditor/Source/UI/UIErrorsWidget.h
  34. 6 0
      Source/AtomicEditor/Source/UI/UIFindTextWidget.cpp
  35. 2 0
      Source/AtomicEditor/Source/UI/UIFindTextWidget.h
  36. 10 3
      Source/AtomicEditor/Source/UI/UIIssuesWidget.cpp
  37. 2 0
      Source/AtomicEditor/Source/UI/UIIssuesWidget.h
  38. 6 0
      Source/AtomicEditor/Source/UI/UIMainFrame.cpp
  39. 1 0
      Source/AtomicEditor/Source/UI/UIMainFrame.h

+ 27 - 0
Source/Atomic/Graphics/Direct3D9/D3D9Graphics.cpp

@@ -375,6 +375,33 @@ void Graphics::SetWindowPosition(int x, int y)
     SetWindowPosition(IntVector2(x, y));
 }
 
+void Graphics::SetWindowSize(int width, int height)
+{
+    if (impl_->window_)
+    {
+        SDL_SetWindowSize(impl_->window_, width, height);
+        WindowResized();
+    }
+}
+
+void Graphics::CenterWindow()
+{
+    if (impl_->window_)
+    {
+        SDL_DisplayMode mode;
+        SDL_GetDesktopDisplayMode(0, &mode);
+
+        int width, height;
+        SDL_GetWindowSize(impl_->window_, &width, &height);
+
+        int x = mode.w/2 - width/2;
+        int y = mode.h/2 - height/2;
+
+        SetWindowPosition(x, y);
+
+    }
+}
+
 void Graphics::RaiseWindow()
 {
     if (impl_->window_)

+ 5 - 0
Source/Atomic/Graphics/Direct3D9/D3D9Graphics.h

@@ -92,6 +92,11 @@ public:
     void SetWindowPosition(const IntVector2& position);
     /// Set window position. Sets initial position if window is not created yet.
     void SetWindowPosition(int x, int y);
+    /// Set window size.
+    void SetWindowSize(int width, int height);
+    /// Center window.
+    void CenterWindow();
+    /// Bring the window to front with focus
     void RaiseWindow();
     /// Set screen mode. Return true if successful.
     bool SetMode(int width, int height, bool fullscreen, bool borderless, bool resizable, bool vsync, bool tripleBuffer, int multiSample);

+ 1 - 1
Source/AtomicEditor/Source/AEApplication.cpp

@@ -92,7 +92,7 @@ void AEApplication::Start()
 
     Input* input = GetSubsystem<Input>();
 
-    // The mouse isn't showing up on OSX until I tab, this is a hack and temp workaround
+
     input->SetMouseVisible(true);
 
     context_->RegisterSubsystem(new ProjectUtils(context_));

+ 8 - 4
Source/AtomicEditor/Source/AEEditor.cpp

@@ -44,11 +44,7 @@ Editor::Editor(Context* context) :
 {
     RegisterEditorLibrary(context_);
 
-    javascript_ = new Javascript(context_);
-    context_->RegisterSubsystem(javascript_);
-
     aejavascript_ = new AEJavascript(context_);
-
     aepreferences_ = new AEPreferences(context_);
 
 #ifdef USE_SPIDERMONKEY
@@ -304,6 +300,14 @@ void Editor::HandleExitRequested(StringHash eventType, VariantMap& eventData)
         aepreferences_->Write();
     }
 
+    mainframe_ = 0;
+    context_->RemoveSubsystem(Javascript::GetBaseTypeStatic());
+
+    SendEvent(E_EDITORSHUTDOWN);
+
+    SharedPtr<Editor> keepAlive(this);
+    context_->RemoveSubsystem(GetType());
+
     Engine* engine = GetSubsystem<Engine>();
     engine->Exit();
 }

+ 4 - 0
Source/AtomicEditor/Source/AEEvents.h

@@ -120,5 +120,9 @@ EVENT(E_CURLCOMPLETE, CurlComplete)
     PARAM(P_CURLREQUEST, Request);      // CurlRequest*
 }
 
+EVENT(E_EDITORSHUTDOWN, EditorShutdown)
+{
+
+}
 
 }

+ 6 - 1
Source/AtomicEditor/Source/AEJavascript.cpp

@@ -13,6 +13,7 @@
 #include <Atomic/Resource/ResourceCache.h>
 
 #include "AEEditor.h"
+#include "AEEvents.h"
 #include "Project/AEProject.h"
 
 #include "AEJavascript.h"
@@ -40,6 +41,7 @@ AEJavascript::AEJavascript(Context* context) :
     errorChecker_ = new JSErrorChecker(context, ctx_);
 
     SubscribeToEvent(E_FILECHANGED, HANDLER(AEJavascript, HandleFileChanged));
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(AEJavascript, HandleEditorShutdown));
 
     ExecuteFile("AtomicEditor/javascript/AtomicEditor.js");
 }
@@ -312,6 +314,9 @@ int AEJavascript::js_module_search(duk_context* ctx)
     return 1;
 }
 
-
+void AEJavascript::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
 
 }

+ 1 - 0
Source/AtomicEditor/Source/AEJavascript.h

@@ -48,6 +48,7 @@ private:
 
     bool ReadZeroTerminatedSourceFile(const String& path, String& source);
     void HandleFileChanged(StringHash eventType, VariantMap& eventData);
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
 
     static int js_module_search(duk_context* ctx);
     static int js_read_source(duk_context* ctx);

+ 8 - 0
Source/AtomicEditor/Source/AEPreferences.cpp

@@ -14,6 +14,7 @@
 #include <Atomic/IO/File.h>
 #include <Atomic/Graphics/Graphics.h>
 
+#include "AEEvents.h"
 #include "AEPreferences.h"
 
 using namespace rapidjson;
@@ -26,6 +27,8 @@ AEPreferences::AEPreferences(Context* context) :
 {
     context->RegisterSubsystem(this);
 
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(AEPreferences, HandleEditorShutdown));
+
     Read();
 }
 
@@ -262,4 +265,9 @@ bool AEPreferences::ReadStartupPrefs(Context *context, StartupPreferences& prefs
 
 }
 
+void AEPreferences::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
 }

+ 2 - 1
Source/AtomicEditor/Source/AEPreferences.h

@@ -46,8 +46,9 @@ public:
 
 private:
 
-    void Clear();
+     void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
 
+    void Clear();
     String GetPreferencesFullPath();
 
     String androidSDKPath_;

+ 6 - 0
Source/AtomicEditor/Source/Build/BuildSystem.cpp

@@ -27,6 +27,7 @@ BuildSystem::BuildSystem(Context* context) :
     buildSettings_ = new BuildSettings(context);
 
     SubscribeToEvent(E_EDITORBUILD, HANDLER(BuildSystem, HandleEditorBuild));
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(BuildSystem, HandleEditorShutdown));
 
 }
 
@@ -167,4 +168,9 @@ void BuildSystem::HandleEditorBuild(StringHash eventType, VariantMap& eventData)
 
 }
 
+void BuildSystem::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
 }

+ 1 - 0
Source/AtomicEditor/Source/Build/BuildSystem.h

@@ -47,6 +47,7 @@ private:
     SharedPtr<UIBuildComplete> uiBuildComplete_;
 
     void HandleEditorBuild(StringHash eventType, VariantMap& eventData);
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
 };
 
 

+ 8 - 0
Source/AtomicEditor/Source/License/AELicenseSystem.cpp

@@ -18,6 +18,7 @@
 
 #include "AtomicEditor.h"
 #include <Atomic/Core/CoreEvents.h>
+#include <Atomic/Core/Context.h>
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/IO/File.h>
 #include <Atomic/IO/Log.h>
@@ -44,6 +45,8 @@ LicenseSystem::LicenseSystem(Context* context) :
 
 {
     ResetLicense();
+
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(LicenseSystem, HandleEditorShutdown));
 }
 
 LicenseSystem::~LicenseSystem()
@@ -518,6 +521,11 @@ void LicenseSystem::HandleDeactivate(StringHash eventType, VariantMap& eventData
 
 }
 
+void LicenseSystem::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
 }
 
 // END LICENSE MANAGEMENT

+ 1 - 0
Source/AtomicEditor/Source/License/AELicenseSystem.h

@@ -88,6 +88,7 @@ private:
 
     void HandleVerification(StringHash eventType, VariantMap& eventData);
     void HandleDeactivate(StringHash eventType, VariantMap& eventData);
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
 
     bool eulaAgreementConfirmed_;
 

+ 7 - 0
Source/AtomicEditor/Source/License/AEVersionCheck.cpp

@@ -7,6 +7,7 @@
 #include <rapidjson/prettywriter.h>
 
 #include "AtomicEditor.h"
+#include <Atomic/Core/Context.h>
 #include <Atomic/IO/Log.h>
 #include "AEEditor.h"
 #include "AEEvents.h"
@@ -20,6 +21,7 @@ VersionCheck::VersionCheck(Context* context) :
     Object(context)
 
 {
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(VersionCheck, HandleEditorShutdown));
     progressModal_ = new ProgressModal(context_, "Checking for Updates", "Checking for updates, please wait...");
 }
 
@@ -125,6 +127,11 @@ void VersionCheck::HandleCurlComplete(StringHash eventType, VariantMap& eventDat
 
 }
 
+void VersionCheck::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
 /*
 {
     "major" : 0,

+ 1 - 0
Source/AtomicEditor/Source/License/AEVersionCheck.h

@@ -27,6 +27,7 @@ public:
     void DoVersionCheck();
 
 private:
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
     void HandleCurlComplete(StringHash eventType, VariantMap& eventData);
 
     SharedPtr<CurlRequest> versionRequest_;

+ 6 - 0
Source/AtomicEditor/Source/Net/CurlManager.cpp

@@ -4,6 +4,7 @@
 
 #include "AtomicEditor.h"
 #include <Atomic/Core/CoreEvents.h>
+#include <Atomic/Core/Context.h>
 #include "CurlManager.h"
 #include <curl/curl.h>
 
@@ -74,6 +75,7 @@ CurlManager::CurlManager(Context* context) :
     curl_global_init(CURL_GLOBAL_DEFAULT);
 
     SubscribeToEvent(E_UPDATE, HANDLER(CurlManager, HandleUpdate));
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(CurlManager, HandleEditorShutdown));
 }
 
 CurlManager::~CurlManager()
@@ -115,5 +117,9 @@ void CurlManager::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
 }
 
+void CurlManager::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
 
 }

+ 1 - 0
Source/AtomicEditor/Source/Net/CurlManager.h

@@ -59,6 +59,7 @@ public:
 
 private:
 
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
 
     Vector< SharedPtr<CurlRequest> > requests_;

+ 6 - 0
Source/AtomicEditor/Source/Player/AEPlayer.cpp

@@ -28,6 +28,7 @@ AEPlayer::AEPlayer(Context* context) :
     Object(context),
     mode_(AE_PLAYERMODE_WIDGET)
 {
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(AEPlayer, HandleEditorShutdown));
 
     assert(!context->GetSubsystem<AEPlayer>());
     context->RegisterSubsystem(this);
@@ -106,4 +107,9 @@ bool AEPlayer::Play(AEPlayerMode mode, const IntRect &rect)
     return ok;
 }
 
+void AEPlayer::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
 }

+ 1 - 0
Source/AtomicEditor/Source/Player/AEPlayer.h

@@ -55,6 +55,7 @@ private:
     Vector<AEPlayerError> errors_;
 
     void HandleJSError(StringHash eventType, VariantMap& eventData);
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
 
     SharedPtr<JSVM> vm_;
 

+ 8 - 1
Source/AtomicEditor/Source/Project/ProjectUtils.cpp

@@ -8,6 +8,7 @@
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/Graphics/Graphics.h>
 #include "ProjectUtils.h"
+#include "AEEvents.h"
 #include "nfd.h"
 
 #include "../AEEditor.h"
@@ -18,7 +19,7 @@ namespace AtomicEditor
 ProjectUtils::ProjectUtils(Context* context) :
     Object(context)
 {
-
+     SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(ProjectUtils, HandleEditorShutdown));
 }
 
 void ProjectUtils::OpenProjectFileDialog()
@@ -153,4 +154,10 @@ ProjectUtils::~ProjectUtils()
 {
 }
 
+void ProjectUtils::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
+
 }

+ 5 - 0
Source/AtomicEditor/Source/Project/ProjectUtils.h

@@ -28,6 +28,11 @@ public:
     ProjectUtils(Context* context);
     /// Destruct.
     ~ProjectUtils();
+
+private:
+
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
+
 };
 
 

+ 7 - 0
Source/AtomicEditor/Source/Resources/AEResourceOps.cpp

@@ -28,6 +28,8 @@ ResourceOps::ResourceOps(Context* context) :
     Object(context)
 {
     context->RegisterSubsystem(this);
+
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(ResourceOps, HandleEditorShutdown));
 }
 
 /// Destruct.
@@ -439,5 +441,10 @@ void ResourceOps::HandleCreate2DLevel(const String& resourcePath, const String&
 
 }
 
+void ResourceOps::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
 
 }

+ 2 - 0
Source/AtomicEditor/Source/Resources/AEResourceOps.h

@@ -32,6 +32,8 @@ public:
     void HandleCreate2DLevel(const String& resourcePath, const String& resourceName, bool navigateToResource = false, bool reportError = true);
 private:
 
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
+
     bool CopyFile(File* srcFile, const String& destFileName);
 
     bool CheckCreateComponent(const String& resourcePath, const String& resourceName, bool reportError);

+ 10 - 1
Source/AtomicEditor/Source/Subprocess/AESubprocessSystem.cpp

@@ -4,8 +4,11 @@
 
 #include "AtomicEditor.h"
 #include <Atomic/Core/CoreEvents.h>
+#include <Atomic/Core/Context.h>
 #include <Atomic/IO/FileSystem.h>
-#include "AtomicEditor.h"
+
+#include "AEEvents.h"
+
 #include "AESubprocessSystem.h"
 
 namespace AtomicEditor
@@ -16,6 +19,7 @@ SubprocessSystem::SubprocessSystem(Context* context) :
     updateTimer_(0.0f)
 {
     SubscribeToEvent(E_UPDATE, HANDLER(SubprocessSystem, HandleUpdate));
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(SubprocessSystem, HandleEditorShutdown));
 }
 
 SubprocessSystem::~SubprocessSystem()
@@ -68,5 +72,10 @@ void SubprocessSystem::HandleUpdate(StringHash eventType, VariantMap& eventData)
 
 }
 
+void SubprocessSystem::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
 }
 

+ 1 - 0
Source/AtomicEditor/Source/Subprocess/AESubprocessSystem.h

@@ -30,6 +30,7 @@ public:
 private:
 
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
 
     Vector<SharedPtr<Subprocess> > processes_;
     float updateTimer_;

+ 9 - 1
Source/AtomicEditor/Source/Tools/External/AEExternalTooling.cpp

@@ -4,11 +4,13 @@
 
 #include "AtomicEditor.h"
 
+#include <Atomic/Core/Context.h>
 #include <Atomic/IO/Log.h>
 #include <Atomic/IO/FileSystem.h>
 
-#include "AEExternalTooling.h"
+#include "AEEvents.h"
 
+#include "AEExternalTooling.h"
 #include "AtomicTiled.h"
 
 namespace AtomicEditor
@@ -17,6 +19,7 @@ namespace AtomicEditor
 ExternalTooling::ExternalTooling(Context* context) :
     Object(context)
 {
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(ExternalTooling, HandleEditorShutdown));
 }
 
 ExternalTooling::~ExternalTooling()
@@ -78,5 +81,10 @@ String ExternalTooling::GetToolApplicationPath()
 
 }
 
+void ExternalTooling::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
 
 }

+ 2 - 0
Source/AtomicEditor/Source/Tools/External/AEExternalTooling.h

@@ -33,6 +33,8 @@ public:
 
 private:
 
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
+
     HashMap<String, SharedPtr<ExternalTool> > tools_;
 
 

+ 7 - 0
Source/AtomicEditor/Source/UI/Modal/UIModalOps.cpp

@@ -81,6 +81,8 @@ UIModalOps::UIModalOps(Context* context) :
     TBWidgetListener::AddGlobalListener(this);
     context->RegisterSubsystem(this);
     dimmer_ = new TBDimmer();
+
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(UIModalOps, HandleEditorShutdown));
 }
 
 void UIModalOps::Show()
@@ -309,4 +311,9 @@ bool UIModalOps::OnEvent(const TBWidgetEvent &ev)
     return false;
 }
 
+void UIModalOps::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
 }

+ 2 - 0
Source/AtomicEditor/Source/UI/Modal/UIModalOps.h

@@ -85,6 +85,8 @@ private:
 
     void Show();
 
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
+
     // TBWidgetListener
     void OnWidgetDelete(TBWidget *widget);
     bool OnWidgetDying(TBWidget *widget);

+ 6 - 0
Source/AtomicEditor/Source/UI/UIConsoleWidget.cpp

@@ -30,6 +30,7 @@ ConsoleWidget::ConsoleWidget(Context* context) :
     consolelayout_(0)
 {
     context_->RegisterSubsystem(this);
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(ConsoleWidget, HandleEditorShutdown));
 
     TBUI* tbui = GetSubsystem<TBUI>();
     tbui->LoadResourceFile(delegate_, "AtomicEditor/editor/ui/consolewidget.tb.txt");
@@ -83,5 +84,10 @@ bool ConsoleWidget::OnEvent(const TBWidgetEvent &ev)
     return false;
 }
 
+void ConsoleWidget::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
 }
 

+ 2 - 0
Source/AtomicEditor/Source/UI/UIConsoleWidget.h

@@ -34,6 +34,8 @@ public:
 
 private:
 
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
+
     SharedPtr<ListView> consoleList_;
     TBLayout* consolelayout_;
 

+ 9 - 2
Source/AtomicEditor/Source/UI/UIErrorsWidget.cpp

@@ -7,15 +7,15 @@
 #include <TurboBadger/tb_layout.h>
 #include <Atomic/Core/Context.h>
 #include <Atomic/IO/Log.h>
+#include <Atomic/IO/FileSystem.h>
 #include <Atomic/UI/TBUI.h>
 
+#include "AEEvents.h"
 #include "UIListView.h"
 #include "UIErrorsWidget.h"
 #include "UIMainFrame.h"
 #include "UIResourceFrame.h"
 
-#include <Atomic/IO/FileSystem.h>
-
 namespace AtomicEditor
 {
 
@@ -38,6 +38,8 @@ ErrorsWidget::ErrorsWidget(Context* context) :
     errorListWD->SetGravity(WIDGET_GRAVITY_ALL);
 
     errorlayout_->AddChild(errorListWD);
+
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(ErrorsWidget, HandleEditorShutdown));
 }
 
 ErrorsWidget::~ErrorsWidget()
@@ -101,5 +103,10 @@ bool ErrorsWidget::OnEvent(const TBWidgetEvent &ev)
     return false;
 }
 
+void ErrorsWidget::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
 }
 

+ 3 - 0
Source/AtomicEditor/Source/UI/UIErrorsWidget.h

@@ -34,6 +34,9 @@ public:
     bool OnEvent(const TBWidgetEvent &ev);
 
 private:
+
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
+
     Vector<AEPlayerError> errors_;
     SharedPtr<ListView> errorList_;
     TBLayout* errorlayout_;

+ 6 - 0
Source/AtomicEditor/Source/UI/UIFindTextWidget.cpp

@@ -34,6 +34,7 @@ FindTextWidget::FindTextWidget(Context* context) :
 
     SubscribeToEvent(E_FINDTEXTOPEN, HANDLER(FindTextWidget, HandleFindTextOpen));
     SubscribeToEvent(E_FINDTEXTCLOSE, HANDLER(FindTextWidget, HandleFindTextClose));
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(FindTextWidget, HandleEditorShutdown));
 }
 
 FindTextWidget::~FindTextWidget()
@@ -148,5 +149,10 @@ bool FindTextWidget::OnEvent(const TBWidgetEvent &ev)
     return false;
 }
 
+void FindTextWidget::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
 }
 

+ 2 - 0
Source/AtomicEditor/Source/UI/UIFindTextWidget.h

@@ -41,6 +41,8 @@ public:
 
 private:
 
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
+
     TBEditField* findtextedit_;
 
 };

+ 10 - 3
Source/AtomicEditor/Source/UI/UIIssuesWidget.cpp

@@ -8,6 +8,7 @@
 
 #include <Atomic/Core/Context.h>
 #include <Atomic/IO/Log.h>
+#include <Atomic/IO/FileSystem.h>
 #include <Atomic/UI/TBUI.h>
 
 #include "UIListView.h"
@@ -15,9 +16,8 @@
 #include "UIMainFrame.h"
 #include "UIResourceFrame.h"
 
-#include <Atomic/IO/FileSystem.h>
-
-#include "../AEJavascript.h"
+#include "AEEvents.h"
+#include "AEJavascript.h"
 
 namespace AtomicEditor
 {
@@ -41,6 +41,8 @@ IssuesWidget::IssuesWidget(Context* context) :
     issueListWD->SetGravity(WIDGET_GRAVITY_ALL);
 
     issuelayout_->AddChild(issueListWD);
+
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(IssuesWidget, HandleEditorShutdown));
 }
 
 IssuesWidget::~IssuesWidget()
@@ -102,5 +104,10 @@ bool IssuesWidget::OnEvent(const TBWidgetEvent &ev)
     return false;
 }
 
+void IssuesWidget::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
 }
 

+ 2 - 0
Source/AtomicEditor/Source/UI/UIIssuesWidget.h

@@ -34,6 +34,8 @@ public:
 
 private:
 
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
+
     SharedPtr<ListView> issueList_;
     TBLayout* issuelayout_;
 

+ 6 - 0
Source/AtomicEditor/Source/UI/UIMainFrame.cpp

@@ -181,6 +181,7 @@ MainFrame::MainFrame(Context* context) :
     SubscribeToEvent(E_SCREENMODE, HANDLER(MainFrame, HandleScreenMode));
     SubscribeToEvent(E_JAVASCRIPTSAVED, HANDLER(MainFrame, HandleJavascriptSaved));
     SubscribeToEvent(E_PLATFORMCHANGE, HANDLER(MainFrame, HandlePlatformChange));
+    SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(MainFrame, HandleEditorShutdown));
 
     messageModal_ = new MessageModal(context_);
     uiModalOps_ = new UIModalOps(context_);
@@ -712,4 +713,9 @@ void MainFrame::HandlePlatformChange(StringHash eventType, VariantMap& eventData
 
 }
 
+void MainFrame::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
+{
+    context_->RemoveSubsystem(GetType());
+}
+
 }

+ 1 - 0
Source/AtomicEditor/Source/UI/UIMainFrame.h

@@ -83,6 +83,7 @@ private:
     void HandleScreenMode(StringHash eventType, VariantMap& eventData);
     void HandleJavascriptSaved(StringHash eventType, VariantMap& eventData);
     void HandlePlatformChange(StringHash eventType, VariantMap& eventData);
+    void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
 
     TBEditField* consoletext_;
     TBLayout* resourceviewcontainer_;