Преглед изворни кода

Remove ReferenceCountable from System-, Render-, and FileInterface.

Michael Ragazzon пре 6 година
родитељ
комит
a4b526c55c
41 измењених фајлова са 226 додато и 315 уклоњено
  1. 2 2
      Include/RmlUi/Core/Context.h
  2. 7 4
      Include/RmlUi/Core/Core.h
  3. 1 7
      Include/RmlUi/Core/FileInterface.h
  4. 1 7
      Include/RmlUi/Core/RenderInterface.h
  5. 1 7
      Include/RmlUi/Core/SystemInterface.h
  6. 6 6
      Samples/basic/animation/src/main.cpp
  7. 5 6
      Samples/basic/benchmark/src/main.cpp
  8. 6 7
      Samples/basic/bitmapfont/src/main.cpp
  9. 5 7
      Samples/basic/customlog/src/main.cpp
  10. 7 8
      Samples/basic/drag/src/main.cpp
  11. 6 7
      Samples/basic/loaddocument/src/main.cpp
  12. 6 6
      Samples/basic/sdl2/src/RenderInterfaceSDL2.h
  13. 3 2
      Samples/basic/sdl2/src/SystemInterfaceSDL2.h
  14. 11 11
      Samples/basic/sdl2/src/main.cpp
  15. 9 9
      Samples/basic/sfml2/src/RenderInterfaceSFML.h
  16. 3 3
      Samples/basic/sfml2/src/SystemInterfaceSFML.h
  17. 14 14
      Samples/basic/sfml2/src/main.cpp
  18. 5 5
      Samples/basic/transform/src/main.cpp
  19. 7 8
      Samples/basic/treeview/src/main.cpp
  20. 5 6
      Samples/invaders/src/main.cpp
  21. 5 5
      Samples/shell/include/ShellFileInterface.h
  22. 18 19
      Samples/shell/include/ShellRenderInterfaceOpenGL.h
  23. 4 4
      Samples/shell/include/ShellSystemInterface.h
  24. 8 8
      Samples/shell/src/ShellRenderInterfaceOpenGL.cpp
  25. 3 4
      Samples/shell/src/macosx/ShellMacOSX.cpp
  26. 3 4
      Samples/shell/src/win32/ShellWin32.cpp
  27. 3 4
      Samples/shell/src/x11/ShellX11.cpp
  28. 5 6
      Samples/tutorial/datagrid/src/main.cpp
  29. 5 6
      Samples/tutorial/datagrid_tree/src/main.cpp
  30. 5 6
      Samples/tutorial/drag/src/main.cpp
  31. 5 6
      Samples/tutorial/template/src/main.cpp
  32. 2 3
      Source/Core/Context.cpp
  33. 25 57
      Source/Core/Core.cpp
  34. 1 11
      Source/Core/FileInterface.cpp
  35. 5 5
      Source/Core/FileInterfaceDefault.h
  36. 3 13
      Source/Core/RenderInterface.cpp
  37. 1 11
      Source/Core/SystemInterface.cpp
  38. 7 3
      Source/Debugger/Plugin.cpp
  39. 4 1
      Source/Debugger/Plugin.h
  40. 3 6
      Source/Debugger/SystemInterface.cpp
  41. 1 1
      Source/Debugger/SystemInterface.h

+ 2 - 2
Include/RmlUi/Core/Context.h

@@ -284,7 +284,7 @@ private:
 	Vector2i mouse_position;
 	Vector2i mouse_position;
 
 
 	// The render interface this context renders through.
 	// The render interface this context renders through.
-	RenderInterface* render_interface;
+	SharedPtr<RenderInterface> render_interface;
 	Vector2i clip_origin;
 	Vector2i clip_origin;
 	Vector2i clip_dimensions;
 	Vector2i clip_dimensions;
 
 
@@ -331,7 +331,7 @@ private:
 	static void SendEvents(const ElementSet& old_items, const ElementSet& new_items, EventId id, const Dictionary& parameters);
 	static void SendEvents(const ElementSet& old_items, const ElementSet& new_items, EventId id, const Dictionary& parameters);
 
 
 	friend class Element;
 	friend class Element;
-	friend RMLUICORE_API Context* CreateContext(const String&, const Vector2i&, RenderInterface*);
+	friend RMLUICORE_API Context* CreateContext(const String&, const Vector2i&, SharedPtr<RenderInterface>);
 };
 };
 
 
 }
 }

+ 7 - 4
Include/RmlUi/Core/Core.h

@@ -105,16 +105,19 @@ RMLUICORE_API String GetVersion();
 
 
 /// Sets the interface through which all system requests are made. This must be called before Initialise().
 /// Sets the interface through which all system requests are made. This must be called before Initialise().
 /// @param[in] system_interface The application-specified logging interface.
 /// @param[in] system_interface The application-specified logging interface.
-RMLUICORE_API void SetSystemInterface(SystemInterface* system_interface);
+/// @return The previously set system interface.
+RMLUICORE_API void SetSystemInterface(SharedPtr<SystemInterface> system_interface);
 /// Returns RmlUi's system interface.
 /// Returns RmlUi's system interface.
 /// @return RmlUi's system interface.
 /// @return RmlUi's system interface.
 RMLUICORE_API SystemInterface* GetSystemInterface();
 RMLUICORE_API SystemInterface* GetSystemInterface();
+/// Returns a copy of the shared pointer to the system interface.
+RMLUICORE_API SharedPtr<SystemInterface> GetSystemInterfaceSharedPtr();
 
 
 /// Sets the interface through which all rendering requests are made. This is not required to be called, but if it is
 /// Sets the interface through which all rendering requests are made. This is not required to be called, but if it is
 /// it must be called before Initialise(). If no render interface is specified, then all contexts must have a custom
 /// it must be called before Initialise(). If no render interface is specified, then all contexts must have a custom
 /// render interface.
 /// render interface.
 /// @param[in] render_interface Render interface implementation.
 /// @param[in] render_interface Render interface implementation.
-RMLUICORE_API void SetRenderInterface(RenderInterface* render_interface);
+RMLUICORE_API void SetRenderInterface(SharedPtr<RenderInterface> render_interface);
 /// Returns RmlUi's default's render interface.
 /// Returns RmlUi's default's render interface.
 /// @return RmlUi's render interface.
 /// @return RmlUi's render interface.
 RMLUICORE_API RenderInterface* GetRenderInterface();
 RMLUICORE_API RenderInterface* GetRenderInterface();
@@ -122,7 +125,7 @@ RMLUICORE_API RenderInterface* GetRenderInterface();
 /// Sets the interface through which all file I/O requests are made. This is not required to be called, but if it is it
 /// Sets the interface through which all file I/O requests are made. This is not required to be called, but if it is it
 /// must be called before Initialise().
 /// must be called before Initialise().
 /// @param[in] file_interface The application-specified file interface
 /// @param[in] file_interface The application-specified file interface
-RMLUICORE_API void SetFileInterface(FileInterface* file_interface);
+RMLUICORE_API void SetFileInterface(SharedPtr<FileInterface> file_interface);
 /// Returns RmlUi's file interface.
 /// Returns RmlUi's file interface.
 /// @return RmlUi's file interface.
 /// @return RmlUi's file interface.
 RMLUICORE_API FileInterface* GetFileInterface();
 RMLUICORE_API FileInterface* GetFileInterface();
@@ -132,7 +135,7 @@ RMLUICORE_API FileInterface* GetFileInterface();
 /// @param[in] dimensions The initial dimensions of the new context.
 /// @param[in] dimensions The initial dimensions of the new context.
 /// @param[in] render_interface The custom render interface to use, or NULL to use the default.
 /// @param[in] render_interface The custom render interface to use, or NULL to use the default.
 /// @return The new context, or NULL if the context could not be created.
 /// @return The new context, or NULL if the context could not be created.
-RMLUICORE_API Context* CreateContext(const String& name, const Vector2i& dimensions, RenderInterface* render_interface = nullptr);
+RMLUICORE_API Context* CreateContext(const String& name, const Vector2i& dimensions, SharedPtr<RenderInterface> render_interface = nullptr);
 /// Removes a context.
 /// Removes a context.
 /// @param[in] name The name of the context to remove.
 /// @param[in] name The name of the context to remove.
 /// @return True if name is a valid context, false otherwise.
 /// @return True if name is a valid context, false otherwise.

+ 1 - 7
Include/RmlUi/Core/FileInterface.h

@@ -46,7 +46,7 @@ namespace Core {
 	@author Peter Curry
 	@author Peter Curry
  */
  */
 
 
-class RMLUICORE_API FileInterface : public ReferenceCountable
+class RMLUICORE_API FileInterface : public NonCopyMoveable
 {
 {
 public:
 public:
 	FileInterface();
 	FileInterface();
@@ -82,12 +82,6 @@ public:
 	/// @param file The handle of the file to be queried.
 	/// @param file The handle of the file to be queried.
 	/// @return The length of the file in bytes.
 	/// @return The length of the file in bytes.
 	virtual size_t Length(FileHandle file);
 	virtual size_t Length(FileHandle file);
-
-	/// Called when this file interface is released.
-	virtual void Release();
-
-protected:
-	virtual void OnReferenceDeactivate();
 };
 };
 
 
 }
 }

+ 1 - 7
Include/RmlUi/Core/RenderInterface.h

@@ -47,7 +47,7 @@ class Context;
 	@author Peter Curry
 	@author Peter Curry
  */
  */
 
 
