rbutilqt: Add error handling to TTSCarbon::generateSettings()

Co-authored-by: ChatGPT (GPT-5.3 Mini) <chatgpt@openai.com>
Change-Id: Iad04028853e930b508e72c2c9c3e9ebd9504d4bb
This commit is contained in:
Vencislav Atanasov 2026-06-29 22:28:35 +03:00
parent 92d62cf6ac
commit 1039eb305a

View file

@ -117,18 +117,33 @@ void TTSCarbon::generateSettings(void)
// get system voice
error = GetVoiceDescription(NULL, &vdesc, sizeof(vdesc));
if (error != 0) {
LOG_ERROR() << "GetVoiceDescription() failed with code" << error;
return;
}
systemVoice
= QString::fromLocal8Bit((const char*)&vdesc.name[1], vdesc.name[0]);
// get list of all voices
CountVoices(&numVoices);
for(SInt16 i = 1; i < numVoices; ++i) {
error = GetIndVoice(i, &vspec);
if (error != 0) {
LOG_ERROR() << "GetIndVoice(" << i << ") failed with code" << error;
continue;
}
error = GetVoiceDescription(&vspec, &vdesc, sizeof(vdesc));
if (error != 0) {
LOG_ERROR() << "GetVoiceDescription(" << i << ") failed with code" << error;
continue;
}
// name is pascal string, i.e. the first byte is the length.
QString name
= QString::fromLocal8Bit((const char*)&vdesc.name[1], vdesc.name[0]);
voiceNames.append(name.trimmed());
}
if (voiceNames.isEmpty()) {
return;
}
// voice
EncTtsSetting* setting;
QString voice