NEVERHOOD: Fix crash when viewing videos in the video viewer

The crash was caused by stale pointers, exactly the same as in commit
2e4f64066d
This commit is contained in:
Filippos Karapetis 2013-06-10 03:41:55 +03:00
parent 4d56fe773d
commit a01b8a5174
2 changed files with 12 additions and 4 deletions

View File

@ -473,8 +473,15 @@ uint32 DiskplayerScene::handleMessage(int messageNum, const MessageParam &param,
return 0;
}
void DiskplayerScene::openSmacker(uint32 fileHash, bool keepLastFrame) {
// The old Smacker surface is deleted when a new Smacker is opened.
removeSurface(_diskSmackerPlayer->getSurface());
_diskSmackerPlayer->open(fileHash, keepLastFrame);
addSurface(_diskSmackerPlayer->getSurface());
}
void DiskplayerScene::stop() {
_diskSmackerPlayer->open(0x08288103, true);
openSmacker(0x08288103, true);
_vm->_screen->setSmackerDecoder(_diskSmackerPlayer->getSmackerDecoder());
_palette->usePalette();
_ssPlayButton->release();
@ -483,7 +490,7 @@ void DiskplayerScene::stop() {
}
void DiskplayerScene::tuneIn() {
_diskSmackerPlayer->open(0x900001C1, false);
openSmacker(0x900001C1, false);
_vm->_screen->setSmackerDecoder(_diskSmackerPlayer->getSmackerDecoder());
_palette->usePalette();
_ssPlayButton->release();
@ -492,7 +499,7 @@ void DiskplayerScene::tuneIn() {
}
void DiskplayerScene::playDisk() {
_diskSmackerPlayer->open(kDiskplayerSmackerFileHashes[_diskIndex], false);
openSmacker(kDiskplayerSmackerFileHashes[_diskIndex], false);
_vm->_screen->setSmackerDecoder(_diskSmackerPlayer->getSmackerDecoder());
_palette->usePalette();
_updateStatus = kUSPlaying;
@ -500,7 +507,7 @@ void DiskplayerScene::playDisk() {
}
void DiskplayerScene::playStatic() {
_diskSmackerPlayer->open(0x90000101, false);
openSmacker(0x90000101, false);
_vm->_screen->setSmackerDecoder(_diskSmackerPlayer->getSmackerDecoder());
_palette->usePalette();
_ssPlayButton->release();

View File

@ -99,6 +99,7 @@ protected:
bool _dropKey;
void update();
uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
void openSmacker(uint32 fileHash, bool keepLastFrame);
void stop();
void tuneIn();
void playDisk();