mismatched allocation function compiler warning during qmlRegisterType
Unsolved
QML and Qt Quick
-
I have created a couple of C++ classes which I expose to QML using the following code in main.cpp:
qmlRegisterType<GUIConstants> ("GUIConstants",1,0,"GUIConstants"); qmlRegisterType<GUIManager> ("GUIManager",1,0,"GUIManager");
THe program runs fine, but both lines above give me a compilation warning about mismatched allocation function:
/opt/Qt/5.15.2/gcc_64/include/QtQml/qqmlprivate.h:166: warning: ‘static void QQmlPrivate::QQmlElement<T>::operator delete(void*, void*) [with T = GUIConstants]’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete] In file included from /opt/Qt/5.15.2/gcc_64/include/QtQml/qqml.h:43, from /opt/Qt/5.15.2/gcc_64/include/QtQml/qqmlengine.h:47, from /opt/Qt/5.15.2/gcc_64/include/QtQml/qqmlapplicationengine.h:43, from /opt/Qt/5.15.2/gcc_64/include/QtQml/QQmlApplicationEngine:1, from ../overseer-gui/main.cpp:2: /opt/Qt/5.15.2/gcc_64/include/QtQml/qqmlprivate.h: In function ‘void QQmlPrivate::createInto(void*) [with T = GUIConstants]’: /opt/Qt/5.15.2/gcc_64/include/QtQml/qqmlprivate.h:166:37: warning: ‘static void QQmlPrivate::QQmlElement<T>::operator delete(void*, void*) [with T = GUIConstants]’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete] 166 | void createInto(void *memory) { new (memory) QQmlElement<T>; } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /opt/Qt/5.15.2/gcc_64/include/QtQml/qqmlprivate.h:166:37: note: returned from ‘void* operator new(std::size_t, void*)’
Can someone help with what is wrong? (I get 2 errors, one for GUIConstants and one for GUIManager, so I assume it's these two lines)