mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Fix access to CPrologEpilogVideo after destruction from sound callback
This commit is contained in:
parent
c7fda0dc32
commit
9188280d02
@ -322,6 +322,13 @@ void CSoundHandler::setCallback(int channel, std::function<void()> function)
|
||||
iter->second.push_back(function);
|
||||
}
|
||||
|
||||
void CSoundHandler::resetCallback(int channel)
|
||||
{
|
||||
boost::mutex::scoped_lock lockGuard(mutexCallbacks);
|
||||
|
||||
callbacks.erase(channel);
|
||||
}
|
||||
|
||||
void CSoundHandler::soundFinishedCallback(int channel)
|
||||
{
|
||||
boost::mutex::scoped_lock lockGuard(mutexCallbacks);
|
||||
|
@ -85,6 +85,7 @@ public:
|
||||
void stopSound(int handler);
|
||||
|
||||
void setCallback(int channel, std::function<void()> function);
|
||||
void resetCallback(int channel);
|
||||
void soundFinishedCallback(int channel);
|
||||
|
||||
int ambientGetRange() const;
|
||||
|
@ -74,6 +74,7 @@ void CPrologEpilogVideo::show(Canvas & to)
|
||||
void CPrologEpilogVideo::clickPressed(const Point & cursorPosition)
|
||||
{
|
||||
close();
|
||||
CCS->soundh->resetCallback(voiceSoundHandle); // reset callback to avoid memory corruption since 'this' will be destroyed
|
||||
CCS->soundh->stopSound(voiceSoundHandle);
|
||||
CCS->soundh->stopSound(videoSoundHandle);
|
||||
if(exitCb)
|
||||
|
Loading…
Reference in New Issue
Block a user