-class RMLUICORE_API RenderInterface : public ReferenceCountable
+class RMLUICORE_API RenderInterface : public NonCopyMoveable
 {
 {
 public:
 public:
 	RenderInterface();
 	RenderInterface();
@@ -122,16 +122,10 @@ public:
 	///            It always equals the argument of the latest call to PushTransform().
 	///            It always equals the argument of the latest call to PushTransform().
 	virtual void PopTransform(const Matrix4f& transform);
 	virtual void PopTransform(const Matrix4f& transform);
 
 
-	/// Called when this render interface is released.
-	virtual void Release();
-
 	/// Get the context currently being rendered. This is only valid during RenderGeometry,
 	/// Get the context currently being rendered. This is only valid during RenderGeometry,
 	/// CompileGeometry, RenderCompiledGeometry, EnableScissorRegion and SetScissorRegion.
 	/// CompileGeometry, RenderCompiledGeometry, EnableScissorRegion and SetScissorRegion.
 	Context* GetContext() const;
 	Context* GetContext() const;
 
 
-protected:
-	virtual void OnReferenceDeactivate();
-
 private:
 private:
 	Context* context;
 	Context* context;
 
 

+ 1 - 7
Include/RmlUi/Core/SystemInterface.h

@@ -52,7 +52,7 @@ namespace Core {
 	@author Lloyd Weehuizen
 	@author Lloyd Weehuizen
  */
  */
 
 
-class RMLUICORE_API SystemInterface : public ReferenceCountable
+class RMLUICORE_API SystemInterface : public NonCopyMoveable
 {
 {
 public:
 public:
 	SystemInterface();
 	SystemInterface();
@@ -97,12 +97,6 @@ public:
 	
 	
 	/// Deactivate keyboard (for touchscreen devices)
 	/// Deactivate keyboard (for touchscreen devices)
 	virtual void DeactivateKeyboard();
 	virtual void DeactivateKeyboard();
-	
-	/// Called when this system interface is no longer required.
-	virtual void Release();
-
-protected:
-	virtual void OnReferenceDeactivate();
 };
 };
 
 
 }
 }

+ 6 - 6
Samples/basic/animation/src/main.cpp

@@ -326,8 +326,9 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	const int width = 1800;
 	const int width = 1800;
 	const int height = 1000;
 	const int height = 1000;
 
 
-	ShellRenderInterfaceOpenGL opengl_renderer;
-	shell_renderer = &opengl_renderer;
+
+	auto opengl_renderer = std::make_shared<ShellRenderInterfaceOpenGL>();
+	shell_renderer = opengl_renderer.get();
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	if (!Shell::Initialise() ||
 	if (!Shell::Initialise() ||
@@ -338,11 +339,10 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	}
 	}
 
 
 	// RmlUi initialisation.
 	// RmlUi initialisation.
-	Rml::Core::SetRenderInterface(&opengl_renderer);
-	opengl_renderer.SetViewport(width, height);
+	Rml::Core::SetRenderInterface(opengl_renderer);
+	opengl_renderer->SetViewport(width, height);
 
 
-	ShellSystemInterface system_interface;
-	Rml::Core::SetSystemInterface(&system_interface);
+	Rml::Core::SetSystemInterface(std::make_shared<ShellSystemInterface>());
 
 
 	Rml::Core::Initialise();
 	Rml::Core::Initialise();
 
 

+ 5 - 6
Samples/basic/benchmark/src/main.cpp

@@ -287,8 +287,8 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	const int width = 1800;
 	const int width = 1800;
 	const int height = 1000;
 	const int height = 1000;
 
 
-	ShellRenderInterfaceOpenGL opengl_renderer;
-	shell_renderer = &opengl_renderer;
+	auto opengl_renderer = std::make_shared<ShellRenderInterfaceOpenGL>();
+	shell_renderer = opengl_renderer.get();
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	if (!Shell::Initialise() ||
 	if (!Shell::Initialise() ||
@@ -299,11 +299,10 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	}
 	}
 
 
 	// RmlUi initialisation.
 	// RmlUi initialisation.
-	Rml::Core::SetRenderInterface(&opengl_renderer);
-	opengl_renderer.SetViewport(width, height);
+	Rml::Core::SetRenderInterface(opengl_renderer);
+	opengl_renderer->SetViewport(width, height);
 
 
-	ShellSystemInterface system_interface;
-	Rml::Core::SetSystemInterface(&system_interface);
+	Rml::Core::SetSystemInterface(std::make_shared<ShellSystemInterface>());
 
 
 	Rml::Core::Initialise();
 	Rml::Core::Initialise();
 
 

+ 6 - 7
Samples/basic/bitmapfont/src/main.cpp

@@ -66,11 +66,11 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
         AllocConsole();
         AllocConsole();
 #endif
 #endif
 
 
-        int window_width = 1024;
-        int window_height = 768;
+    int window_width = 1024;
+    int window_height = 768;
 
 
-	ShellRenderInterfaceOpenGL opengl_renderer;
-	shell_renderer = &opengl_renderer;
+	auto opengl_renderer = std::make_shared<ShellRenderInterfaceOpenGL>();
+	shell_renderer = opengl_renderer.get();
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	if (!Shell::Initialise() ||
 	if (!Shell::Initialise() ||
@@ -81,11 +81,10 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	}
 	}
 
 
 	// RmlUi initialisation.
 	// RmlUi initialisation.
-	Rml::Core::SetRenderInterface(&opengl_renderer);
+	Rml::Core::SetRenderInterface(opengl_renderer);
 	shell_renderer->SetViewport(window_width, window_height);
 	shell_renderer->SetViewport(window_width, window_height);
 
 
-	ShellSystemInterface system_interface;
-	Rml::Core::SetSystemInterface(&system_interface);
+	Rml::Core::SetSystemInterface(std::make_shared<ShellSystemInterface>());
 
 
 	Rml::Core::Initialise();
 	Rml::Core::Initialise();
 
 

+ 5 - 7
Samples/basic/customlog/src/main.cpp

@@ -70,8 +70,8 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	int window_width = 1024;
 	int window_width = 1024;
 	int window_height = 768;
 	int window_height = 768;
 
 
-	ShellRenderInterfaceOpenGL opengl_renderer;
-	shell_renderer = &opengl_renderer;
+	auto opengl_renderer = std::make_shared<ShellRenderInterfaceOpenGL>();
+	shell_renderer = opengl_renderer.get();
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	if (!Shell::Initialise() ||
 	if (!Shell::Initialise() ||
@@ -82,13 +82,11 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	}
 	}
 
 
 	// RmlUi initialisation.
 	// RmlUi initialisation.
-	Rml::Core::SetRenderInterface(&opengl_renderer);
-	opengl_renderer.SetViewport(window_width, window_height);
-
+	Rml::Core::SetRenderInterface(opengl_renderer);
+	opengl_renderer->SetViewport(window_width, window_height);
 
 
 	// Initialise our system interface to write the log messages to file.
 	// Initialise our system interface to write the log messages to file.
-	SystemInterface system_interface;
-	Rml::Core::SetSystemInterface(&system_interface);
+	Rml::Core::SetSystemInterface(std::make_shared<ShellSystemInterface>());
 
 
 	Rml::Core::Initialise();
 	Rml::Core::Initialise();
 
 

+ 7 - 8
Samples/basic/drag/src/main.cpp

@@ -73,11 +73,11 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
         AllocConsole();
         AllocConsole();
 #endif
 #endif
 
 
-        int window_width = 1024;
-        int window_height = 768;
+    int window_width = 1024;
+    int window_height = 768;
 
 
-	ShellRenderInterfaceOpenGL opengl_renderer;
-	shell_renderer = &opengl_renderer;
+	auto opengl_renderer = std::make_shared<ShellRenderInterfaceOpenGL>();
+	shell_renderer = opengl_renderer.get();
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	if (!Shell::Initialise() ||
 	if (!Shell::Initialise() ||
@@ -88,11 +88,10 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	}
 	}
 
 
 	// RmlUi initialisation.
 	// RmlUi initialisation.
-	Rml::Core::SetRenderInterface(&opengl_renderer);
-	opengl_renderer.SetViewport(window_width, window_height);
+	Rml::Core::SetRenderInterface(opengl_renderer);
+	opengl_renderer->SetViewport(window_width, window_height);
 
 
-	ShellSystemInterface system_interface;
-	Rml::Core::SetSystemInterface(&system_interface);
+	Rml::Core::SetSystemInterface(std::make_shared<ShellSystemInterface>());
 
 
 	Rml::Core::Initialise();
 	Rml::Core::Initialise();
 
 

+ 6 - 7
Samples/basic/loaddocument/src/main.cpp

@@ -66,11 +66,11 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
         AllocConsole();
         AllocConsole();
 #endif
 #endif
 
 
-        int window_width = 1024;
-        int window_height = 768;
+    int window_width = 1024;
+    int window_height = 768;
 
 
-	ShellRenderInterfaceOpenGL opengl_renderer;
-	shell_renderer = &opengl_renderer;
+	auto opengl_renderer = std::make_shared<ShellRenderInterfaceOpenGL>();
+	shell_renderer = opengl_renderer.get();
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	if (!Shell::Initialise() ||
 	if (!Shell::Initialise() ||
@@ -81,11 +81,10 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	}
 	}
 
 
 	// RmlUi initialisation.
 	// RmlUi initialisation.
-	Rml::Core::SetRenderInterface(&opengl_renderer);
+	Rml::Core::SetRenderInterface(opengl_renderer);
 	shell_renderer->SetViewport(window_width, window_height);
 	shell_renderer->SetViewport(window_width, window_height);
 
 
-	ShellSystemInterface system_interface;
-	Rml::Core::SetSystemInterface(&system_interface);
+	Rml::Core::SetSystemInterface(std::make_shared<ShellSystemInterface>());
 
 
 	Rml::Core::Initialise();
 	Rml::Core::Initialise();
 
 

+ 6 - 6
Samples/basic/sdl2/src/RenderInterfaceSDL2.h

@@ -44,19 +44,19 @@ public:
 	RmlUiSDL2Renderer(SDL_Renderer* renderer, SDL_Window* screen);
 	RmlUiSDL2Renderer(SDL_Renderer* renderer, SDL_Window* screen);
 
 
 	/// Called by RmlUi when it wants to render geometry that it does not wish to optimise.
 	/// Called by RmlUi when it wants to render geometry that it does not wish to optimise.
-	virtual void RenderGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture, const Rml::Core::Vector2f& translation);
+	void RenderGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture, const Rml::Core::Vector2f& translation) override;
 
 
 	/// Called by RmlUi when it wants to enable or disable scissoring to clip content.
 	/// Called by RmlUi when it wants to enable or disable scissoring to clip content.
