[Scummvm-cvs-logs] CVS: scummvm/sky control.cpp,1.103,1.104 logic.cpp,1.161,1.162 screen.cpp,1.70,1.71 sky.cpp,1.186,1.187
Robert Göffringmann
lavosspawn at users.sourceforge.net
Tue Dec 13 06:32:02 CET 2005
Update of /cvsroot/scummvm/scummvm/sky
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28668/sky
Modified Files:
control.cpp logic.cpp screen.cpp sky.cpp
Log Message:
fixed Sky memory leaks on quitting
Index: control.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/control.cpp,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- control.cpp 5 Dec 2005 05:02:42 -0000 1.103
+++ control.cpp 13 Dec 2005 14:31:13 -0000 1.104
@@ -237,7 +237,12 @@
delete _restartPanButton; delete _fxPanButton;
delete _musicPanButton; delete _bodge;
delete _yesNo; delete _text;
- delete _statusBar;
+ delete _statusBar; delete _restoreButton;
+
+ if (_textSprite) {
+ free(_textSprite);
+ _textSprite = NULL;
+ }
}
void Control::initPanel(void) {
@@ -318,13 +323,16 @@
_restorePanLookList[6] = _autoSaveButton;
_statusBar = new ControlStatus(_skyText, _system, _screenBuf);
+
+ _textSprite = NULL;
}
void Control::buttonControl(ConResource *pButton) {
char autoSave[] = "Restore Autosave";
if (pButton == NULL) {
- if (_textSprite) free(_textSprite);
+ if (_textSprite)
+ free(_textSprite);
_textSprite = NULL;
_curButtonText = 0;
_text->setSprite(NULL);
@@ -431,7 +439,6 @@
_skyMouse->spriteMouse(MOUSE_NORMAL, 0, 0);
_lastButton = -1;
_curButtonText = 0;
- _textSprite = NULL;
saveRestorePanel(false);
@@ -469,7 +476,6 @@
bool quitPanel = false;
_lastButton = -1;
_curButtonText = 0;
- _textSprite = NULL;
uint16 clickRes = 0;
while (!quitPanel && !SkyEngine::_systemVars.quitGame) {
@@ -841,7 +847,7 @@
bool refreshNames = true;
bool refreshAll = true;
uint16 clickRes = 0;
- while (!quitPanel) {
+ while (!quitPanel && !SkyEngine::_systemVars.quitGame) {
clickRes = 0;
if (refreshNames || refreshAll) {
if (refreshAll) {
@@ -920,7 +926,8 @@
refreshNames = true;
}
}
- if (!haveButton) buttonControl(NULL);
+ if (!haveButton)
+ buttonControl(NULL);
}
for (cnt = 0; cnt < MAX_ON_SCREEN + 1; cnt++)
Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/logic.cpp,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -d -r1.161 -r1.162
--- logic.cpp 6 Dec 2005 16:50:39 -0000 1.161
+++ logic.cpp 13 Dec 2005 14:31:13 -0000 1.162
@@ -90,6 +90,10 @@
Logic::~Logic(void) {
delete _skyGrid;
delete _skyAutoRoute;
+
+ for (int i = 0; i < ARRAYSIZE(_moduleList); i++)
+ if (_moduleList[i])
+ free(_moduleList[i]);
}
void Logic::initScreen0(void) {
Index: screen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/screen.cpp,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- screen.cpp 18 Oct 2005 01:30:23 -0000 1.70
+++ screen.cpp 13 Dec 2005 14:31:13 -0000 1.71
@@ -91,6 +91,8 @@
free(_gameGrid);
if (_currentScreen)
free(_currentScreen);
+ if (_scrollScreen)
+ free(_scrollScreen);
}
void Screen::clearScreen(void) {
@@ -246,14 +248,7 @@
void Screen::fnFadeDown(uint32 scroll) {
- if (scroll && (!(SkyEngine::_systemVars.systemFlags & SF_NO_SCROLL))) {
- // scrolling is performed by fnFadeUp. It's just prepared here
- _scrollScreen = _currentScreen;
- _currentScreen = (uint8 *)malloc(FULL_SCREEN_WIDTH * FULL_SCREEN_HEIGHT);
- // the game will draw the new room into _currentScreen which
- // will be scrolled into the visible screen by fnFadeUp
- // fnFadeUp also frees the _scrollScreen
- } else {
+ if (((scroll != 123) && (scroll != 321)) || (SkyEngine::_systemVars.systemFlags & SF_NO_SCROLL)) {
uint32 delayTime = _system->getMillis();
for (uint8 cnt = 0; cnt < 32; cnt++) {
delayTime += 20;
@@ -265,6 +260,13 @@
waitTime = 0;
_system->delayMillis((uint)waitTime);
}
+ } else {
+ // scrolling is performed by fnFadeUp. It's just prepared here
+ _scrollScreen = _currentScreen;
+ _currentScreen = (uint8 *)malloc(FULL_SCREEN_WIDTH * FULL_SCREEN_HEIGHT);
+ // the game will draw the new room into _currentScreen which
+ // will be scrolled into the visible screen by fnFadeUp
+ // fnFadeUp also frees the _scrollScreen
}
}
@@ -325,9 +327,8 @@
//_currentScreen points to new screen,
//_scrollScreen points to graphic showing old room
- if ((scroll != 123) && (scroll != 321)) {
+ if ((scroll != 123) && (scroll != 321))
scroll = 0;
- }
if ((scroll == 0) || (SkyEngine::_systemVars.systemFlags & SF_NO_SCROLL)) {
uint8 *palette = (uint8 *)_skyCompact->fetchCpt(palNum);
@@ -342,10 +343,7 @@
paletteFadeUp(palette);
#endif
} else if (scroll == 123) { // scroll left (going right)
- if (!_currentScreen)
- error("Screen::fnFadeUp[Scroll L]: _currentScreen is NULL");
- if (!_scrollScreen)
- error("Screen::fnFadeUp[Scroll L]: _scrollScreen is NULL");
+ assert(_currentScreen && _scrollScreen);
uint8 *scrNewPtr, *scrOldPtr;
for (uint8 scrollCnt = 0; scrollCnt < (GAME_SCREEN_WIDTH / SCROLL_JUMP) - 1; scrollCnt++) {
scrNewPtr = _currentScreen + scrollCnt * SCROLL_JUMP;
@@ -360,12 +358,8 @@
waitForTimer();
}
showScreen(_currentScreen);
- free(_scrollScreen);
} else if (scroll == 321) { // scroll right (going left)
- if (!_currentScreen)
- error("Screen::fnFadeUp[Scroll R]: _currentScreen is NULL");
- if (!_scrollScreen)
- error("Screen::fnFadeUp[Scroll R]: _scrollScreen is NULL");
+ assert(_currentScreen && _scrollScreen);
uint8 *scrNewPtr, *scrOldPtr;
for (uint8 scrollCnt = 0; scrollCnt < (GAME_SCREEN_WIDTH / SCROLL_JUMP) - 1; scrollCnt++) {
scrNewPtr = _currentScreen + GAME_SCREEN_WIDTH - (scrollCnt + 1) * SCROLL_JUMP;
@@ -380,7 +374,10 @@
waitForTimer();
}
showScreen(_currentScreen);
+ }
+ if (_scrollScreen) {
free(_scrollScreen);
+ _scrollScreen = NULL;
}
}
Index: sky.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sky.cpp,v
retrieving revision 1.186
retrieving revision 1.187
diff -u -d -r1.186 -r1.187
--- sky.cpp 5 Dec 2005 05:02:43 -0000 1.186
+++ sky.cpp 13 Dec 2005 14:31:13 -0000 1.187
@@ -133,6 +133,8 @@
delete _skyScreen;
delete _debugger;
delete _skyDisk;
+ delete _skyControl;
+ delete _skyCompact;
for (int i = 0; i < 300; i++)
if (_itemList[i])
More information about the Scummvm-git-logs
mailing list