mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 20:53:52 +00:00
Fix memory leak in MWInput
mListener wasn't being cleaned up
This commit is contained in:
parent
49c828c138
commit
fe815d3d8d
2 changed files with 9 additions and 9 deletions
|
@ -171,16 +171,16 @@ namespace MWInput
|
||||||
, mDragDrop(false)
|
, mDragDrop(false)
|
||||||
{
|
{
|
||||||
std::string file = userFileExists ? userFile : "";
|
std::string file = userFileExists ? userFile : "";
|
||||||
mInputBinder = new InputControlSystem(file);
|
mInputBinder = std::make_unique<InputControlSystem>(file);
|
||||||
mListener = new BindingsListener(mInputBinder, this);
|
mListener = std::make_unique<BindingsListener>(mInputBinder.get(), this);
|
||||||
mInputBinder->setDetectingBindingListener(mListener);
|
mInputBinder->setDetectingBindingListener(mListener.get());
|
||||||
|
|
||||||
loadKeyDefaults();
|
loadKeyDefaults();
|
||||||
loadControllerDefaults();
|
loadControllerDefaults();
|
||||||
|
|
||||||
for (int i = 0; i < A_Last; ++i)
|
for (int i = 0; i < A_Last; ++i)
|
||||||
{
|
{
|
||||||
mInputBinder->getChannel(i)->addListener(mListener);
|
mInputBinder->getChannel(i)->addListener(mListener.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,6 @@ namespace MWInput
|
||||||
BindingsManager::~BindingsManager()
|
BindingsManager::~BindingsManager()
|
||||||
{
|
{
|
||||||
mInputBinder->save(mUserFile);
|
mInputBinder->save(mUserFile);
|
||||||
delete mInputBinder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BindingsManager::update(float dt)
|
void BindingsManager::update(float dt)
|
||||||
|
@ -315,7 +314,7 @@ namespace MWInput
|
||||||
&& mInputBinder->getMouseButtonBinding(control, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS
|
&& mInputBinder->getMouseButtonBinding(control, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS
|
||||||
&& mInputBinder->getMouseWheelBinding(control, ICS::Control::INCREASE) == ICS::InputControlSystem::MouseWheelClick::UNASSIGNED))
|
&& mInputBinder->getMouseWheelBinding(control, ICS::Control::INCREASE) == ICS::InputControlSystem::MouseWheelClick::UNASSIGNED))
|
||||||
{
|
{
|
||||||
clearAllKeyBindings(mInputBinder, control);
|
clearAllKeyBindings(mInputBinder.get(), control);
|
||||||
|
|
||||||
if (defaultKeyBindings.find(i) != defaultKeyBindings.end()
|
if (defaultKeyBindings.find(i) != defaultKeyBindings.end()
|
||||||
&& (force || !mInputBinder->isKeyBound(defaultKeyBindings[i])))
|
&& (force || !mInputBinder->isKeyBound(defaultKeyBindings[i])))
|
||||||
|
@ -402,7 +401,7 @@ namespace MWInput
|
||||||
if (!controlExists || force || (mInputBinder->getJoystickAxisBinding(control, sFakeDeviceId, ICS::Control::INCREASE) == ICS::InputControlSystem::UNASSIGNED &&
|
if (!controlExists || force || (mInputBinder->getJoystickAxisBinding(control, sFakeDeviceId, ICS::Control::INCREASE) == ICS::InputControlSystem::UNASSIGNED &&
|
||||||
mInputBinder->getJoystickButtonBinding(control, sFakeDeviceId, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS))
|
mInputBinder->getJoystickButtonBinding(control, sFakeDeviceId, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS))
|
||||||
{
|
{
|
||||||
clearAllControllerBindings(mInputBinder, control);
|
clearAllControllerBindings(mInputBinder.get(), control);
|
||||||
|
|
||||||
if (defaultButtonBindings.find(i) != defaultButtonBindings.end()
|
if (defaultButtonBindings.find(i) != defaultButtonBindings.end()
|
||||||
&& (force || !mInputBinder->isJoystickButtonBound(sFakeDeviceId, defaultButtonBindings[i])))
|
&& (force || !mInputBinder->isJoystickButtonBound(sFakeDeviceId, defaultButtonBindings[i])))
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef MWINPUT_MWBINDINGSMANAGER_H
|
#ifndef MWINPUT_MWBINDINGSMANAGER_H
|
||||||
#define MWINPUT_MWBINDINGSMANAGER_H
|
#define MWINPUT_MWBINDINGSMANAGER_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -64,8 +65,8 @@ namespace MWInput
|
||||||
private:
|
private:
|
||||||
void setupSDLKeyMappings();
|
void setupSDLKeyMappings();
|
||||||
|
|
||||||
InputControlSystem* mInputBinder;
|
std::unique_ptr<InputControlSystem> mInputBinder;
|
||||||
BindingsListener* mListener;
|
std::unique_ptr<BindingsListener> mListener;
|
||||||
|
|
||||||
std::string mUserFile;
|
std::string mUserFile;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue