diff --git a/src/DockAreaTabBar.cpp b/src/DockAreaTabBar.cpp index 374fd79..9e00c30 100644 --- a/src/DockAreaTabBar.cpp +++ b/src/DockAreaTabBar.cpp @@ -199,6 +199,7 @@ void CDockAreaTabBar::startFloating(const QPoint& Pos) //============================================================================ void CDockAreaTabBar::setCurrentIndex(int index) { + std::cout << "CDockAreaTabBar::setCurrentIndex " << index << std::endl; if (index == d->CurrentIndex) { return; @@ -267,6 +268,7 @@ void CDockAreaTabBar::insertTab(int Index, CDockWidgetTab* Tab) //=========================================================================== void CDockAreaTabBar::removeTab(CDockWidgetTab* Tab) { + std::cout << "CDockAreaTabBar::removeTab " << std::endl; d->TabsLayout->removeWidget(Tab); disconnect(Tab, SIGNAL(clicked()), this, SLOT(onTabClicked())); d->MenuOutdated = true; @@ -297,6 +299,10 @@ void CDockAreaTabBar::onTabClicked() } int index = d->TabsLayout->indexOf(Tab); + if (index < 0) + { + return; + } setCurrentIndex(index); std::cout << "emit tabBarClicked " << index << std::endl; emit tabBarClicked(index); diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 291933c..a458a85 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -159,6 +159,7 @@ public: void insertWidget(int index, QWidget* Widget) { + Widget->setParent(0); if (index < 0) { index = m_Widgets.count(); @@ -643,7 +644,8 @@ void CDockAreaWidget::setCurrentIndex(int index) emit currentChanging(index); d->TabBar->setCurrentIndex(index); - auto Features = d->TabBar->currentTab()->dockWidget()->features(); + CDockWidgetTab* CurrentTab = d->TabBar->currentTab(); + auto Features = CurrentTab->dockWidget()->features(); d->CloseButton->setVisible(Features.testFlag(CDockWidget::DockWidgetClosable)); if (!dockManager()->isRestoringState()) diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index dadfe6f..c328b7e 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -255,9 +255,9 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin if (area == CenterDockWidgetArea) { auto NewDockWidgets = FloatingContainer->dockWidgets(); - for (auto DockWidget : NewDockWidgets) + for (int i = 0; i < NewDockWidgets.count(); ++i) { - TargetArea->insertDockWidget(0, DockWidget, false); + TargetArea->insertDockWidget(i, NewDockWidgets[i], false); } TargetArea->setCurrentIndex(0); // make the topmost widget active FloatingWidget->deleteLater();