[Scummvm-git-logs] scummvm master -> 34bf3f2de0e2722f8a6e951e8fb5be069ba7299f

bgK bastien.bouclet at gmail.com
Fri Nov 15 21:25:22 CET 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
34bf3f2de0 TTS: Fix use of virtual function in TTSMan destructor


Commit: 34bf3f2de0e2722f8a6e951e8fb5be069ba7299f
    https://github.com/scummvm/scummvm/commit/34bf3f2de0e2722f8a6e951e8fb5be069ba7299f
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2019-11-15T21:24:22+01:00

Commit Message:
TTS: Fix use of virtual function in TTSMan destructor

TextToSpeechManager::freeVoiceData was called while the virtual function
table pointer was already reset by the parent class destructor.

Changed paths:
    backends/text-to-speech/linux/linux-text-to-speech.cpp
    backends/text-to-speech/macosx/macosx-text-to-speech.mm
    backends/text-to-speech/windows/windows-text-to-speech.cpp
    common/text-to-speech.cpp
    common/text-to-speech.h


diff --git a/backends/text-to-speech/linux/linux-text-to-speech.cpp b/backends/text-to-speech/linux/linux-text-to-speech.cpp
index 5943b69..b4a0d8c 100644
--- a/backends/text-to-speech/linux/linux-text-to-speech.cpp
+++ b/backends/text-to-speech/linux/linux-text-to-speech.cpp
@@ -127,6 +127,9 @@ void SpeechDispatcherManager::init() {
 
 SpeechDispatcherManager::~SpeechDispatcherManager() {
 	stop();
+
+	clearState();
+
 	if (_connection != 0)
 		spd_close(_connection);
 	if (_threadCreated)
diff --git a/backends/text-to-speech/macosx/macosx-text-to-speech.mm b/backends/text-to-speech/macosx/macosx-text-to-speech.mm
index 72f56f9..4d232f3 100644
--- a/backends/text-to-speech/macosx/macosx-text-to-speech.mm
+++ b/backends/text-to-speech/macosx/macosx-text-to-speech.mm
@@ -66,6 +66,8 @@ MacOSXTextToSpeechManager::MacOSXTextToSpeechManager() : Common::TextToSpeechMan
 }
 
 MacOSXTextToSpeechManager::~MacOSXTextToSpeechManager() {
+	clearState();
+
 	[synthesizer release];
 	[synthesizerDelegate release];
 }
diff --git a/backends/text-to-speech/windows/windows-text-to-speech.cpp b/backends/text-to-speech/windows/windows-text-to-speech.cpp
index 9f4ecf7..a398200 100644
--- a/backends/text-to-speech/windows/windows-text-to-speech.cpp
+++ b/backends/text-to-speech/windows/windows-text-to-speech.cpp
@@ -120,6 +120,9 @@ void WindowsTextToSpeechManager::init() {
 
 WindowsTextToSpeechManager::~WindowsTextToSpeechManager() {
 	stop();
+
+	clearState();
+
 	if (_thread != NULL) {
 		WaitForSingleObject(_thread, INFINITE);
 		CloseHandle(_thread);
diff --git a/common/text-to-speech.cpp b/common/text-to-speech.cpp
index fa74e53..8e4742b 100644
--- a/common/text-to-speech.cpp
+++ b/common/text-to-speech.cpp
@@ -88,15 +88,6 @@ TextToSpeechManager::TextToSpeechManager() {
 	_ttsState->_next = nullptr;
 }
 
-TextToSpeechManager::~TextToSpeechManager() {
-	TTSState *tmp = _ttsState;
-	while (tmp != nullptr) {
-		tmp = _ttsState->_next;
-		delete _ttsState;
-		_ttsState = tmp;
-	}
-}
-
 void TextToSpeechManager::pushState() {
 	stop();
 	TTSState *newState = new TTSState;
@@ -130,6 +121,15 @@ bool TextToSpeechManager::popState() {
 	return false;
 }
 
+void TextToSpeechManager::clearState() {
+	TTSState *tmp = _ttsState;
+	while (tmp != nullptr) {
+		tmp = _ttsState->_next;
+		delete _ttsState;
+		_ttsState = tmp;
+	}
+}
+
 TTSVoice TextToSpeechManager::getVoice() {
 	if (!_ttsState->_availableVoices.empty())
 		return _ttsState->_availableVoices[_ttsState->_activeVoice];
diff --git a/common/text-to-speech.h b/common/text-to-speech.h
index 14cbab1..cd34c28 100644
--- a/common/text-to-speech.h
+++ b/common/text-to-speech.h
@@ -149,7 +149,7 @@ public:
 	 * pitch and volume to their middle values.
 	 */
 	TextToSpeechManager();
-	virtual ~TextToSpeechManager();
+	virtual ~TextToSpeechManager() {}
 
 	/**
 	 * Interrupts what's being said and says the given string
@@ -311,6 +311,7 @@ public:
 protected:
 	TTSState *_ttsState;
 
+	void clearState();
 	virtual void updateVoices() {};
 };
 





More information about the Scummvm-git-logs mailing list