-	virtual void EnableScissorRegion(bool enable);
+	void EnableScissorRegion(bool enable) override;
 	/// Called by RmlUi when it wants to change the scissor region.
 	/// Called by RmlUi when it wants to change the scissor region.
-	virtual void SetScissorRegion(int x, int y, int width, int height);
+	void SetScissorRegion(int x, int y, int width, int height) override;
 
 
 	/// Called by RmlUi when a texture is required by the library.
 	/// Called by RmlUi when a texture is required by the library.
-	virtual bool LoadTexture(Rml::Core::TextureHandle& texture_handle, Rml::Core::Vector2i& texture_dimensions, const Rml::Core::String& source);
+	bool LoadTexture(Rml::Core::TextureHandle& texture_handle, Rml::Core::Vector2i& texture_dimensions, const Rml::Core::String& source) override;
 	/// Called by RmlUi when a texture is required to be built from an internally-generated sequence of pixels.
 	/// Called by RmlUi when a texture is required to be built from an internally-generated sequence of pixels.
-	virtual bool GenerateTexture(Rml::Core::TextureHandle& texture_handle, const Rml::Core::byte* source, const Rml::Core::Vector2i& source_dimensions);
+	bool GenerateTexture(Rml::Core::TextureHandle& texture_handle, const Rml::Core::byte* source, const Rml::Core::Vector2i& source_dimensions) override;
 	/// Called by RmlUi when a loaded texture is no longer required.
 	/// Called by RmlUi when a loaded texture is no longer required.
-	virtual void ReleaseTexture(Rml::Core::TextureHandle texture_handle);
+	void ReleaseTexture(Rml::Core::TextureHandle texture_handle) override;
 
 
 private:
 private:
     SDL_Renderer* mRenderer;
     SDL_Renderer* mRenderer;

+ 3 - 2
Samples/basic/sdl2/src/SystemInterfaceSDL2.h

@@ -39,7 +39,8 @@ public:
     Rml::Core::Input::KeyIdentifier TranslateKey(SDL_Keycode sdlkey);
     Rml::Core::Input::KeyIdentifier TranslateKey(SDL_Keycode sdlkey);
     int TranslateMouseButton(Uint8 button);
     int TranslateMouseButton(Uint8 button);
 	int GetKeyModifiers();
 	int GetKeyModifiers();
-	double GetElapsedTime();
-    bool LogMessage(Rml::Core::Log::Type type, const Rml::Core::String& message);
+	
+	double GetElapsedTime() override;
+    bool LogMessage(Rml::Core::Log::Type type, const Rml::Core::String& message) override;
 };
 };
 #endif
 #endif

+ 11 - 11
Samples/basic/sdl2/src/main.cpp

@@ -76,15 +76,15 @@ int main(int argc, char **argv)
     glLoadIdentity();
     glLoadIdentity();
     glOrtho(0, window_width, window_height, 0, 0, 1);
     glOrtho(0, window_width, window_height, 0, 0, 1);
  
  
-	RmlUiSDL2Renderer Renderer(renderer, screen);
-	RmlUiSDL2SystemInterface SystemInterface;
+	auto Renderer = std::make_shared<RmlUiSDL2Renderer>(renderer, screen);
+	auto SystemInterface = std::make_shared<RmlUiSDL2SystemInterface>();
 	
 	
 	Rml::Core::String root = Shell::FindSamplesRoot();
 	Rml::Core::String root = Shell::FindSamplesRoot();
-	ShellFileInterface FileInterface(root);
+	auto FileInterface = std::make_shared<ShellFileInterface>(root);
 
 
-	Rml::Core::SetFileInterface(&FileInterface);
-	Rml::Core::SetRenderInterface(&Renderer);
-    Rml::Core::SetSystemInterface(&SystemInterface);
+	Rml::Core::SetFileInterface(FileInterface);
+	Rml::Core::SetRenderInterface(Renderer);
+    Rml::Core::SetSystemInterface(SystemInterface);
 
 
 	if(!Rml::Core::Initialise())
 	if(!Rml::Core::Initialise())
 		return 1;
 		return 1;
@@ -132,18 +132,18 @@ int main(int argc, char **argv)
                     break;
                     break;
 
 
                 case SDL_MOUSEMOTION:
                 case SDL_MOUSEMOTION:
-                    Context->ProcessMouseMove(event.motion.x, event.motion.y, SystemInterface.GetKeyModifiers());
+                    Context->ProcessMouseMove(event.motion.x, event.motion.y, SystemInterface->GetKeyModifiers());
                     break;
                     break;
                 case SDL_MOUSEBUTTONDOWN:
                 case SDL_MOUSEBUTTONDOWN:
-                    Context->ProcessMouseButtonDown(SystemInterface.TranslateMouseButton(event.button.button), SystemInterface.GetKeyModifiers());
+                    Context->ProcessMouseButtonDown(SystemInterface->TranslateMouseButton(event.button.button), SystemInterface->GetKeyModifiers());
                     break;
                     break;
 
 
                 case SDL_MOUSEBUTTONUP:
                 case SDL_MOUSEBUTTONUP:
-                    Context->ProcessMouseButtonUp(SystemInterface.TranslateMouseButton(event.button.button), SystemInterface.GetKeyModifiers());
+                    Context->ProcessMouseButtonUp(SystemInterface->TranslateMouseButton(event.button.button), SystemInterface->GetKeyModifiers());
                     break;
                     break;
 
 
                 case SDL_MOUSEWHEEL:
                 case SDL_MOUSEWHEEL:
-                    Context->ProcessMouseWheel(event.wheel.y, SystemInterface.GetKeyModifiers());
+                    Context->ProcessMouseWheel(event.wheel.y, SystemInterface->GetKeyModifiers());
                     break;
                     break;
 
 
                 case SDL_KEYDOWN:
                 case SDL_KEYDOWN:
@@ -155,7 +155,7 @@ int main(int argc, char **argv)
                         break;
                         break;
                     }
                     }
                     
                     
-                    Context->ProcessKeyDown(SystemInterface.TranslateKey(event.key.keysym.sym), SystemInterface.GetKeyModifiers());
+                    Context->ProcessKeyDown(SystemInterface->TranslateKey(event.key.keysym.sym), SystemInterface->GetKeyModifiers());
                     break;
                     break;
                 }
                 }
                 
                 

+ 9 - 9
Samples/basic/sfml2/src/RenderInterfaceSFML.h

@@ -61,27 +61,27 @@ public:
 	void Resize();
 	void Resize();
 
 
 	/// Called by RmlUi when it wants to render geometry that it does not wish to optimise.
 	/// Called by RmlUi when it wants to render geometry that it does not wish to optimise.
-	virtual void RenderGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture, const Rml::Core::Vector2f& translation);
+	void RenderGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture, const Rml::Core::Vector2f& translation) override;
 
 
 	/// Called by RmlUi when it wants to compile geometry it believes will be static for the forseeable future.
 	/// Called by RmlUi when it wants to compile geometry it believes will be static for the forseeable future.
-	virtual Rml::Core::CompiledGeometryHandle CompileGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture);
+	Rml::Core::CompiledGeometryHandle CompileGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture) override;
 
 
 	/// Called by RmlUi when it wants to render application-compiled geometry.
 	/// Called by RmlUi when it wants to render application-compiled geometry.
-	virtual void RenderCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry, const Rml::Core::Vector2f& translation);
+	void RenderCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry, const Rml::Core::Vector2f& translation) override;
 	/// Called by RmlUi when it wants to release application-compiled geometry.
 	/// Called by RmlUi when it wants to release application-compiled geometry.
-	virtual void ReleaseCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry);
+	void ReleaseCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry) override;
 
 
 	/// Called by RmlUi when it wants to enable or disable scissoring to clip content.
 	/// Called by RmlUi when it wants to enable or disable scissoring to clip content.
-	virtual void EnableScissorRegion(bool enable);
+	void EnableScissorRegion(bool enable) override;
 	/// Called by RmlUi when it wants to change the scissor region.
 	/// Called by RmlUi when it wants to change the scissor region.
-	virtual void SetScissorRegion(int x, int y, int width, int height);
+	void SetScissorRegion(int x, int y, int width, int height) override;
 
 
 	/// Called by RmlUi when a texture is required by the library.
 	/// Called by RmlUi when a texture is required by the library.
-	virtual bool LoadTexture(Rml::Core::TextureHandle& texture_handle, Rml::Core::Vector2i& texture_dimensions, const Rml::Core::String& source);
+	bool LoadTexture(Rml::Core::TextureHandle& texture_handle, Rml::Core::Vector2i& texture_dimensions, const Rml::Core::String& source) override;
 	/// Called by RmlUi when a texture is required to be built from an internally-generated sequence of pixels.
 	/// Called by RmlUi when a texture is required to be built from an internally-generated sequence of pixels.
-	virtual bool GenerateTexture(Rml::Core::TextureHandle& texture_handle, const Rml::Core::byte* source, const Rml::Core::Vector2i& source_dimensions);
+	bool GenerateTexture(Rml::Core::TextureHandle& texture_handle, const Rml::Core::byte* source, const Rml::Core::Vector2i& source_dimensions) override;
 	/// Called by RmlUi when a loaded texture is no longer required.
 	/// Called by RmlUi when a loaded texture is no longer required.
-	virtual void ReleaseTexture(Rml::Core::TextureHandle texture_handle);
+	void ReleaseTexture(Rml::Core::TextureHandle texture_handle) override;
 
 
 private:
 private:
 	sf::RenderWindow *MyWindow;
 	sf::RenderWindow *MyWindow;

+ 3 - 3
Samples/basic/sfml2/src/SystemInterfaceSFML.h

@@ -35,11 +35,11 @@
 class RmlUiSFMLSystemInterface : public Rml::Core::SystemInterface
 class RmlUiSFMLSystemInterface : public Rml::Core::SystemInterface
 {
 {
 public:
 public:
-
 	Rml::Core::Input::KeyIdentifier TranslateKey(sf::Keyboard::Key Key);
 	Rml::Core::Input::KeyIdentifier TranslateKey(sf::Keyboard::Key Key);
 	int GetKeyModifiers(sf::Window *Window);
 	int GetKeyModifiers(sf::Window *Window);
-	double GetElapsedTime();
-	bool LogMessage(Rml::Core::Log::Type type, const Rml::Core::String& message);
+	
+	double GetElapsedTime() override;
+	bool LogMessage(Rml::Core::Log::Type type, const Rml::Core::String& message) override;
 
 
 private:
 private:
 	sf::Clock timer;
 	sf::Clock timer;

+ 14 - 14
Samples/basic/sfml2/src/main.cpp

@@ -68,22 +68,22 @@ int main(int argc, char **argv)
 	fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
 	fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
 #endif
 #endif
 
 
-	RmlUiSFMLRenderer Renderer;
-	RmlUiSFMLSystemInterface SystemInterface;
+	auto Renderer = std::make_shared<RmlUiSFMLRenderer>();
+	auto SystemInterface = std::make_shared<RmlUiSFMLSystemInterface>;
 
 
 	// NOTE: if fonts and rml are not found you'll probably have to adjust
 	// NOTE: if fonts and rml are not found you'll probably have to adjust
 	// the path information in the string
 	// the path information in the string
 	Rml::Core::String root = Shell::FindSamplesRoot();
 	Rml::Core::String root = Shell::FindSamplesRoot();
-	ShellFileInterface FileInterface(root);
+	auto FileInterface = std::make_shared<ShellFileInterface>(root);
 
 
 	if(!MyWindow.isOpen())
 	if(!MyWindow.isOpen())
 		return 1;
 		return 1;
 
 
 	Renderer.SetWindow(&MyWindow);
 	Renderer.SetWindow(&MyWindow);
 
 
-	Rml::Core::SetFileInterface(&FileInterface);
-	Rml::Core::SetRenderInterface(&Renderer);
-	Rml::Core::SetSystemInterface(&SystemInterface);
+	Rml::Core::SetFileInterface(FileInterface);
+	Rml::Core::SetRenderInterface(Renderer);
+	Rml::Core::SetSystemInterface(SystemInterface);
 
 
 
 
 	if(!Rml::Core::Initialise())
 	if(!Rml::Core::Initialise())
@@ -128,27 +128,27 @@ int main(int argc, char **argv)
 				break;
 				break;
 			case sf::Event::MouseMoved:
 			case sf::Event::MouseMoved:
 				Context->ProcessMouseMove(event.mouseMove.x, event.mouseMove.y,
 				Context->ProcessMouseMove(event.mouseMove.x, event.mouseMove.y,
-					SystemInterface.GetKeyModifiers(&MyWindow));
+					SystemInterface->GetKeyModifiers(&MyWindow));
 				break;
 				break;
 			case sf::Event::MouseButtonPressed:
 			case sf::Event::MouseButtonPressed:
 				Context->ProcessMouseButtonDown(event.mouseButton.button,
 				Context->ProcessMouseButtonDown(event.mouseButton.button,
-					SystemInterface.GetKeyModifiers(&MyWindow));
+					SystemInterface->GetKeyModifiers(&MyWindow));
 				break;
 				break;
 			case sf::Event::MouseButtonReleased:
 			case sf::Event::MouseButtonReleased:
 				Context->ProcessMouseButtonUp(event.mouseButton.button,
 				Context->ProcessMouseButtonUp(event.mouseButton.button,
-					SystemInterface.GetKeyModifiers(&MyWindow));
+					SystemInterface->GetKeyModifiers(&MyWindow));
 				break;
 				break;
 			case sf::Event::MouseWheelMoved:
 			case sf::Event::MouseWheelMoved:
 				Context->ProcessMouseWheel(-event.mouseWheel.delta,
 				Context->ProcessMouseWheel(-event.mouseWheel.delta,
-					SystemInterface.GetKeyModifiers(&MyWindow));
+					SystemInterface->GetKeyModifiers(&MyWindow));
 				break;
 				break;
 			case sf::Event::TextEntered:
 			case sf::Event::TextEntered:
 				if (event.text.unicode > 32)
 				if (event.text.unicode > 32)
 					Context->ProcessTextInput(event.text.unicode);
 					Context->ProcessTextInput(event.text.unicode);
 				break;
 				break;
 			case sf::Event::KeyPressed:
 			case sf::Event::KeyPressed:
-				Context->ProcessKeyDown(SystemInterface.TranslateKey(event.key.code),
-					SystemInterface.GetKeyModifiers(&MyWindow));
+				Context->ProcessKeyDown(SystemInterface->TranslateKey(event.key.code),
+					SystemInterface->GetKeyModifiers(&MyWindow));
 				break;
 				break;
 			case sf::Event::KeyReleased:
 			case sf::Event::KeyReleased:
 				if(event.key.code == sf::Keyboard::F8)
 				if(event.key.code == sf::Keyboard::F8)
@@ -160,8 +160,8 @@ int main(int argc, char **argv)
 					MyWindow.close();
 					MyWindow.close();
 				}
 				}
 
 
-				Context->ProcessKeyUp(SystemInterface.TranslateKey(event.key.code),
-					SystemInterface.GetKeyModifiers(&MyWindow));
+				Context->ProcessKeyUp(SystemInterface->TranslateKey(event.key.code),
+					SystemInterface->GetKeyModifiers(&MyWindow));
 				break;
 				break;
 			case sf::Event::Closed:
 			case sf::Event::Closed:
 				MyWindow.close();
 				MyWindow.close();

+ 5 - 5
Samples/basic/transform/src/main.cpp

@@ -134,8 +134,8 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	RMLUI_UNUSED(argv);
 	RMLUI_UNUSED(argv);
 #endif
 #endif
 
 
-	ShellRenderInterfaceOpenGL opengl_renderer;
-	shell_renderer = &opengl_renderer;
+	auto opengl_renderer = std::make_shared<ShellRenderInterfaceOpenGL>();
+	shell_renderer = opengl_renderer.get();
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	if (!Shell::Initialise() ||
 	if (!Shell::Initialise() ||
@@ -146,11 +146,11 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	}
 	}
 
 
 	// RmlUi initialisation.
 	// RmlUi initialisation.
-	Rml::Core::SetRenderInterface(&opengl_renderer);
-	opengl_renderer.SetViewport(1024,768);
+	Rml::Core::SetRenderInterface(opengl_renderer);
+	opengl_renderer->SetViewport(1024,768);
 
 
 	ShellSystemInterface system_interface;
 	ShellSystemInterface system_interface;
-	Rml::Core::SetSystemInterface(&system_interface);
+	Rml::Core::SetSystemInterface(std::make_shared<ShellSystemInterface>());
 
 
 	Rml::Core::Initialise();
 	Rml::Core::Initialise();
 
 

+ 7 - 8
Samples/basic/treeview/src/main.cpp

@@ -69,11 +69,11 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
         AllocConsole();
         AllocConsole();
 #endif
 #endif
 
 
-        int window_width = 1024;
-        int window_height = 768;
+	int window_width = 1024;
+	int window_height = 768;
 
 
-	ShellRenderInterfaceOpenGL opengl_renderer;
-	shell_renderer = &opengl_renderer;
+	auto opengl_renderer = std::make_shared<ShellRenderInterfaceOpenGL>();
+	shell_renderer = opengl_renderer.get();
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	if (!Shell::Initialise() ||
 	if (!Shell::Initialise() ||
@@ -84,11 +84,10 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	}
 	}
 
 
 	// RmlUi initialisation.
 	// RmlUi initialisation.
