Details
-
Bug
-
Resolution: Unresolved
-
P4: Low
-
None
-
6.6.2
-
None
Description
InsertWidget on a layout results in a segfault if index is too big. Minimal example:
#include <QtWidgets> class MyDialog : public QDialog { public: MyDialog(QWidget *parent = nullptr) : QDialog(parent) { QVBoxLayout *layout_1 = new QVBoxLayout(this); layout_1->insertWidget(1, new QLabel("aaa", this)); } }; int main(int argc, char *argv[]) { QApplication qt_app(argc, argv); MyDialog window; window.show(); return qt_app.exec(); }
It works correctly if index is 0. This is confusing, as documentation says: "Inserts widget at position index, with stretch factor stretch and alignment alignment. If index is negative, the widget is added at the end." , which does not suggest any restrictions on index. I think a segfault is a very ugly way of handling it, some sort of more descriptive error would make debugging much easier.
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-130275 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
599981,3 | QBoxLayout: don't crash on passing invalid index | dev | qt/qtbase | Status: NEW | 0 | 0 |