fix stale INPUTMAN pointer in Lua after device change
This commit is contained in:
@@ -100,8 +100,7 @@ void GameLoop()
|
|||||||
|
|
||||||
if( INPUTMAN->DevicesChanged() )
|
if( INPUTMAN->DevicesChanged() )
|
||||||
{
|
{
|
||||||
SAFE_DELETE( INPUTMAN );
|
INPUTMAN->LoadDrivers();
|
||||||
INPUTMAN = new RageInput( PREFSMAN->GetInputDrivers() );
|
|
||||||
StepMania::CheckForChangedInputDevicesAndRemap();
|
StepMania::CheckForChangedInputDevicesAndRemap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,9 @@ RageInput::RageInput( CString sDriverList )
|
|||||||
{
|
{
|
||||||
LOG->Trace( "RageInput::RageInput()" );
|
LOG->Trace( "RageInput::RageInput()" );
|
||||||
|
|
||||||
/* Init optional devices. */
|
m_sDriverList = sDriverList;
|
||||||
MakeInputHandlers( sDriverList, m_pDevices );
|
|
||||||
|
|
||||||
/* If no input devices are loaded, the user won't be able to input anything. */
|
LoadDrivers();
|
||||||
if( m_pDevices.size() == 0 )
|
|
||||||
LOG->Warn( "No input devices were loaded." );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RageInput::~RageInput()
|
RageInput::~RageInput()
|
||||||
@@ -27,6 +24,20 @@ RageInput::~RageInput()
|
|||||||
delete m_pDevices[i];
|
delete m_pDevices[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RageInput::LoadDrivers()
|
||||||
|
{
|
||||||
|
for( unsigned i = 0; i < m_pDevices.size(); ++i )
|
||||||
|
delete m_pDevices[i];
|
||||||
|
m_pDevices.clear();
|
||||||
|
|
||||||
|
/* Init optional devices. */
|
||||||
|
MakeInputHandlers( m_sDriverList, m_pDevices );
|
||||||
|
|
||||||
|
/* If no input devices are loaded, the user won't be able to input anything. */
|
||||||
|
if( m_pDevices.size() == 0 )
|
||||||
|
LOG->Warn( "No input devices were loaded." );
|
||||||
|
}
|
||||||
|
|
||||||
void RageInput::Update( float fDeltaTime )
|
void RageInput::Update( float fDeltaTime )
|
||||||
{
|
{
|
||||||
/* Update optional devices. */
|
/* Update optional devices. */
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public:
|
|||||||
RageInput( CString sDriverList );
|
RageInput( CString sDriverList );
|
||||||
~RageInput();
|
~RageInput();
|
||||||
|
|
||||||
|
void LoadDrivers();
|
||||||
void Update( float fDeltaTime );
|
void Update( float fDeltaTime );
|
||||||
bool DevicesChanged();
|
bool DevicesChanged();
|
||||||
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<CString>& vsDescriptionsOut );
|
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<CString>& vsDescriptionsOut );
|
||||||
@@ -27,6 +28,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
vector<InputHandler *> m_pDevices;
|
vector<InputHandler *> m_pDevices;
|
||||||
|
CString m_sDriverList;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern RageInput* INPUTMAN; // global and accessable from anywhere in our program
|
extern RageInput* INPUTMAN; // global and accessable from anywhere in our program
|
||||||
|
|||||||
Reference in New Issue
Block a user