-	opengl_renderer.SetViewport(window_width, window_height);
-	Rml::Core::SetRenderInterface(&opengl_renderer);
+	Rml::Core::SetRenderInterface(opengl_renderer);
+	opengl_renderer->SetViewport(window_width, window_height);
 
 
-	ShellSystemInterface system_interface;
-	Rml::Core::SetSystemInterface(&system_interface);
+	Rml::Core::SetSystemInterface(std::make_shared<ShellSystemInterface>());
 
 
 	Rml::Core::Initialise();
 	Rml::Core::Initialise();
 
 

+ 5 - 6
Samples/invaders/src/main.cpp

@@ -81,8 +81,8 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	int window_width = 1024;
 	int window_width = 1024;
 	int window_height = 768;
 	int window_height = 768;
 
 
-	ShellRenderInterfaceOpenGL opengl_renderer;
-	shell_renderer = &opengl_renderer;
+	auto opengl_renderer = std::make_shared<ShellRenderInterfaceOpenGL>();
+	shell_renderer = opengl_renderer.get();
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	if (!Shell::Initialise() ||
 	if (!Shell::Initialise() ||
@@ -93,11 +93,10 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	}
 	}
 
 
 	// RmlUi initialisation.
 	// RmlUi initialisation.
-	Rml::Core::SetRenderInterface(&opengl_renderer);
-	opengl_renderer.SetViewport(window_width, window_height);
+	Rml::Core::SetRenderInterface(opengl_renderer);
+	opengl_renderer->SetViewport(window_width, window_height);
 
 
-	ShellSystemInterface system_interface;
-	Rml::Core::SetSystemInterface(&system_interface);
+	Rml::Core::SetSystemInterface(std::make_shared<ShellSystemInterface>());
 
 
 	Rml::Core::Initialise();
 	Rml::Core::Initialise();
 	// Initialise the RmlUi Controls library.
 	// Initialise the RmlUi Controls library.

+ 5 - 5
Samples/shell/include/ShellFileInterface.h

@@ -44,19 +44,19 @@ public:
 	virtual ~ShellFileInterface();
 	virtual ~ShellFileInterface();
 
 
 	/// Opens a file.		
 	/// Opens a file.		
-	virtual Rml::Core::FileHandle Open(const Rml::Core::String& path);
+	Rml::Core::FileHandle Open(const Rml::Core::String& path) override;
 
 
 	/// Closes a previously opened file.		
 	/// Closes a previously opened file.		
-	virtual void Close(Rml::Core::FileHandle file);
+	void Close(Rml::Core::FileHandle file) override;
 
 
 	/// Reads data from a previously opened file.		
 	/// Reads data from a previously opened file.		
-	virtual size_t Read(void* buffer, size_t size, Rml::Core::FileHandle file);
+	size_t Read(void* buffer, size_t size, Rml::Core::FileHandle file) override;
 
 
 	/// Seeks to a point in a previously opened file.		
 	/// Seeks to a point in a previously opened file.		
-	virtual bool Seek(Rml::Core::FileHandle file, long offset, int origin);
+	bool Seek(Rml::Core::FileHandle file, long offset, int origin) override;
 
 
 	/// Returns the current position of the file pointer.		
 	/// Returns the current position of the file pointer.		
-	virtual size_t Tell(Rml::Core::FileHandle file);
+	size_t Tell(Rml::Core::FileHandle file) override;
 
 
 private:
 private:
 	Rml::Core::String root;
 	Rml::Core::String root;

+ 18 - 19
Samples/shell/include/ShellRenderInterfaceOpenGL.h

@@ -43,42 +43,41 @@ public:
 	ShellRenderInterfaceOpenGL();
 	ShellRenderInterfaceOpenGL();
 
 
 	/// Called by RmlUi when it wants to render geometry that it does not wish to optimise.
 	/// Called by RmlUi when it wants to render geometry that it does not wish to optimise.
-	virtual void RenderGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture, const Rml::Core::Vector2f& translation);
+	void RenderGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture, const Rml::Core::Vector2f& translation) override;
 
 
 	/// Called by RmlUi when it wants to compile geometry it believes will be static for the forseeable future.
 	/// Called by RmlUi when it wants to compile geometry it believes will be static for the forseeable future.
-	virtual Rml::Core::CompiledGeometryHandle CompileGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture);
+	Rml::Core::CompiledGeometryHandle CompileGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture) override;
 
 
 	/// Called by RmlUi when it wants to render application-compiled geometry.
 	/// Called by RmlUi when it wants to render application-compiled geometry.
-	virtual void RenderCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry, const Rml::Core::Vector2f& translation);
+	void RenderCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry, const Rml::Core::Vector2f& translation) override;
 	/// Called by RmlUi when it wants to release application-compiled geometry.
 	/// Called by RmlUi when it wants to release application-compiled geometry.
-	virtual void ReleaseCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry);
+	void ReleaseCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry) override;
 
 
 	/// Called by RmlUi when it wants to enable or disable scissoring to clip content.
 	/// Called by RmlUi when it wants to enable or disable scissoring to clip content.
-	virtual void EnableScissorRegion(bool enable);
+	void EnableScissorRegion(bool enable) override;
 	/// Called by RmlUi when it wants to change the scissor region.
 	/// Called by RmlUi when it wants to change the scissor region.
-	virtual void SetScissorRegion(int x, int y, int width, int height);
+	void SetScissorRegion(int x, int y, int width, int height) override;
 
 
 	/// Called by RmlUi when a texture is required by the library.
 	/// Called by RmlUi when a texture is required by the library.
-	virtual bool LoadTexture(Rml::Core::TextureHandle& texture_handle, Rml::Core::Vector2i& texture_dimensions, const Rml::Core::String& source);
+	bool LoadTexture(Rml::Core::TextureHandle& texture_handle, Rml::Core::Vector2i& texture_dimensions, const Rml::Core::String& source) override;
 	/// Called by RmlUi when a texture is required to be built from an internally-generated sequence of pixels.
 	/// Called by RmlUi when a texture is required to be built from an internally-generated sequence of pixels.
-	virtual bool GenerateTexture(Rml::Core::TextureHandle& texture_handle, const Rml::Core::byte* source, const Rml::Core::Vector2i& source_dimensions);
+	bool GenerateTexture(Rml::Core::TextureHandle& texture_handle, const Rml::Core::byte* source, const Rml::Core::Vector2i& source_dimensions) override;
 	/// Called by RmlUi when a loaded texture is no longer required.
 	/// Called by RmlUi when a loaded texture is no longer required.
-	virtual void ReleaseTexture(Rml::Core::TextureHandle texture_handle);
+	void ReleaseTexture(Rml::Core::TextureHandle texture_handle) override;
 
 
 	/// Called by RmlUi when it wants to set the current transform matrix to a new matrix.
 	/// Called by RmlUi when it wants to set the current transform matrix to a new matrix.
-	virtual void PushTransform(const Rml::Core::RowMajorMatrix4f& transform);
-	virtual void PushTransform(const Rml::Core::ColumnMajorMatrix4f& transform);
+	void PushTransform(const Rml::Core::Matrix4f& transform) override;
 
 
 	/// Called by RmlUi when it wants to revert the latest transform change.
 	/// Called by RmlUi when it wants to revert the latest transform change.
-	virtual void PopTransform(const Rml::Core::Matrix4f& transform);
+	void PopTransform(const Rml::Core::Matrix4f& transform) override;
 
 
-// ShellRenderInterfaceExtensions
-	virtual void SetViewport(int width, int height);
-	virtual void SetContext(void *context);
-	virtual bool AttachToNative(void *nativeWindow);
-	virtual void DetachFromNative(void);
-	virtual void PrepareRenderBuffer(void);
-	virtual void PresentRenderBuffer(void);
+	// ShellRenderInterfaceExtensions
+	void SetViewport(int width, int height) override;
+	void SetContext(void *context) override;
+	bool AttachToNative(void *nativeWindow) override;
+	void DetachFromNative(void) override;
+	void PrepareRenderBuffer(void) override;
+	void PresentRenderBuffer(void) override;
 
 
 protected:
 protected:
 	int m_width;
 	int m_width;

+ 4 - 4
Samples/shell/include/ShellSystemInterface.h

@@ -41,19 +41,19 @@ class ShellSystemInterface : public Rml::Core::SystemInterface
 public:
 public:
 	/// Get the number of seconds elapsed since the start of the application
 	/// Get the number of seconds elapsed since the start of the application
 	/// @returns Seconds elapsed
 	/// @returns Seconds elapsed
-	virtual double GetElapsedTime();
+	double GetElapsedTime() override;
 
 
 	/// Set mouse cursor.
 	/// Set mouse cursor.
 	/// @param[in] cursor_name Cursor name to activate.
 	/// @param[in] cursor_name Cursor name to activate.
-	virtual void SetMouseCursor(const Rml::Core::String& cursor_name);
+	void SetMouseCursor(const Rml::Core::String& cursor_name) override;
 
 
 	/// Set clipboard text.
 	/// Set clipboard text.
 	/// @param[in] text Text to apply to clipboard.
 	/// @param[in] text Text to apply to clipboard.
-	virtual void SetClipboardText(const Rml::Core::WString& text);
+	void SetClipboardText(const Rml::Core::WString& text) override;
 
 
 	/// Get clipboard text.
 	/// Get clipboard text.
 	/// @param[out] text Retrieved text from clipboard.
 	/// @param[out] text Retrieved text from clipboard.
-	virtual void GetClipboardText(Rml::Core::WString& text);
+	void GetClipboardText(Rml::Core::WString& text) override;
 };
 };
 
 
 #endif
 #endif

