diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-08-08 02:18:53 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-08-26 23:07:22 +0200 |
commit | 7a5f865186b3dd831c5943ca6050437fc17abb87 (patch) | |
tree | 26e4082839e6686b57090891869833e0fb7a9a05 /src/widgets/widgets/qmainwindowlayout.cpp | |
parent | fded035b1c808ece70cd49e27efd3f0e74f90ffc (diff) |
QLayout::indexOf: redo implementation
Stop relying on the "magic" of itemAt returning nullptr for out of
bounds. Just use count().
Unfortunately, QMainWindowLayout breaks the API contract by NOT
implementing count() properly. So, make its count() crash if called;
and move the itemAt implementation there.
Change-Id: I120686a834bab15dd537598a56bd93d6a5924aa5
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/widgets/qmainwindowlayout.cpp')
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 017e33692b..76d9a33e06 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -1895,8 +1895,10 @@ void QMainWindowLayout::raise(QDockWidget *widget) int QMainWindowLayout::count() const { - qWarning("QMainWindowLayout::count: ?"); - return 0; //################################################# + int result = 0; + while (itemAt(result)) + ++result; + return result; } QLayoutItem *QMainWindowLayout::itemAt(int index) const |