Permalink
Browse files

Fix event objects not being freed

  • Loading branch information...
LBPHacker authored and jacob1 committed Nov 16, 2018
1 parent 531229d commit 3de68c43466f8730d45058b3bb2695df1a9c9de7
Showing with 16 additions and 8 deletions.
  1. +14 −7 src/gui/game/GameController.cpp
  2. +2 −1 src/lua/LuaScriptInterface.cpp
@@ -622,12 +622,14 @@ void GameController::CutRegion(ui::Point point1, ui::Point point2, bool includeP
bool GameController::MouseMove(int x, int y, int dx, int dy)
{
return commandInterface->HandleEvent(LuaEvents::mousemove, new MouseMoveEvent(x, y, dx, dy));
MouseMoveEvent ev(x, y, dx, dy);
return commandInterface->HandleEvent(LuaEvents::mousemove, &ev);
}
bool GameController::MouseDown(int x, int y, unsigned button)
{
bool ret = commandInterface->HandleEvent(LuaEvents::mousedown, new MouseDownEvent(x, y, button));
MouseDownEvent ev(x, y, button);
bool ret = commandInterface->HandleEvent(LuaEvents::mousedown, &ev);
if (ret && y<YRES && x<XRES && !gameView->GetPlacingSave() && !gameView->GetPlacingZoom())
{
ui::Point point = gameModel->AdjustZoomCoords(ui::Point(x, y));
@@ -649,7 +651,8 @@ bool GameController::MouseDown(int x, int y, unsigned button)
bool GameController::MouseUp(int x, int y, unsigned button, char type)
{
bool ret = commandInterface->HandleEvent(LuaEvents::mouseup, new MouseUpEvent(x, y, button, type));
MouseUpEvent ev(x, y, button, type);
bool ret = commandInterface->HandleEvent(LuaEvents::mouseup, &ev);
if (type)
return ret;
if (ret && foundSignID != -1 && y<YRES && x<XRES && !gameView->GetPlacingSave())
@@ -707,17 +710,20 @@ bool GameController::MouseUp(int x, int y, unsigned button, char type)
bool GameController::MouseWheel(int x, int y, int d)
{
return commandInterface->HandleEvent(LuaEvents::mousewheel, new MouseWheelEvent(x, y, d));
MouseWheelEvent ev(x, y, d);
return commandInterface->HandleEvent(LuaEvents::mousewheel, &ev);
}
bool GameController::TextInput(String text)
{
return commandInterface->HandleEvent(LuaEvents::textinput, new TextInputEvent(text));
TextInputEvent ev(text);
return commandInterface->HandleEvent(LuaEvents::textinput, &ev);
}
bool GameController::KeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
bool ret = commandInterface->HandleEvent(LuaEvents::keypress, new KeyEvent(key, scan, repeat, shift, ctrl, alt));
KeyEvent ev(key, scan, repeat, shift, ctrl, alt);
bool ret = commandInterface->HandleEvent(LuaEvents::keypress, &ev);
if (repeat)
return ret;
if (ret)
@@ -796,7 +802,8 @@ bool GameController::KeyPress(int key, int scan, bool repeat, bool shift, bool c
bool GameController::KeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
bool ret = commandInterface->HandleEvent(LuaEvents::keyrelease, new KeyEvent(key, scan, repeat, shift, ctrl, alt));
KeyEvent ev(key, scan, repeat, shift, ctrl, alt);
bool ret = commandInterface->HandleEvent(LuaEvents::keyrelease, &ev);
if (repeat)
return ret;
if (ret)
@@ -3349,7 +3349,8 @@ void LuaScriptInterface::OnTick()
lua_setfield(l, -2, "NUM_PARTS");
}
lua_pop(l, 1);
HandleEvent(LuaEvents::tick, new TickEvent());
TickEvent ev;
HandleEvent(LuaEvents::tick, &ev);
}
int LuaScriptInterface::Command(String command)

0 comments on commit 3de68c4

Please sign in to comment.