+ 8 - 8
Samples/shell/src/ShellRenderInterfaceOpenGL.cpp

@@ -29,6 +29,7 @@
 #include <ShellRenderInterfaceExtensions.h>
 #include <ShellRenderInterfaceExtensions.h>
 #include <ShellRenderInterfaceOpenGL.h>
 #include <ShellRenderInterfaceOpenGL.h>
 #include <RmlUi/Core.h>
 #include <RmlUi/Core.h>
+#include <type_traits>
 
 
 #define GL_CLAMP_TO_EDGE 0x812F
 #define GL_CLAMP_TO_EDGE 0x812F
 
 
@@ -281,16 +282,15 @@ void ShellRenderInterfaceOpenGL::ReleaseTexture(Rml::Core::TextureHandle texture
 }
 }
 
 
 // Called by RmlUi when it wants to set the current transform matrix to a new matrix.
 // Called by RmlUi when it wants to set the current transform matrix to a new matrix.
-void ShellRenderInterfaceOpenGL::PushTransform(const Rml::Core::RowMajorMatrix4f& transform)
+void ShellRenderInterfaceOpenGL::PushTransform(const Rml::Core::Matrix4f& transform)
 {
 {
 	glPushMatrix();
 	glPushMatrix();
-	glLoadMatrixf(transform.Transpose().data());
-	++m_transforms;
-}
-void ShellRenderInterfaceOpenGL::PushTransform(const Rml::Core::ColumnMajorMatrix4f& transform)
-{
-	glPushMatrix();
-	glLoadMatrixf(transform.data());
+
+	if(std::is_same<Rml::Core::Matrix4f, Rml::Core::ColumnMajorMatrix4f>::value)
+		glLoadMatrixf(transform.data());
+	else if (std::is_same<Rml::Core::Matrix4f, Rml::Core::RowMajorMatrix4f>::value)
+		glLoadMatrixf(transform.Transpose().data());
+
 	++m_transforms;
 	++m_transforms;
 }
 }
 
 

+ 3 - 4
Samples/shell/src/macosx/ShellMacOSX.cpp

@@ -57,7 +57,7 @@ static WindowRef window;
 static timeval start_time;
 static timeval start_time;
 static Rml::Core::WString clipboard_text;
 static Rml::Core::WString clipboard_text;
 
 
-ShellFileInterface* file_interface = NULL;
+static Rml::Core::SharedPtr<ShellFileInterface> file_interface;
 
 
 static void IdleTimerCallback(EventLoopTimerRef timer, EventLoopIdleTimerMessage inState, void* p);
 static void IdleTimerCallback(EventLoopTimerRef timer, EventLoopIdleTimerMessage inState, void* p);
 static OSStatus EventHandler(EventHandlerCallRef next_handler, EventRef event, void* p);
 static OSStatus EventHandler(EventHandlerCallRef next_handler, EventRef event, void* p);
@@ -70,7 +70,7 @@ bool Shell::Initialise()
 
 
 	Rml::Core::String root = FindSamplesRoot();
 	Rml::Core::String root = FindSamplesRoot();
 
 
-	file_interface = new ShellFileInterface(root);
+	file_interface = std::make_shared<ShellFileInterface>(root);
 	Rml::Core::SetFileInterface(file_interface);
 	Rml::Core::SetFileInterface(file_interface);
 
 
 	return true;
 	return true;
@@ -78,8 +78,7 @@ bool Shell::Initialise()
 
 
 void Shell::Shutdown()
 void Shell::Shutdown()
 {
 {
-	delete file_interface;
-	file_interface = NULL;
+	file_interface.reset();
 }
 }
 
 
 Rml::Core::String Shell::FindSamplesRoot()
 Rml::Core::String Shell::FindSamplesRoot()

+ 3 - 4
Samples/shell/src/win32/ShellWin32.cpp

@@ -45,7 +45,7 @@ static HINSTANCE instance_handle = NULL;
 static double time_frequency;
 static double time_frequency;
 static LARGE_INTEGER time_startup;
 static LARGE_INTEGER time_startup;
 
 
-static ShellFileInterface* file_interface = NULL;
+static Rml::Core::SharedPtr<ShellFileInterface> file_interface;
 
 
 static HCURSOR cursor_default = NULL;
 static HCURSOR cursor_default = NULL;
 static HCURSOR cursor_move = NULL;
 static HCURSOR cursor_move = NULL;
@@ -72,7 +72,7 @@ bool Shell::Initialise()
 
 
 	Rml::Core::String root = FindSamplesRoot();
 	Rml::Core::String root = FindSamplesRoot();
 	
 	
-	file_interface = new ShellFileInterface(root);
+	file_interface = std::make_shared<ShellFileInterface>(root);
 	Rml::Core::SetFileInterface(file_interface);
 	Rml::Core::SetFileInterface(file_interface);
 
 
 	return true;
 	return true;
@@ -82,8 +82,7 @@ void Shell::Shutdown()
 {
 {
 	InputWin32::Shutdown();
 	InputWin32::Shutdown();
 
 
-	delete file_interface;
-	file_interface = NULL;
+	file_interface.reset();
 }
 }
 
 
 Rml::Core::String Shell::FindSamplesRoot()
 Rml::Core::String Shell::FindSamplesRoot()

+ 3 - 4
Samples/shell/src/x11/ShellX11.cpp

@@ -48,7 +48,7 @@ static int screen = -1;
 static timeval start_time;
 static timeval start_time;
 static Rml::Core::WString clipboard_text;
 static Rml::Core::WString clipboard_text;
 
 
-static ShellFileInterface* file_interface = NULL;
+static Rml::Core::SharedPtr<ShellFileInterface> file_interface;
 
 
 static bool isDirectory(const Rml::Core::String &path)
 static bool isDirectory(const Rml::Core::String &path)
 {
 {
@@ -63,7 +63,7 @@ bool Shell::Initialise()
 
 
 	Rml::Core::String root = FindSamplesRoot();
 	Rml::Core::String root = FindSamplesRoot();
 
 
-	file_interface = new ShellFileInterface(root);
+	file_interface = std::make_shared<ShellFileInterface>(root);
 	Rml::Core::SetFileInterface(file_interface);
 	Rml::Core::SetFileInterface(file_interface);
 
 
 	return true;
 	return true;
@@ -73,8 +73,7 @@ void Shell::Shutdown()
 {
 {
 	InputX11::Shutdown();
 	InputX11::Shutdown();
 
 
-	delete file_interface;
-	file_interface = NULL;
+	file_interface.reset();
 }
 }
 
 
 Rml::Core::String Shell::FindSamplesRoot()
 Rml::Core::String Shell::FindSamplesRoot()

+ 5 - 6
Samples/tutorial/datagrid/src/main.cpp

@@ -52,8 +52,8 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
         AllocConsole();
         AllocConsole();
 #endif
 #endif
 
 
-	ShellRenderInterfaceOpenGL opengl_renderer;
-	shell_renderer = &opengl_renderer;
+	auto opengl_renderer = std::make_shared<ShellRenderInterfaceOpenGL>();
+	shell_renderer = opengl_renderer.get();
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	if (!Shell::Initialise() ||
 	if (!Shell::Initialise() ||
@@ -64,11 +64,10 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	}
 	}
 
 
 	// RmlUi initialisation.
 	// RmlUi initialisation.
-	Rml::Core::SetRenderInterface(&opengl_renderer);
-	opengl_renderer.SetViewport(1024,768);
+	Rml::Core::SetRenderInterface(opengl_renderer);
+	opengl_renderer->SetViewport(1024,768);
 
 
-	ShellSystemInterface system_interface;
-	Rml::Core::SetSystemInterface(&system_interface);
+	Rml::Core::SetSystemInterface(std::make_shared<ShellSystemInterface>());
 
 
 	Rml::Core::Initialise();
 	Rml::Core::Initialise();
 	Rml::Controls::Initialise();
 	Rml::Controls::Initialise();

+ 5 - 6
Samples/tutorial/datagrid_tree/src/main.cpp

@@ -56,8 +56,8 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	int window_width = 1024;
 	int window_width = 1024;
 	int window_height = 768;
 	int window_height = 768;
 
 
-	ShellRenderInterfaceOpenGL opengl_renderer;
-	shell_renderer = &opengl_renderer;
+	auto opengl_renderer = std::make_shared<ShellRenderInterfaceOpenGL>();
+	shell_renderer = opengl_renderer.get();
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	if (!Shell::Initialise() ||
 	if (!Shell::Initialise() ||
@@ -68,11 +68,10 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	}
 	}
 
 
 	// RmlUi initialisation.
 	// RmlUi initialisation.
-	Rml::Core::SetRenderInterface(&opengl_renderer);
-	opengl_renderer.SetViewport(window_width, window_height);
+	Rml::Core::SetRenderInterface(opengl_renderer);
+	opengl_renderer->SetViewport(window_width, window_height);
 
 
-	ShellSystemInterface system_interface;
-	Rml::Core::SetSystemInterface(&system_interface);
+	Rml::Core::SetSystemInterface(std::make_shared<ShellSystemInterface>());
 
 
 	Rml::Core::Initialise();
 	Rml::Core::Initialise();
 	Rml::Controls::Initialise();
 	Rml::Controls::Initialise();

+ 5 - 6
Samples/tutorial/drag/src/main.cpp

@@ -53,8 +53,8 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	int window_width = 1024;
 	int window_width = 1024;
 	int window_height = 768;
 	int window_height = 768;
 
 
-	ShellRenderInterfaceOpenGL opengl_renderer;
-	shell_renderer = &opengl_renderer;
+	auto opengl_renderer = std::make_shared<ShellRenderInterfaceOpenGL>();
+	shell_renderer = opengl_renderer.get();
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	if (!Shell::Initialise() ||
 	if (!Shell::Initialise() ||
@@ -65,11 +65,10 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	}
 	}
 
 
 	// RmlUi initialisation.
 	// RmlUi initialisation.
-	Rml::Core::SetRenderInterface(&opengl_renderer);
-	opengl_renderer.SetViewport(window_width, window_height);
+	Rml::Core::SetRenderInterface(opengl_renderer);
+	opengl_renderer->SetViewport(window_width, window_height);
 
 
-	ShellSystemInterface system_interface;
-	Rml::Core::SetSystemInterface(&system_interface);
+	Rml::Core::SetSystemInterface(std::make_shared<ShellSystemInterface>());
 
 
 	Rml::Core::Initialise();
 	Rml::Core::Initialise();
 
 

+ 5 - 6
Samples/tutorial/template/src/main.cpp

@@ -52,8 +52,8 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	int window_width = 1024;
 	int window_width = 1024;
 	int window_height = 768;
 	int window_height = 768;
 
 
-	ShellRenderInterfaceOpenGL opengl_renderer;
-	shell_renderer = &opengl_renderer;
+	auto opengl_renderer = std::make_shared<ShellRenderInterfaceOpenGL>();
+	shell_renderer = opengl_renderer.get();
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	if (!Shell::Initialise() ||
 	if (!Shell::Initialise() ||
@@ -64,11 +64,10 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 	}
 	}
 
 
 	// RmlUi initialisation.
 	// RmlUi initialisation.
-	Rml::Core::SetRenderInterface(&opengl_renderer);
-	opengl_renderer.SetViewport(window_width, window_height);
+	Rml::Core::SetRenderInterface(opengl_renderer);
+	opengl_renderer->SetViewport(window_width, window_height);
 
 
-	ShellSystemInterface system_interface;
-	Rml::Core::SetSystemInterface(&system_interface);
+	Rml::Core::SetSystemInterface(std::make_shared<ShellSystemInterface>());
 
 
 	Rml::Core::Initialise();
 	Rml::Core::Initialise();
 
 

+ 2 - 3
Source/Core/Context.cpp

@@ -94,8 +94,7 @@ Context::~Context()
 
 
 	instancer.reset();
 	instancer.reset();
 
 
-	if (render_interface)
-		render_interface->RemoveReference();
+	render_interface.reset();
 }
 }
 
 
 // Returns the name of the context.
 // Returns the name of the context.
