summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2024-12-12 20:01:34 -0500
committerAndras Timar <andras.timar@collabora.com>2024-12-18 12:41:13 +0100
commit703b7bbd6e20382b71dd4393b24c2c6925c46986 (patch)
treec784674853fe28228f863d5a872aff7fd09ace10
parentcf11ac040a11bacaa4100f3ebbf5c9506c8bb318 (diff)
tdf#163033 sc: fix crash when copying comment to another ScDocument
Fixes a crash that started with 7.6.0.2 commit eec038b982b4672ac8feb030cb6bae546fa8c901 The crash occurred when comments were copied (without cloning) to another document and then the source document was closed, removing access to the (uncloned) comment. Also took the opportunity to put the (minutely) most expensive comparison at the end of the if clause. Change-Id: Ia5c1313aa17550f760d5f870c566f06b7abd598b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178394 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> (cherry picked from commit 6edc10c6b0b8322db63230b3a71e393437cbb7ac) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178420 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r--sc/source/core/data/postit.cxx5
1 files changed, 3 insertions, 2 deletions
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 695106ee5202..570dd28142f7 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -484,8 +484,9 @@ ScPostIt::~ScPostIt()
std::unique_ptr<ScPostIt> ScPostIt::Clone( const ScAddress& rOwnPos, ScDocument& rDestDoc, const ScAddress& rDestPos, bool bCloneCaption ) const
{
- // tdf#117307: Don't clone comment, if it is in the same position
- if ( (rOwnPos == rDestPos) && !mrDoc.IsClipboard() )
+ // tdf#117307: Don't clone comment, if it is in the same position in the same document
+ const bool bIsSameDoc = mrDoc.GetPool() == rDestDoc.GetPool();
+ if (bIsSameDoc && !mrDoc.IsClipboard() && rOwnPos == rDestPos)
bCloneCaption = false;
CreateCaptionFromInitData( rOwnPos );
sal_uInt32 nPostItId = comphelper::LibreOfficeKit::isActive() ? 0 : mnPostItId;