Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. mismatched allocation function compiler warning during qmlRegisterType

mismatched allocation function compiler warning during qmlRegisterType

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 288 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ocgltdO Offline
    ocgltdO Offline
    ocgltd
    wrote on last edited by ocgltd
    #1

    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)

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved