From e019c9f61edf20c433ac4bf2e3546ce9b5c1104a Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Mon, 16 Jan 2017 19:11:07 +0100 Subject: [PATCH] [TabBox] Remember current model index on SwitcherItem model set In case we need to set the SwitcherItem model in `TabBoxHandlerPrivate::show()`, remember the current index row, otherwise it gets reset to the first item. Reviewers: #kwin, graesslin Tags: #kwin Differential Revision: https://phabricator.kde.org/D4162 BUG: 333511 --- tabbox/tabboxhandler.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tabbox/tabboxhandler.cpp b/tabbox/tabboxhandler.cpp index 90681748bd..afaf5a12f2 100644 --- a/tabbox/tabboxhandler.cpp +++ b/tabbox/tabboxhandler.cpp @@ -323,6 +323,9 @@ void TabBoxHandlerPrivate::show() } } if (SwitcherItem *item = switcherItem()) { + // In case the model isn't yet set (see below), index will be reset and therefore we + // need to save the current index row (https://bugs.kde.org/show_bug.cgi?id=333511). + int indexRow = index.row(); if (!item->model()) { QAbstractItemModel *model = nullptr; if (desktopMode) { @@ -333,7 +336,7 @@ void TabBoxHandlerPrivate::show() item->setModel(model); } item->setAllDesktops(config.clientDesktopMode() == TabBoxConfig::AllDesktopsClients); - item->setCurrentIndex(index.row()); + item->setCurrentIndex(indexRow); // everything is prepared, so let's make the whole thing visible item->setVisible(true); }