Fix two anchors following each other
This commit is contained in:
@@ -329,9 +329,7 @@ void AnchorGroup::turnIntoPlaceholder()
|
||||
if (!right->isStatic())
|
||||
right->setPosition(right->position() - ((right->position() - left->position()) / 2));
|
||||
left->setFollowee(right);
|
||||
}
|
||||
|
||||
if (right->shouldFollow()) {
|
||||
} else if (right->shouldFollow()) {
|
||||
right->setFollowee(left);
|
||||
}
|
||||
|
||||
@@ -340,10 +338,7 @@ void AnchorGroup::turnIntoPlaceholder()
|
||||
if (!bottom->isStatic())
|
||||
bottom->setPosition(bottom->position() - ((bottom->position() - top->position()) / 2));
|
||||
top->setFollowee(bottom);
|
||||
}
|
||||
|
||||
|
||||
if (bottom->shouldFollow()) {
|
||||
} else if (bottom->shouldFollow()) {
|
||||
bottom->setFollowee(top);
|
||||
}
|
||||
|
||||
|
||||
@@ -742,6 +742,17 @@ void MultiSplitterLayout::setAnchorBeingDragged(Anchor *anchor)
|
||||
m_anchorBeingDragged = anchor;
|
||||
}
|
||||
|
||||
int MultiSplitterLayout::numAchorsFolllowing() const
|
||||
{
|
||||
int count = 0;
|
||||
for (Anchor *a : m_anchors) {
|
||||
if (a->isFollowing())
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
Anchor *MultiSplitterLayout::staticAnchor(Anchor::Type type) const
|
||||
{
|
||||
if (type == Anchor::Type_TopStatic)
|
||||
|
||||
@@ -193,6 +193,9 @@ public:
|
||||
///@brief returns list of separators
|
||||
const Anchor::List anchors() const { return m_anchors; }
|
||||
|
||||
///@brief returns the number of anchors that are following others, just for tests.
|
||||
int numAchorsFolllowing() const;
|
||||
|
||||
///@brief returns either the left, top, right or bottom separator, depending on the @p type
|
||||
Anchor *staticAnchor(Anchor::Type type) const;
|
||||
|
||||
|
||||
@@ -286,6 +286,7 @@ private Q_SLOTS:
|
||||
void tst_placeholderDisappearsOnReadd();
|
||||
void tst_placeholdersAreRemovedPropertly();
|
||||
void tst_embeddedMainWindow();
|
||||
void tst_toggleMiddleDockCrash(); // tests some crash I got
|
||||
private:
|
||||
void tst_restoreEmpty(); // TODO. Disabled for now, save/restore needs to support placeholders
|
||||
void tst_restoreCrash(); // TODO. Disabled for now, save/restore needs to support placeholders
|
||||
@@ -2495,6 +2496,39 @@ void TestDocks::tst_embeddedMainWindow()
|
||||
|
||||
}
|
||||
|
||||
void TestDocks::tst_toggleMiddleDockCrash()
|
||||
{
|
||||
EnsureTopLevelsDeleted e;
|
||||
auto m = createMainWindow(QSize(800, 500), MainWindowOption_None); // Remove central frame
|
||||
auto dropArea = qobject_cast<DropArea*>(m->centralWidget());
|
||||
MultiSplitterLayout *layout = dropArea->multiSplitter();
|
||||
QPointer<DockWidget> dock1 = createDockWidget(QStringLiteral("1"), new QPushButton(QStringLiteral("1")));
|
||||
QPointer<DockWidget> dock2 = createDockWidget(QStringLiteral("2"), new QPushButton(QStringLiteral("2")));
|
||||
QPointer<DockWidget> dock3 = createDockWidget(QStringLiteral("3"), new QPushButton(QStringLiteral("3")));
|
||||
|
||||
m->addDockWidget(dock1, Location_OnLeft);
|
||||
m->addDockWidget(dock2, Location_OnRight);
|
||||
m->addDockWidget(dock3, Location_OnRight);
|
||||
|
||||
QCOMPARE(layout->count(), 3);
|
||||
QCOMPARE(layout->placeholderCount(), 0);
|
||||
|
||||
auto frame = dock2->frame();
|
||||
dock2->close();
|
||||
QVERIFY(waitForDeleted(frame));
|
||||
|
||||
QCOMPARE(layout->count(), 3);
|
||||
QCOMPARE(layout->placeholderCount(), 1);
|
||||
QVERIFY(layout->checkSanity());
|
||||
QCOMPARE(layout->numAchorsFolllowing(), 1);
|
||||
|
||||
|
||||
delete dock2;
|
||||
|
||||
|
||||
//dock2->show();
|
||||
}
|
||||
|
||||
// QTest::qWait(50000)
|
||||
|
||||
QTEST_MAIN(KDDockWidgets::TestDocks)
|
||||
|
||||
Reference in New Issue
Block a user