Details
-
Bug
-
Resolution: Done
-
P2: Important
-
Qt Creator 4.10.1, Qt Creator 4.11.0-rc1
-
1ab9dc946410e96e0e211347e9d9127740ab18dd (qt-creator/qt-creator/4.11)
Description
"Convert to Stack Variable" and "convert to Pointer" generates invalid code
Case 1. (Convert to Stack Variable) from: QObject *obj = new QObject(this); to: QObject obj = this; expected: QObject obj(this); Case 2. (Convert to Stack Variable) from: QObject *obj = new QObject{this}; to: QObject obj; expected: QObject obj{this}; Case 3. (Convert to Stack Variable) from: QByteArray *buf = new QByteArray("text", 4); to: QByteArray buf = "text", 4; expected: QByteArray buf("text", 4); Case 4. (Convert to Stack Variable) from: QByteArray *buf = new QByteArray{"text", 4}; to: QByteArray buf; expected: QByteArray buf{"text", 4}; Case 5. (Convert to Pointer) from: QObject obj; to: QObject *obj; expected: QObject *obj = new QObject; Case 6. (Convert to Pointer) from: QObject obj{this}; to: QObject *obj{this}; expected: QObject *obj = new QObject{this};
Even the documentation at https://doc.qt.io/qtcreator/creator-editor-refactoring.html needs to be updated as it is not in sync with current behaviour.