sw/qa/core/txtnode/txtnode.cxx | 12 ++++++++++++ sw/source/core/txtnode/thints.cxx | 7 +++++-- 2 files changed, 17 insertions(+), 2 deletions(-)
New commits: commit 00ce7545bd85193929ffec3787b7cea7932d8e1f Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Jun 9 14:23:11 2022 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Jun 13 14:24:01 2022 +0200 sw content controls: fix crash on trying to insert nested dropdown This went wrong in commit 3dd4f3691458ea537bc1867386269694775cfbcb (sw content controls: add document model, 2022-03-30). (cherry picked from commit 51eb7b837996384d0155c0841bf69cf068bbe367) Change-Id: I8040e02975d1f98cc01ef6f8a22745f27afa5276 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135571 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx index ed8759112ae1..ad44a12f7c9b 100644 --- a/sw/qa/core/txtnode/txtnode.cxx +++ b/sw/qa/core/txtnode/txtnode.cxx @@ -24,6 +24,7 @@ #include <wrtsh.hxx> #include <unotxdoc.hxx> #include <docsh.hxx> +#include <formatcontentcontrol.hxx> constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/core/txtnode/data/"; @@ -208,6 +209,17 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testSplitNodeSuperscriptCopy) CPPUNIT_ASSERT(!aSet.HasItem(RES_CHRATR_ESCAPEMENT)); } +CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testInsertDropDownContentControlTwice) +{ + // Given an already selected dropdown content control: + SwDoc* pDoc = createSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->InsertContentControl(SwContentControlType::DROP_DOWN_LIST); + + // When trying to insert an inner one, make sure that we don't crash: + pWrtShell->InsertContentControl(SwContentControlType::DROP_DOWN_LIST); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 71d0263850d2..f5f1a1e7b469 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -107,11 +107,14 @@ SwpHints::SwpHints(const SwTextNode& rParent) static void TextAttrDelete( SwDoc & rDoc, SwTextAttr * const pAttr ) { if (RES_TXTATR_META == pAttr->Which() || - RES_TXTATR_METAFIELD == pAttr->Which() || - pAttr->Which() == RES_TXTATR_CONTENTCONTROL) + RES_TXTATR_METAFIELD == pAttr->Which()) { static_txtattr_cast<SwTextMeta *>(pAttr)->ChgTextNode(nullptr); // prevents ASSERT } + else if (pAttr->Which() == RES_TXTATR_CONTENTCONTROL) + { + static_txtattr_cast<SwTextContentControl*>(pAttr)->ChgTextNode(nullptr); + } SwTextAttr::Destroy( pAttr, rDoc.GetAttrPool() ); }