Fix some memory leaks

This commit is contained in:
Wojtek Figat
2021-08-13 13:13:12 +02:00
parent af22c7e96f
commit 7fc144b07b
2 changed files with 29 additions and 3 deletions

View File

@@ -73,6 +73,7 @@ public:
}
void Update() override;
void Dispose() override;
};
InputService InputServiceInstance;
@@ -914,3 +915,24 @@ void InputService::Update()
}
}
}
void InputService::Dispose()
{
// Dispose input devices
if (Input::Mouse)
{
Input::Mouse->DeleteObject();
Input::Mouse = nullptr;
}
if (Input::Keyboard)
{
Input::Keyboard->DeleteObject();
Input::Keyboard = nullptr;
}
for (int32 i = 0; i < Input::Gamepads.Count(); i++)
Input::Gamepads[i]->DeleteObject();
Input::Gamepads.Clear();
for (int32 i = 0; i < Input::CustomDevices.Count(); i++)
Input::CustomDevices[i]->DeleteObject();
Input::CustomDevices.Clear();
}