mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-24 05:22:06 +08:00
fixes #20 crash on-show.
checks for _sections.count() > 0 in dropContent() and creates first SectionWidget, if needed.
This commit is contained in:
parent
0be013bca2
commit
0317c3ebeb
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user