From 932f4dc0ab54e33b7724e74d394da1eeac1b594f Mon Sep 17 00:00:00 2001 From: Carmen Alvarez Date: Sun, 13 Feb 2022 15:37:38 +0100 Subject: [PATCH 1/2] Fix compilation error casting `QString` to `QLocale`. When building qtspeech against Qt 6.2.3, we see the below compilation error. ``` qtexttospeech_osx.mm:192:12: error: no viable conversion from returned value of type 'QString' to function return type 'QLocale' return QString::fromNSString(attrs[NSVoiceLocaleIdentifier]); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/jdoe/dev/Qt/6.2.3/macos/lib/QtCore.framework/Headers/qlocale.h:930:5: note: candidate constructor not viable: no known conversion from 'QString' to 'QLocale::Language' for 1st argument QLocale(Language language, Script script = AnyScript, Territory territory = AnyTerritory); ^ /Users/jdoe/dev/Qt/6.2.3/macos/lib/QtCore.framework/Headers/qlocale.h:931:5: note: candidate constructor not viable: no known conversion from 'QString' to 'const QLocale &' for 1st argument QLocale(const QLocale &other); ^ /Users/jdoe/dev/Qt/6.2.3/macos/lib/QtCore.framework/Headers/qlocale.h:1129:5: note: candidate constructor not viable: no known conversion from 'QString' to 'QLocalePrivate &' for 1st argument QLocale(QLocalePrivate &dd); ^ /Users/jdoe/dev/Qt/6.2.3/macos/lib/QtCore.framework/Headers/qlocale.h:928:14: note: explicit constructor is not a candidate explicit QLocale(const QString &name); ^ 1 error generated. ``` To prevent this error, use the `QLocale(QString)` constructor. --- src/plugins/tts/osx/qtexttospeech_osx.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/tts/osx/qtexttospeech_osx.mm b/src/plugins/tts/osx/qtexttospeech_osx.mm index fe6a260a..32578bd7 100644 --- a/src/plugins/tts/osx/qtexttospeech_osx.mm +++ b/src/plugins/tts/osx/qtexttospeech_osx.mm @@ -189,7 +189,7 @@ - (void)speechSynthesizer:(NSSpeechSynthesizer *)sender didFinishSpeaking:(BOOL) QLocale localeForVoice(NSString *voice) { NSDictionary *attrs = [NSSpeechSynthesizer attributesForVoice:voice]; - return QString::fromNSString(attrs[NSVoiceLocaleIdentifier]); + return QLocale(QString::fromNSString(attrs[NSVoiceLocaleIdentifier])); } QVoice QTextToSpeechEngineOsx::voiceForNSVoice(NSString *voiceString) const From c6f91adf95c618b7674aa2a8d001f4e0416a921a Mon Sep 17 00:00:00 2001 From: Carmen Alvarez Date: Sun, 13 Feb 2022 11:32:12 +0100 Subject: [PATCH 2/2] Fix windows compilation error regarding missing `POINTER_*` types When building qtspeech against Qt 6.2.3, mingw_64, we see the below compilation error. ``` In file included from C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/windows.h:72, from C:/Qt/6.2.3/mingw_64/include/QtCore/qt_windows.h:64, from qtexttospeech_sapi.h:40, from qtexttospeech_sapi.cpp:37: C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:43: error: variable 'CreateSyntheticPointerDevice' definition is marked dllimport 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYPE pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:72: error: 'POINTER_INPUT_TYPE' was not declared in this scope; did you mean 'PRINTER_FONTTYPE'? 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYP pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode); | ^~~~~~~~~~~~~~~~~ | PRINTER_FONTTYPE C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:110: error: expected primary-expression before 'maxCount' 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYPE pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode); | ^~~~~~~~ C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:120: error: 'POINTER_FEEDBACK_MODE' was not declared in this scope 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYPE pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode); | ^~~~~~~~~~~~~~~~~~~~~ C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:146: error: expression list treated as compound expression in initializer [-fpermissive] 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYPE pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode); | ^ C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2966:93: error: 'POINTER_TYPE_INFO' does not name a type; did you mean 'POINTER_64_INT'? 2966 | WINUSERAPI WINBOOL WINAPI InjectSyntheticPointerInput(HSYNTHETICPOINTERDEVICE device, CONST POINTER_TYPE_INFO* pointerInfo, UINT32 count); | ^~~~~~~~~~~~~~~~~ | POINTER_64_INT ``` Based on a tip mentioned in a related issue [QTEXT-14](https://bugreports.qt.io/projects/QTEXT/issues/QTEXT-14), workaround this by including `windows.h`, before including `qt_windows.h`. --- src/plugins/tts/sapi/qtexttospeech_sapi.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/tts/sapi/qtexttospeech_sapi.h b/src/plugins/tts/sapi/qtexttospeech_sapi.h index 790660bd..4e540721 100644 --- a/src/plugins/tts/sapi/qtexttospeech_sapi.h +++ b/src/plugins/tts/sapi/qtexttospeech_sapi.h @@ -37,6 +37,7 @@ #ifndef QTEXTTOSPEECHENGINE_SAPI_H #define QTEXTTOSPEECHENGINE_SAPI_H +#include #include #include