ohos: Handle possible listVoices() error


listVoices() returned an empty vector both when the engine reported no
voices and when the query failed, so the caller could not tell the two
cases apart. Return std::optional instead and leave it unset on failure.

The engine constructor now reports that failure through setError(),
which fills errorReason() and errorString() and moves the engine to
QTextToSpeech::Error. Errors for speak() and stop() are delivered by the
JS engine's onError() callback and already go through setError(), so
both paths now converge on the same error state.

Task-number: QTBUG-147179
Pick-to: 6.12
Change-Id: Ie7871a3740526848a036123d93c49aeadbe9bd8e
Reviewed-by: Dawid Śliwa <dawid.sliwa@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
commit989bb80265213e87371d24374f2fd77bdbb1974e
parentccb7c564471ce1c543769cb43b30ed7f6f4318fb
authorArkadiusz Zarębski <arkadiusz.zarebski@qt.io>
committerArkadiusz Zarębski <arkadiusz.zarebski@qt.io>
commit timeThu, 17 Sep 2026 08:34:00 +0000