Browse Source

Fix small memory leak, thanks valgrind

master
Riyyi 4 years ago
parent
commit
f56cfb9084
  1. 4
      inferno/src/inferno/window.cpp
  2. 5
      inferno/src/inferno/window.h

4
inferno/src/inferno/window.cpp

@ -1,5 +1,3 @@
#include <cstring>
#include <GLFW/glfw3.h>
#include "inferno/assertions.h"
@ -67,7 +65,7 @@ namespace Inferno {
glfwSetWindowUserPointer(m_window, this);
// Create graphics context
m_context = new Context(m_window);
m_context = std::make_shared<Context>(m_window);
m_context->initialize();
// Capture cursor and hide it

5
inferno/src/inferno/window.h

@ -2,6 +2,7 @@
#define WINDOW_H
#include <functional> // std::function
#include <memory> // std::shared_ptr
struct GLFWwindow;
@ -42,14 +43,14 @@ namespace Inferno {
inline bool isVSync() const { return m_properties.vsync; }
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; }
private:
WindowProperties m_properties;
GLFWwindow* m_window;
Context* m_context;
std::shared_ptr<Context> m_context;
std::function<void(Event&)> m_eventCallback;

Loading…
Cancel
Save