Fixed crash in editor mode (log listener not being removed because destructors not being called. Base class destructors MUST be virtual!)

Gui_Panel_Refactor
Joey Pollack 4 years ago
parent fed77546dc
commit 145dd7095c

@ -246,6 +246,7 @@ namespace lunarium
return; return;
#else #else
mpRunMode = new editor::Editor; mpRunMode = new editor::Editor;
delete mPanels[gui::PanelType::PT_CORE_CONSOLE]; delete mPanels[gui::PanelType::PT_CORE_CONSOLE];
mPanels[gui::PanelType::PT_CORE_CONSOLE] = nullptr; mPanels[gui::PanelType::PT_CORE_CONSOLE] = nullptr;
// Editor has it's own console // Editor has it's own console

@ -10,13 +10,19 @@
#include <gui/dearimgui/imgui.h> #include <gui/dearimgui/imgui.h>
#include <gui/dearimgui/imgui_internal.h> // To use the DockWindowXXX methods #include <gui/dearimgui/imgui_internal.h> // To use the DockWindowXXX methods
#include <iostream>
namespace lunarium namespace lunarium
{ {
CoreConsole::CoreConsole() CoreConsole::CoreConsole()
: Console(gui::PanelType::PT_CORE_CONSOLE, "Core Console"), mDockIsInit(false) : Console(gui::PanelType::PT_CORE_CONSOLE, "Core Console"), mDockIsInit(false)
{ {
} }
CoreConsole::~CoreConsole()
{
}
bool CoreConsole::DoFrame() bool CoreConsole::DoFrame()
{ {

@ -17,6 +17,7 @@ namespace lunarium
{ {
public: public:
CoreConsole(); CoreConsole();
virtual ~CoreConsole();
bool DoFrame() override; bool DoFrame() override;
private: private:

@ -13,6 +13,7 @@
#include <input/inputManager.h> #include <input/inputManager.h>
#include <cstring> #include <cstring>
#include <sstream> #include <sstream>
#include <iostream>
namespace lunarium namespace lunarium
{ {
namespace gui namespace gui
@ -47,12 +48,20 @@ namespace lunarium
Console::Console(PanelType type, const char* name) Console::Console(PanelType type, const char* name)
: Panel(type, name, gui::PanelDockZone::DDZ_NONE, false), : Panel(type, name, gui::PanelDockZone::DDZ_NONE, false),
mbNewCommand(false), mRecalledCommand(-1), mIsFocused(false), mListener(nullptr), mbNewCommand(false), mRecalledCommand(-1), mIsFocused(false), mListener(nullptr),
mbOglDebug(false), mbInfoVerbose(false) mbOglDebug(false), mbInfoVerbose(false), mpListener(nullptr)
{ {
memset(mBuffer, 0, LUA_CON_BUFFER_SIZE); memset(mBuffer, 0, LUA_CON_BUFFER_SIZE);
Logger::GetInstance()->AddListener(new GuiListener(this)); mpListener = Logger::GetInstance()->AddListener(new GuiListener(this));
} }
Console::~Console()
{
Logger::GetInstance()->RemoveListener(mpListener);
delete mpListener;
mpListener = nullptr;
}
bool Console::IsFocused() const bool Console::IsFocused() const
{ {
return mIsFocused; return mIsFocused;

@ -35,6 +35,7 @@ namespace lunarium
{ {
public: public:
Console(PanelType type, const char* name); Console(PanelType type, const char* name);
virtual ~Console();
virtual void Update(float dt); virtual void Update(float dt);
virtual bool DoFrame(); virtual bool DoFrame();
@ -49,6 +50,7 @@ namespace lunarium
private: private:
// LUA COMMAND STUFF // LUA COMMAND STUFF
LogListener* mpListener;
char mBuffer[LUA_CON_BUFFER_SIZE]; char mBuffer[LUA_CON_BUFFER_SIZE];
std::vector<std::string> mCommandHistory; std::vector<std::string> mCommandHistory;
bool mbNewCommand; bool mbNewCommand;

@ -20,6 +20,11 @@ namespace gui
} }
Panel::~Panel()
{
}
PanelType Panel::GetType() const PanelType Panel::GetType() const
{ {
return mType; return mType;

@ -23,6 +23,7 @@ namespace gui
{ {
public: public:
Panel(PanelType type, std::string name, PanelDockZone dock_zone, bool isOpen = false); Panel(PanelType type, std::string name, PanelDockZone dock_zone, bool isOpen = false);
virtual ~Panel();
PanelType GetType() const; PanelType GetType() const;
const char* GetName() const; const char* GetName() const;

@ -7,7 +7,7 @@
******************************************************************************/ ******************************************************************************/
#include "worldView.h" #include "worldView.h"
#include <utils\logger.h> #include <utils/logger.h>
#include <game/world/world.h> #include <game/world/world.h>
#include <gui/dearimgui/imgui.h> #include <gui/dearimgui/imgui.h>
#include <editor/editor.h> #include <editor/editor.h>

@ -1,6 +1,6 @@
<State> <State>
<DataDirectory>data/</DataDirectory> <DataDirectory>data/</DataDirectory>
<Mode Type="test" /> <Mode Type="editor" />
<Display Renderer="opengl" IsFullScreen="false" VSyncEnabled="true"> <Display Renderer="opengl" IsFullScreen="false" VSyncEnabled="true">
<FullScreenResolution Width="1920" Height="1080" /> <FullScreenResolution Width="1920" Height="1080" />
<WindowedSize Width="1280" Height="720" /> <WindowedSize Width="1280" Height="720" />

Loading…
Cancel
Save