fix for blenderplayer crashing on exit.
the event consumer was being freed twice, once when going out of C++ scope, another when freeing the system.
This commit is contained in:
@@ -263,6 +263,15 @@ extern int GHOST_DispatchEvents(GHOST_SystemHandle systemhandle);
|
||||
extern GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle,
|
||||
GHOST_EventConsumerHandle consumerhandle);
|
||||
|
||||
/**
|
||||
* Remove the given event consumer to our list.
|
||||
* @param systemhandle The handle to the system
|
||||
* @param consumerhandle The event consumer to remove.
|
||||
* @return Indication of success.
|
||||
*/
|
||||
extern GHOST_TSuccess GHOST_RemoveEventConsumer(GHOST_SystemHandle systemhandle,
|
||||
GHOST_EventConsumerHandle consumerhandle);
|
||||
|
||||
/***************************************************************************************
|
||||
** Progress bar functionality
|
||||
***************************************************************************************/
|
||||
|
@@ -291,6 +291,13 @@ public:
|
||||
*/
|
||||
virtual GHOST_TSuccess addEventConsumer(GHOST_IEventConsumer* consumer) = 0;
|
||||
|
||||
/**
|
||||
* Removes the given event consumer to our list.
|
||||
* @param consumer The event consumer to remove.
|
||||
* @return Indication of success.
|
||||
*/
|
||||
virtual GHOST_TSuccess removeEventConsumer(GHOST_IEventConsumer* consumer) = 0;
|
||||
|
||||
/***************************************************************************************
|
||||
** N-degree of freedom device management functionality
|
||||
***************************************************************************************/
|
||||
|
@@ -253,6 +253,13 @@ GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_Eve
|
||||
return system->addEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle);
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_RemoveEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle)
|
||||
{
|
||||
GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
|
||||
|
||||
return system->removeEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle);
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle,float progress)
|
||||
{
|
||||
GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
|
||||
|
@@ -226,6 +226,17 @@ GHOST_TSuccess GHOST_System::addEventConsumer(GHOST_IEventConsumer* consumer)
|
||||
return success;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_System::removeEventConsumer(GHOST_IEventConsumer* consumer)
|
||||
{
|
||||
GHOST_TSuccess success;
|
||||
if (m_eventManager) {
|
||||
success = m_eventManager->removeConsumer(consumer);
|
||||
}
|
||||
else {
|
||||
success = GHOST_kFailure;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_System::pushEvent(GHOST_IEvent* event)
|
||||
{
|
||||
|
@@ -183,7 +183,12 @@ public:
|
||||
*/
|
||||
virtual GHOST_TSuccess addEventConsumer(GHOST_IEventConsumer* consumer);
|
||||
|
||||
|
||||
/**
|
||||
* Remove the given event consumer to our list.
|
||||
* @param consumer The event consumer to remove.
|
||||
* @return Indication of success.
|
||||
*/
|
||||
virtual GHOST_TSuccess removeEventConsumer(GHOST_IEventConsumer* consumer);
|
||||
|
||||
/***************************************************************************************
|
||||
** N-degree of freedom devcice management functionality
|
||||
|
@@ -939,6 +939,10 @@ int main(int argc, char** argv)
|
||||
}
|
||||
app.StopGameEngine();
|
||||
|
||||
/* 'app' is freed automatic when out of scope.
|
||||
* removal is needed else the system will free an already freed value */
|
||||
system->removeEventConsumer(&app);
|
||||
|
||||
BLO_blendfiledata_free(bfd);
|
||||
}
|
||||
} while (exitcode == KX_EXIT_REQUEST_RESTART_GAME || exitcode == KX_EXIT_REQUEST_START_OTHER_GAME);
|
||||
|
Reference in New Issue
Block a user