diff --git a/AdvancedDockingSystem/src/ContainerWidget.cpp b/AdvancedDockingSystem/src/ContainerWidget.cpp index 06a4f3a..36e8ea7 100644 --- a/AdvancedDockingSystem/src/ContainerWidget.cpp +++ b/AdvancedDockingSystem/src/ContainerWidget.cpp @@ -70,17 +70,6 @@ ContainerWidget::~ContainerWidget() SectionWidget* ContainerWidget::addSectionContent(const SectionContent::RefPtr& sc, SectionWidget* sw, DropArea area) { ADS_Expects(!sc.isNull()); - if (!sw) - { - if (_sections.isEmpty()) - { // Create default section - sw = newSectionWidget(); - addSection(sw); - } - else if (area == CenterDropArea) - // Use existing default section - sw = _sections.first(); - } // Drop it based on "area" InternalContentData data; @@ -496,6 +485,14 @@ SectionWidget* ContainerWidget::dropContent(const InternalContentData& data, Sec SectionWidget* ret = NULL; + // If no sections exists yet, create a default one and always drop into it. + if (_sections.count() <= 0) + { + targetSection = newSectionWidget(); + addSection(targetSection); + area = CenterDropArea; + } + // Drop on outer area if (!targetSection) { diff --git a/AdvancedDockingSystemDemo/src/mainwindow.cpp b/AdvancedDockingSystemDemo/src/mainwindow.cpp index f5cf501..a6fd951 100644 --- a/AdvancedDockingSystemDemo/src/mainwindow.cpp +++ b/AdvancedDockingSystemDemo/src/mainwindow.cpp @@ -116,9 +116,9 @@ MainWindow::MainWindow(QWidget *parent) : } // ADS - Adding some contents. - // Test #1: Use high-level public API if (true) { + // Test #1: Use high-level public API ADS_NS::ContainerWidget* cw = _container; ADS_NS::SectionWidget* sw = NULL; @@ -131,6 +131,20 @@ MainWindow::MainWindow(QWidget *parent) : _container->addSectionContent(createLongTextLabelSC(_container)); _container->addSectionContent(createLongTextLabelSC(_container)); } + else if (false) + { + // Issue #2: If the first drop is not into CenterDropArea, the application crashes. + ADS_NS::ContainerWidget* cw = _container; + ADS_NS::SectionWidget* sw = NULL; + + sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::LeftDropArea); + sw = _container->addSectionContent(createCalendarSC(cw), sw, ADS_NS::LeftDropArea); + sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::CenterDropArea); + sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::CenterDropArea); + sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::CenterDropArea); + sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::RightDropArea); + sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::BottomDropArea); + } // Default window geometry resize(800, 600);