Improved ModularBackend and OSystem_SDL destructors.

svn-id: r49679
This commit is contained in:
Alejandro Marzini 2010-06-15 05:15:34 +00:00
parent e1ef3cd9fc
commit d2f9355aee
3 changed files with 28 additions and 15 deletions

View File

@ -40,11 +40,20 @@ ModularBackend::ModularBackend()
}
ModularBackend::~ModularBackend() {
delete _eventManager;
delete _mutexManager;
delete _graphicsManager;
delete _mixer;
delete _audiocdManager;
if (_eventManager != 0)
delete _eventManager;
if (_graphicsManager != 0)
delete _graphicsManager;
if (_mixer != 0)
delete _mixer;
if (_audiocdManager != 0)
delete _audiocdManager;
if (_savefileManager != 0)
delete _savefileManager;
if (_timerManager != 0)
delete _timerManager;
if (_mutexManager != 0)
delete _mutexManager;
}
bool ModularBackend::hasFeature(Feature f) {

View File

@ -63,7 +63,7 @@ int main(int argc, char *argv[]) {
// Invoke the actual ScummVM main entry point:
int res = scummvm_main(argc, argv);
((OSystem_SDL *)g_system)->deinit();
delete (OSystem_SDL *)g_system;
return res;
}

View File

@ -169,9 +169,7 @@ OSystem_SDL::OSystem_SDL()
}
OSystem_SDL::~OSystem_SDL() {
delete _mixer;
delete _savefileManager;
delete _timerManager;
deinit();
}
void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
@ -299,16 +297,22 @@ void OSystem_SDL::setWindowCaption(const char *caption) {
void OSystem_SDL::deinit() {
SDL_ShowCursor(SDL_ENABLE);
delete _eventManager;
_eventManager = 0;
delete _savefileManager;
_savefileManager = 0;
delete _graphicsManager;
_graphicsManager = 0;
delete _audiocdManager;
_audiocdManager = 0;
delete _mixer;
_mixer = 0;
delete _timerManager;
_timerManager = 0;
delete _mutexManager;
_mutexManager = 0;
SDL_Quit();
// Event Manager requires save manager for storing
// recorded events
delete _eventManager;
delete _savefileManager;
}
void OSystem_SDL::quit() {