Avoid adding a gui-client while another is being removed
Fixes the crash in kate_view_mgmt_tests if toolbar of the mainwindow is visible:
#0 0x7f2665ffe8e6 in KXMLGUI::ContainerNode::findChildContainerClient(KXMLGUIClient*, QString const&, QList<KXMLGUI::MergingIndex>::iterator const&) kxmlgui/src/kxmlguifactory_p.cpp
#1 0x7f2666005935 in KXMLGUI::BuildHelper::processActionOrCustomElement(QDomElement const&, bool) kxmlgui/src/kxmlguifactory_p.cpp:539:35
#2 0x7f26660054d9 in KXMLGUI::BuildHelper::processElement(QDomElement const&) kxmlgui/src/kxmlguifactory_p.cpp:518:9
#3 0x7f2666004e78 in KXMLGUI::BuildHelper::build(QDomElement const&) kxmlgui/src/kxmlguifactory_p.cpp:506:9
#4 0x7f26660073fe in KXMLGUI::BuildHelper::processContainerElement(QDomElement const&, QString const&, QString const&) kxmlgui/src/kxmlguifactory_p.cpp:766:41
#5 0x7f2666005607 in KXMLGUI::BuildHelper::processElement(QDomElement const&) kxmlgui/src/kxmlguifactory_p.cpp:520:9
#6 0x7f2666004e78 in KXMLGUI::BuildHelper::build(QDomElement const&) kxmlgui/src/kxmlguifactory_p.cpp:506:9
#7 0x7f2665fe3711 in KXMLGUIFactory::addClient(KXMLGUIClient*) kxmlgui/src/kxmlguifactory.cpp:231:36
#8 0x7f26670b2a42 in KateViewManager::activateView(KTextEditor::View*) kate/apps/lib/kateviewmanager.cpp:863:41
#9 0x7f26670b1d46 in KateViewManager::activateSpace(KTextEditor::View*) kate/apps/lib/kateviewmanager.cpp:818:9
#10 0x7f26670c40ea in QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, QtPrivate::List<KTextEditor::View*>, void, void (KateViewManager::*)(KTextEditor::View*)>::call(void (KateViewManager::*)(KTextEditor::View*), KateViewManager*, void**) /usr/include/qt6/QtCore/qobjectdefs_impl.h:145:13
#11 0x7f26670c40ea in void QtPrivate::FunctionPointer<void (KateViewManager::*)(KTextEditor::View*)>::call<QtPrivate::List<KTextEditor::View*>, void>(void (KateViewManager::*)(KTextEditor::View*), KateViewManager*, void**) /usr/include/qt6/QtCore/qobjectdefs_impl.h:182:13
#12 0x7f26670c40ea in QtPrivate::QCallableObject<void (KateViewManager::*)(KTextEditor::View*), QtPrivate::List<KTextEditor::View*>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) /usr/include/qt6/QtCore/qobjectdefs_impl.h:520:21
#13 0x7f2662790ca8 (/usr/lib/libQt6Core.so.6+0x190ca8)
#14 0x7f2666a60489 in KTextEditor::View::focusIn(KTextEditor::View*) KF6TextEditor_autogen/include/moc_view.cpp:607:5
#15 0x7f266686b161 in KTextEditor::ViewPrivate::slotGotFocus() ktexteditor/src/view/kateview.cpp:1633:12
#16 0x7f26668e2ce4 in KateViewInternal::focusInEvent(QFocusEvent*) ktexteditor/src/view/kateviewinternal.cpp:4156:13
#17 0x7f2663744c04 in QWidget::event(QEvent*) (/usr/lib/libQt6Widgets.so.6+0x144c04)
#18 0x7f26636f438a in QApplicationPrivate::notify_helper(QObject*, QEvent*) (/usr/lib/libQt6Widgets.so.6+0xf438a)
#19 0x7f2662739817 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (/usr/lib/libQt6Core.so.6+0x139817)
#20 0x7f26637003e1 (/usr/lib/libQt6Widgets.so.6+0x1003e1)
#21 0x7f266374b5bc (/usr/lib/libQt6Widgets.so.6+0x14b5bc)
#22 0x7f26637360aa in QWidget::focusNextPrevChild(bool) (/usr/lib/libQt6Widgets.so.6+0x1360aa)
#23 0x7f266373ed35 in QWidgetPrivate::hide_helper() (/usr/lib/libQt6Widgets.so.6+0x13ed35)
#24 0x7f2663740317 in QWidgetPrivate::setVisible(bool) (/usr/lib/libQt6Widgets.so.6+0x140317)
#25 0x7f266391ad71 (/usr/lib/libQt6Widgets.so.6+0x31ad71)
#26 0x7f2663919feb in QToolBar::actionEvent(QActionEvent*) (/usr/lib/libQt6Widgets.so.6+0x319feb)
#27 0x7f2665fb1121 in KToolBar::actionEvent(QActionEvent*) kxmlgui/src/ktoolbar.cpp:1414:15
#28 0x7f2663744706 in QWidget::event(QEvent*) (/usr/lib/libQt6Widgets.so.6+0x144706)
#29 0x7f26636f438a in QApplicationPrivate::notify_helper(QObject*, QEvent*) (/usr/lib/libQt6Widgets.so.6+0xf438a)
#30 0x7f2662739817 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (/usr/lib/libQt6Core.so.6+0x139817)
#31 0x7f266372e736 in QWidget::removeAction(QAction*) (/usr/lib/libQt6Widgets.so.6+0x12e736)
#32 0x7f2666000558 in KXMLGUI::ContainerNode::removeActions(QList<QAction*> const&) kxmlgui/src/kxmlguifactory_p.cpp:377:24
#33 0x7f2666002132 in KXMLGUI::ContainerNode::unplugClient(KXMLGUI::ContainerClient*) kxmlgui/src/kxmlguifactory_p.cpp:399:5
#34 0x7f26660016d9 in KXMLGUI::ContainerNode::unplugActions(KXMLGUI::BuildState&) kxmlgui/src/kxmlguifactory_p.cpp:363:13
#35 0x7f2666000839 in KXMLGUI::ContainerNode::destruct(QDomElement, KXMLGUI::BuildState&) kxmlgui/src/kxmlguifactory_p.cpp:288:5
#36 0x7f266600119c in KXMLGUI::ContainerNode::destructChildren(QDomElement const&, KXMLGUI::BuildState&) kxmlgui/src/kxmlguifactory_p.cpp:328:24
#37 0x7f266600082e in KXMLGUI::ContainerNode::destruct(QDomElement, KXMLGUI::BuildState&) kxmlgui/src/kxmlguifactory_p.cpp:286:5
#38 0x7f2665fe47ab in KXMLGUIFactory::removeClient(KXMLGUIClient*) kxmlgui/src/kxmlguifactory.cpp:423:20
#39 0x7f26670b33b9 in KateViewManager::deleteView(KTextEditor::View*) kate/apps/lib/kateviewmanager.cpp:733:37
#40 0x7f26670d97a2 in KateViewSpace::closeDocument(KTextEditor::Document*) kate/apps/lib/kateviewspace.cpp:602:28
#41 0x7f26670cfc91 in KateViewSpace::closeTabRequest(int) kate/apps/lib/kateviewspace.cpp:795:5
#42 0x5590a07a1a8a in KateViewManagementTests::testBug465811() kate/apps/lib/autotests/kate_view_mgmt_tests.cpp:538:10
#43 0x5590a07a5335 in KateViewManagementTests::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /home/waqar/kde/build/utilities/kate/apps/lib/autotests/kate_view_mgmt_tests_autogen/include/moc_kate_view_mgmt_tests.cpp:295:22
#44 0x7f266274e6c4 in QMetaMethodInvoker::invokeImpl(QMetaMethod, void*, Qt::ConnectionType, long long, void const* const*, char const* const*, QtPrivate::QMetaTypeInterface const* const*) (/usr/lib/libQt6Core.so.6+0x14e6c4)
#45 0x7f266274ea1b in QMetaMethod::invokeImpl(QMetaMethod, void*, Qt::ConnectionType, long long, void const* const*, char const* const*, QtPrivate::QMetaTypeInterface const* const*) (/usr/lib/libQt6Core.so.6+0x14ea1b)
#46 0x7f26643231f9 (/usr/lib/libQt6Test.so.6+0x221f9)
#47 0x7f266432e97d in QTest::qRun() (/usr/lib/libQt6Test.so.6+0x2d97d)
#48 0x7f266432638e in QTest::qExec(QObject*, int, char**) (/usr/lib/libQt6Test.so.6+0x2538e)
#49 0x5590a0799262 in main kate/apps/lib/autotests/kate_view_mgmt_tests.cpp:19:1
#50 0x7f2662043ccf (/usr/lib/libc.so.6+0x29ccf)
#51 0x7f2662043d89 in __libc_start_main (/usr/lib/libc.so.6+0x29d89)
#52 0x5590a0684134 in _start (kate_view_mgmt_tests+0x7f134)
Edited by Waqar Ahmed