Fix small memory leak, thanks valgrind
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include "inferno/assertions.h"
|
#include "inferno/assertions.h"
|
||||||
@@ -67,7 +65,7 @@ namespace Inferno {
|
|||||||
glfwSetWindowUserPointer(m_window, this);
|
glfwSetWindowUserPointer(m_window, this);
|
||||||
|
|
||||||
// Create graphics context
|
// Create graphics context
|
||||||
m_context = new Context(m_window);
|
m_context = std::make_shared<Context>(m_window);
|
||||||
m_context->initialize();
|
m_context->initialize();
|
||||||
|
|
||||||
// Capture cursor and hide it
|
// Capture cursor and hide it
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define WINDOW_H
|
#define WINDOW_H
|
||||||
|
|
||||||
#include <functional> // std::function
|
#include <functional> // std::function
|
||||||
|
#include <memory> // std::shared_ptr
|
||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
|
|
||||||
@@ -42,14 +43,14 @@ namespace Inferno {
|
|||||||
inline bool isVSync() const { return m_properties.vsync; }
|
inline bool isVSync() const { return m_properties.vsync; }
|
||||||
|
|
||||||
inline GLFWwindow* getWindow() const { return m_window; }
|
inline GLFWwindow* getWindow() const { return m_window; }
|
||||||
inline Context* getContext() const { return m_context; }
|
inline const std::shared_ptr<Context>& getContext() const { return m_context; }
|
||||||
|
|
||||||
inline void setEventCallback(std::function<void(Event&)> callback) { m_eventCallback = callback; }
|
inline void setEventCallback(std::function<void(Event&)> callback) { m_eventCallback = callback; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WindowProperties m_properties;
|
WindowProperties m_properties;
|
||||||
GLFWwindow* m_window;
|
GLFWwindow* m_window;
|
||||||
Context* m_context;
|
std::shared_ptr<Context> m_context;
|
||||||
|
|
||||||
std::function<void(Event&)> m_eventCallback;
|
std::function<void(Event&)> m_eventCallback;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user