@@ -775,7 +774,7 @@ void Context::ProcessViewChange(const Matrix4f &view)
 // Gets the context's render interface.
 // Gets the context's render interface.
 RenderInterface* Context::GetRenderInterface() const
 RenderInterface* Context::GetRenderInterface() const
 {
 {
-	return render_interface;
+	return render_interface.get();
 }
 }
 	
 	
 // Gets the current clipping region for the render traversal
 // Gets the current clipping region for the render traversal

+ 25 - 57
Source/Core/Core.cpp

@@ -41,14 +41,12 @@ namespace Rml {
 namespace Core {
 namespace Core {
 
 
 // RmlUi's renderer interface.
 // RmlUi's renderer interface.
-static RenderInterface* render_interface = NULL;
+static SharedPtr<RenderInterface> render_interface = nullptr;
 /// RmlUi's system interface.
 /// RmlUi's system interface.
-static SystemInterface* system_interface = NULL;
+static SharedPtr<SystemInterface> system_interface = nullptr;
 // RmlUi's file I/O interface.
 // RmlUi's file I/O interface.
-FileInterface* file_interface =  NULL;
-#ifndef RMLUI_NO_FILE_INTERFACE_DEFAULT
-static FileInterfaceDefault file_interface_default;
-#endif
+static SharedPtr<FileInterface> file_interface = nullptr;
+
 static bool initialised = false;
 static bool initialised = false;
 
 
 using ContextMap = UnorderedMap< String, UniquePtr<Context> >;
 using ContextMap = UnorderedMap< String, UniquePtr<Context> >;
@@ -62,17 +60,16 @@ static ContextMap contexts;
 bool Initialise()
 bool Initialise()
 {
 {
 	// Check for valid interfaces, or install default interfaces as appropriate.
 	// Check for valid interfaces, or install default interfaces as appropriate.
-	if (system_interface == NULL)
+	if (!system_interface)
 	{	
 	{	
 		Log::Message(Log::LT_ERROR, "No system interface set!");
 		Log::Message(Log::LT_ERROR, "No system interface set!");
 		return false;
 		return false;
 	}
 	}
 
 
-	if (file_interface == NULL)
+	if (!file_interface)
 	{		
 	{		
 #ifndef RMLUI_NO_FILE_INTERFACE_DEFAULT
 #ifndef RMLUI_NO_FILE_INTERFACE_DEFAULT
-		file_interface = &file_interface_default;
-		file_interface->AddReference();
+		file_interface = std::make_shared<FileInterfaceDefault>();
 #else
 #else
 		Log::Message(Log::LT_ERROR, "No file interface set!");
 		Log::Message(Log::LT_ERROR, "No file interface set!");
 		return false;
 		return false;
@@ -121,18 +118,9 @@ void Shutdown()
 
 
 	initialised = false;
 	initialised = false;
 
 
-	if (render_interface != NULL)
-		render_interface->RemoveReference();
-
-	if (file_interface != NULL)
-		file_interface->RemoveReference();
-
-	if (system_interface != NULL)
-		system_interface->RemoveReference();
-	
-	render_interface = NULL;
-	file_interface = NULL;
-	system_interface = NULL;
+	render_interface.reset();
+	file_interface.reset();
+	system_interface.reset();
 }
 }
 
 
 // Returns the version of this RmlUi library.
 // Returns the version of this RmlUi library.
@@ -142,67 +130,48 @@ String GetVersion()
 }
 }
 
 
 // Sets the interface through which all RmlUi messages will be routed.
 // Sets the interface through which all RmlUi messages will be routed.
-void SetSystemInterface(SystemInterface* _system_interface)
+void SetSystemInterface(SharedPtr<SystemInterface> _system_interface)
 {
 {
-	if (system_interface == _system_interface)
-		return;
-
-	if (system_interface != NULL)
-		system_interface->RemoveReference();
-
-	system_interface = _system_interface;
-	if (system_interface != NULL)
-		system_interface->AddReference();
+	system_interface = std::move(_system_interface);
 }
 }
 
 
 // Returns RmlUi's system interface.
 // Returns RmlUi's system interface.
 SystemInterface* GetSystemInterface()
 SystemInterface* GetSystemInterface()
+{
+	return system_interface.get();
+}
+
+SharedPtr<SystemInterface> GetSystemInterfaceSharedPtr()
 {
 {
 	return system_interface;
 	return system_interface;
 }
 }
 
 
 // Sets the interface through which all rendering requests are made.
 // Sets the interface through which all rendering requests are made.
-void SetRenderInterface(RenderInterface* _render_interface)
+void SetRenderInterface(SharedPtr<RenderInterface> _render_interface)
 {
 {
-	if (render_interface == _render_interface)
-		return;
-
-	if (render_interface != NULL)
-		render_interface->RemoveReference();
-
-	render_interface = _render_interface;
-	if (render_interface != NULL)
-		render_interface->AddReference();
+	render_interface = std::move(_render_interface);
 }
 }
 
 
 // Returns RmlUi's render interface.
 // Returns RmlUi's render interface.
 RenderInterface* GetRenderInterface()
 RenderInterface* GetRenderInterface()
 {
 {
-	return render_interface;
+	return render_interface.get();
 }
 }
 
 
 // Sets the interface through which all file I/O requests are made.
 // Sets the interface through which all file I/O requests are made.
-void SetFileInterface(FileInterface* _file_interface)
+void SetFileInterface(SharedPtr<FileInterface> _file_interface)
 {
 {
-	if (file_interface == _file_interface)
-		return;
-
-	if (file_interface != NULL)
-		file_interface->RemoveReference();
-
-	file_interface = _file_interface;
-	if (file_interface != NULL)
-		file_interface->AddReference();
+	file_interface = std::move(_file_interface);
 }
 }
 
 
 // Returns RmlUi's file interface.
 // Returns RmlUi's file interface.
 FileInterface* GetFileInterface()
 FileInterface* GetFileInterface()
 {
 {
-	return file_interface;
+	return file_interface.get();
 }
 }
 
 
 // Creates a new element context.
 // Creates a new element context.
-Context* CreateContext(const String& name, const Vector2i& dimensions, RenderInterface* custom_render_interface)
+Context* CreateContext(const String& name, const Vector2i& dimensions, SharedPtr<RenderInterface> custom_render_interface)
 {
 {
 	if (!initialised)
 	if (!initialised)
 		return nullptr;
 		return nullptr;
@@ -228,10 +197,9 @@ Context* CreateContext(const String& name, const Vector2i& dimensions, RenderInt
 
 
 	// Set the render interface on the context, and add a reference onto it.
 	// Set the render interface on the context, and add a reference onto it.
 	if (custom_render_interface)
 	if (custom_render_interface)
-		new_context->render_interface = custom_render_interface;
+		new_context->render_interface = std::move(custom_render_interface);
 	else
 	else
 		new_context->render_interface = render_interface;
 		new_context->render_interface = render_interface;
-	new_context->render_interface->AddReference();
 
 
 	new_context->SetDimensions(dimensions);
 	new_context->SetDimensions(dimensions);
 	if (dimensions.x > 0 && dimensions.y > 0)
 	if (dimensions.x > 0 && dimensions.y > 0)

+ 1 - 11
Source/Core/FileInterface.cpp

@@ -32,7 +32,7 @@
 namespace Rml {
 namespace Rml {
 namespace Core {
 namespace Core {
 
 
-FileInterface::FileInterface() : ReferenceCountable(0)
+FileInterface::FileInterface()
 {
 {
 }
 }
 
 
@@ -50,15 +50,5 @@ size_t FileInterface::Length(FileHandle file)
     return length;
     return length;
 }
 }
 
 
-// Called when this file interface is released.
-void FileInterface::Release()
-{
-}
-
-void FileInterface::OnReferenceDeactivate()
-{
-	Release();
-}
-
 }
 }
 }
 }

+ 5 - 5
Source/Core/FileInterfaceDefault.h

@@ -50,27 +50,27 @@ public:
 	/// Opens a file.		
 	/// Opens a file.		
 	/// @param path The path of the file to open.		
 	/// @param path The path of the file to open.		
 	/// @return A valid file handle, or NULL on failure
 	/// @return A valid file handle, or NULL on failure
-	virtual FileHandle Open(const String& path);
+	FileHandle Open(const String& path) override;
 	/// Closes a previously opened file.
 	/// Closes a previously opened file.
 	/// @param file The file handle previously opened through Open().
 	/// @param file The file handle previously opened through Open().
-	virtual void Close(FileHandle file);
+	void Close(FileHandle file) override;
 
 
 	/// Reads data from a previously opened file.
 	/// Reads data from a previously opened file.
 	/// @param buffer The buffer to be read into.
 	/// @param buffer The buffer to be read into.
 	/// @param size The number of bytes to read into the buffer.
 	/// @param size The number of bytes to read into the buffer.
 	/// @param file The handle of the file.
 	/// @param file The handle of the file.
 	/// @return The total number of bytes read into the buffer.
 	/// @return The total number of bytes read into the buffer.
-	virtual size_t Read(void* buffer, size_t size, FileHandle file);
+	size_t Read(void* buffer, size_t size, FileHandle file) override;
 	/// Seeks to a point in a previously opened file.
 	/// Seeks to a point in a previously opened file.
 	/// @param file The handle of the file to seek.
 	/// @param file The handle of the file to seek.
 	/// @param offset The number of bytes to seek.
 	/// @param offset The number of bytes to seek.
 	/// @param origin One of either SEEK_SET (seek from the beginning of the file), SEEK_END (seek from the end of the file) or SEEK_CUR (seek from the current file position).
 	/// @param origin One of either SEEK_SET (seek from the beginning of the file), SEEK_END (seek from the end of the file) or SEEK_CUR (seek from the current file position).
 	/// @return True if the operation completed successfully, false otherwise.
 	/// @return True if the operation completed successfully, false otherwise.
-	virtual bool Seek(FileHandle file, long offset, int origin);
+	bool Seek(FileHandle file, long offset, int origin) override;
 	/// Returns the current position of the file pointer.
 	/// Returns the current position of the file pointer.
 	/// @param file The handle of the file to be queried.
 	/// @param file The handle of the file to be queried.
 	/// @return The number of bytes from the origin of the file.
 	/// @return The number of bytes from the origin of the file.
-	virtual size_t Tell(FileHandle file);
+	size_t Tell(FileHandle file) override;
 };
 };
 
 
 }
 }

