Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
5.2.1
-
None
-
Win7 x64, Qt5.2.1, MSVC2012
Description
This code will crash with a null ptr access.
test.h
#ifndef TEST_H #define TEST_H #include <QObject> class Test : public QObject { Q_OBJECT public: explicit Test(QObject *parent = 0); signals: public slots: void testSlot(); }; extern Test issue; #endif // TEST_H
test.cpp
#include "test.h" #include <QMetaMethod> Test issue; Test::Test(QObject *parent) : QObject(parent) { const QMetaObject* object = metaObject(); QByteArray normalizedSignature = QMetaObject::normalizedSignature( "testSlot()" ); int methodIndex = object->indexOfMethod( normalizedSignature ); QMetaMethod method = object->method( methodIndex ); } void Test::testSlot() { }
main.cpp
#include "test.h" int main(int argc, char *argv[]) { return 0; }
If this is not fixed immediately, at least it should be documented with metaObject() that it may not be used under the conditions as shown above.
Also, instead of just crashing, a valid error message should be displayed.
Additionally, there should be a note here about the issue:
http://qt-project.org/doc/qt-5/qmetamethod.html#invoke
(I basically copied the crashing code from that place of the documentation.)
Attachments
Issue Links
- relates to
-
QTBUG-73318 [qt widgets] qRegisterWidgetsVariant() order of initialization
- Closed
-
QTBUG-69963 Library initialization function crashes on win when called from loading QML plugin
- Closed