QtAndroidTools icon indicating copy to clipboard operation
QtAndroidTools copied to clipboard

Compilation errors with Qt6.7.0

Open NielsMayer opened this issue 1 year ago • 1 comments

With Qt6.7.0-beta1 you get compilation errors like

"error: cannot pass object of non-trivial type 'QtJniTypes::Context' through variadic constructor; call will abort at runtime [-Wnon-pod-varargs]"

Which can be fixed by changing all instances of

QNativeInterface::QAndroidApplication::context()

with

QNativeInterface::QAndroidApplication::context().object<jobject>()

The following patch allows QtAndroidTools to compile successfully with Qt6.7.0 QtAndroidTools.patch.txt

One question is whether QNativeInterface::QAndroidApplication::context().object() is more or less "correct" than the above expression that specifically returns a jobject, whereas object() may cause additional implicit conversions. What's your opinion?

I actually had this problem with my own software and decided to see whether the error was specific to my odd configurations, or whether it also affected QtAndroidTools. See comments in my header that creates abstractions for Android calls in Qt5 and Qt6:

QAndroidCompat.h.txt

NielsMayer avatar Dec 20 '23 19:12 NielsMayer

Hi

I didn't try version 6.7 because I always wait for the final release instead to test beta versions. This because changes can occurs until final release. However this error is a bit strange because based to the documentation here the method

QNativeInterface::QAndroidApplication::context()

should return directly a native jobject type. However this is the documentation of current 6.6.1 version, I should check what is changed as return value to the 6.7 version. From your code it seems it return an object instead of a native type as current one do.

FalsinSoft avatar Dec 20 '23 20:12 FalsinSoft

I fixed this error by changing the code in a compatible way. All changes has been already committed.

FalsinSoft avatar Apr 19 '24 18:04 FalsinSoft