Skip to content

Commit

Permalink
fix SCREEN_READER_AVAILABLE property on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
samtupy committed Jun 17, 2024
1 parent 5dfabd5 commit 436021f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion doc/src/appendix/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ This document lists all major changes that have taken place in NVGT since we sta
* NVGT will no longer fail if a plugin pragma with the same plugin name gets encountered multiple times.
* Fix minor error in bgt_compat's set_sound_storage function where the filename stored was not caching for display properly.
* Improve the downloads page to include release dates and headings for old versions as well as file sizes, yes we do still intend to integrate with github releases.
* A fun little aside, visit https://nvtt.zip/windows, /mac or /linux to instantly download the latest NVGT for that platform!
* Fix the broken SCREEN_READER_AVAILABLE property on windows.
* New documentation on compiling a game for distrobution.

## New in 0.87.1-beta (06/16/2024):
* This patches an issue with the speech dispatcher support on linux where calling screen_reader_unload() would cause a segmentation fault if it had not loaded to begin with due to no libspeechd being available.
Expand Down
14 changes: 8 additions & 6 deletions src/srspeech.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
#elif defined(__APPLE__)
#include "apple.h"
#elif defined(__linux__) || defined(__unix__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
#include <Poco/SharedLibrary.h>
#define using_speechd
#endif
#include <string>
#include <Poco/AtomicFlag.h>
#include <Poco/SharedLibrary.h>
#include <Poco/UnicodeConverter.h>
#include "srspeech.h"

Expand Down Expand Up @@ -48,15 +48,15 @@ Poco::AtomicFlag g_SRSpeechAvailable;

bool ScreenReaderLoad() {
#if defined(_WIN32)
g_SRSpeechAvailable.set();
if (!g_SRSpeechAvailable) return false;
if (g_SRSpeechLoaded) return true;
__try {
Tolk_Load();
} __except (1) {
try {
Poco::SharedLibrary("Tolk.dll");
} catch(Poco::Exception&) {
g_SRSpeechAvailable.reset();
return false;
}
Tolk_Load();
g_SRSpeechAvailable.set();
g_SRSpeechLoaded.set();
return true;
#elif defined(__APPLE__)
Expand Down Expand Up @@ -96,7 +96,9 @@ bool ScreenReaderLoad() {
void ScreenReaderUnload() {
if (!g_SRSpeechLoaded) return;
#if defined(_WIN32)
__try {
Tolk_Unload();
} __except(1) {}
g_SRSpeechLoaded.reset();
#elif defined(__APPLE__)
voice_over_speech_shutdown(); // Really just stops a hacky thread intended to get speech event queuing working.
Expand Down

0 comments on commit 436021f

Please sign in to comment.