+ 3 - 13
Source/Core/RenderInterface.cpp

@@ -33,13 +33,14 @@
 namespace Rml {
 namespace Rml {
 namespace Core {
 namespace Core {
 
 
-RenderInterface::RenderInterface() : ReferenceCountable(0)
+RenderInterface::RenderInterface()
 {
 {
-	context = NULL;
+	context = nullptr;
 }
 }
 
 
 RenderInterface::~RenderInterface()
 RenderInterface::~RenderInterface()
 {
 {
+	TextureDatabase::ReleaseTextures(this);
 }
 }
 
 
 // Called by RmlUi when it wants to compile geometry it believes will be static for the forseeable future.
 // Called by RmlUi when it wants to compile geometry it believes will be static for the forseeable future.
@@ -115,17 +116,6 @@ void RenderInterface::PopTransform(const Matrix4f& transform)
 {
 {
 }
 }
 
 
-// Called when this render interface is released.
-void RenderInterface::Release()
-{
-}
-
-void RenderInterface::OnReferenceDeactivate()
-{
-	TextureDatabase::ReleaseTextures(this);
-	Release();
-}
-
 // Get the context currently being rendered.
 // Get the context currently being rendered.
 Context* RenderInterface::GetContext() const
 Context* RenderInterface::GetContext() const
 {
 {

+ 1 - 11
Source/Core/SystemInterface.cpp

@@ -39,7 +39,7 @@ namespace Core {
 
 
 static WString clipboard_text;
 static WString clipboard_text;
 
 
-SystemInterface::SystemInterface() : ReferenceCountable(0)
+SystemInterface::SystemInterface()
 {
 {
 }
 }
 
 
@@ -140,15 +140,5 @@ void SystemInterface::DeactivateKeyboard()
 {
 {
 }
 }
 
 
-// Called when this system interface is released.
-void SystemInterface::Release()
-{
-}
-
-void SystemInterface::OnReferenceDeactivate()
-{
-	Release();
-}
-
 }
 }
 }
 }

+ 7 - 3
Source/Debugger/Plugin.cpp

@@ -49,7 +49,7 @@ Plugin::Plugin()
 	instance = this;
 	instance = this;
 	host_context = nullptr;
 	host_context = nullptr;
 	debug_context = nullptr;
 	debug_context = nullptr;
-	log_hook = nullptr;
+	log_interface = nullptr;
 
 
 	menu_element = nullptr;
 	menu_element = nullptr;
 	info_element = nullptr;
 	info_element = nullptr;
@@ -352,7 +352,9 @@ bool Plugin::LoadLogElement()
 	}
 	}
 
 
 	// Make the system interface; this will trap the log messages for us.
 	// Make the system interface; this will trap the log messages for us.
-	log_hook = new SystemInterface(log_element);
+	application_interface = Core::GetSystemInterfaceSharedPtr();
+	log_interface = std::make_shared<SystemInterface>(application_interface.get(), log_element);
+	Core::SetSystemInterface(log_interface);
 
 
 	return true;
 	return true;
 }
 }
@@ -377,7 +379,9 @@ void Plugin::ReleaseElements()
 		{
 		{
 			host_context->UnloadDocument(log_element);
 			host_context->UnloadDocument(log_element);
 			log_element = nullptr;
 			log_element = nullptr;
-			delete log_hook;
+			Core::SetSystemInterface(application_interface);
+			application_interface.reset();
+			log_interface.reset();
 		}
 		}
 	}
 	}
 
 

+ 4 - 1
Source/Debugger/Plugin.h

@@ -37,6 +37,7 @@ namespace Rml {
 namespace Core {
 namespace Core {
 
 
 class ElementDocument;
 class ElementDocument;
+class SystemInterface;
 
 
 }
 }
 
 
@@ -117,7 +118,9 @@ private:
 	ElementInfo* info_element;
 	ElementInfo* info_element;
 	ElementLog* log_element;
 	ElementLog* log_element;
 	ElementContextHook* hook_element;
 	ElementContextHook* hook_element;
-	SystemInterface* log_hook;
+
+	Core::SharedPtr<Core::SystemInterface> application_interface;
+	Core::SharedPtr<SystemInterface> log_interface;
 
 
 	bool render_outlines;
 	bool render_outlines;
 
 

+ 3 - 6
Source/Debugger/SystemInterface.cpp

@@ -33,18 +33,15 @@
 namespace Rml {
 namespace Rml {
 namespace Debugger {
 namespace Debugger {
 
 
-SystemInterface::SystemInterface(ElementLog* _log)
+SystemInterface::SystemInterface(Core::SystemInterface* _application_interface, ElementLog* _log)
 {
 {
+	application_interface = _application_interface;
 	log = _log;
 	log = _log;
-	application_interface = Core::GetSystemInterface();
-	application_interface->AddReference();
-	Core::SetSystemInterface(this);
 }
 }
 
 
 SystemInterface::~SystemInterface()
 SystemInterface::~SystemInterface()
 {
 {
-	Core::SetSystemInterface(application_interface);
-	application_interface->RemoveReference();
+	application_interface = nullptr;
 }
 }
 
 
 // Get the number of seconds elapsed since the start of the application.
 // Get the number of seconds elapsed since the start of the application.

+ 1 - 1
Source/Debugger/SystemInterface.h

@@ -48,7 +48,7 @@ class SystemInterface : public Core::SystemInterface
 public:
 public:
 	/// Instances a new debugging log interface.
 	/// Instances a new debugging log interface.
 	/// @param[in] log The logging element to send messages to.
 	/// @param[in] log The logging element to send messages to.
-	SystemInterface(ElementLog* log);
+	SystemInterface(Core::SystemInterface* application_interface, ElementLog* log);
 	virtual ~SystemInterface();
 	virtual ~SystemInterface();
 
 
 	/// Get the number of seconds elapsed since the start of the application.
 	/// Get the number of seconds elapsed since the start of the application.