[Libreoffice-commits] core.git: sw/inc sw/source
Michael Stahl (via logerrit)
logerrit at kemper.freedesktop.org
Mon Apr 15 14:06:42 UTC 2019
sw/inc/txtfld.hxx | 2 -
sw/source/core/doc/DocumentFieldsManager.cxx | 4 ++-
sw/source/core/fields/expfld.cxx | 32 ++++++++++++++++-----------
sw/source/core/txtnode/atrfld.cxx | 8 +++++-
4 files changed, 29 insertions(+), 17 deletions(-)
New commits:
commit 2eb92eaea9ad74b1488246af3c334c3829af36a1
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Apr 15 15:03:14 2019 +0200
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Mon Apr 15 16:05:06 2019 +0200
sw: fix recursive SwTextInputField::LockNotifyContentChange
(related: tdf#123968)
The assertion added in commit 742baabbe4d077e1ba913a7989300908f4637ac7
is triggered during ODF import of import fields associated with user
field types; there is a 3 level recursion of the SwUserFieldType for one
variable calling the SwInputFieldType calling SwUserFieldType of another
variable...
Change-Id: I54fc56733c7375cfdb6439b02cf21c4d852c2b4c
Reviewed-on: https://gerrit.libreoffice.org/70768
Tested-by: Jenkins
Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
diff --git a/sw/inc/txtfld.hxx b/sw/inc/txtfld.hxx
index 11c13edeedc9..38ca9caa6251 100644
--- a/sw/inc/txtfld.hxx
+++ b/sw/inc/txtfld.hxx
@@ -87,7 +87,7 @@ public:
virtual ~SwTextInputField() override;
- void LockNotifyContentChange();
+ bool LockNotifyContentChange();
void UnlockNotifyContentChange();
virtual void NotifyContentChange( SwFormatField& rFormatField ) override;
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx
index 9f05f74f2785..4ef15a9f56e4 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -1275,7 +1275,9 @@ void DocumentFieldsManager::UpdateExpFieldsImpl(
: dynamic_cast<SwTextInputField *>(pTextField));
if (pInputField)
{
- pInputField->LockNotifyContentChange();
+ bool const tmp = pInputField->LockNotifyContentChange();
+ (void) tmp;
+ assert(tmp && "should not be locked here?");
}
::comphelper::ScopeGuard g([pInputField]()
{
diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx
index 62a31891396e..9c90867d5924 100644
--- a/sw/source/core/fields/expfld.cxx
+++ b/sw/source/core/fields/expfld.cxx
@@ -1261,23 +1261,29 @@ void SwInputField::applyFieldContent( const OUString& rNewFieldContent )
if( pUserTyp )
{
pUserTyp->SetContent( rNewFieldContent );
-
- // trigger update of the corresponding User Fields and other related Input Fields
- if ( GetFormatField() != nullptr )
+ if (!pUserTyp->IsModifyLocked())
{
- SwTextInputField* pTextInputField = dynamic_cast< SwTextInputField* >(GetFormatField()->GetTextField());
- if ( pTextInputField != nullptr )
+ // trigger update of the corresponding User Fields and other
+ // related Input Fields
+ bool bUnlock(false);
+ if (GetFormatField() != nullptr)
{
- pTextInputField->LockNotifyContentChange();
+ SwTextInputField *const pTextInputField =
+ dynamic_cast<SwTextInputField*>(GetFormatField()->GetTextField());
+ if (pTextInputField != nullptr)
+ {
+ bUnlock = pTextInputField->LockNotifyContentChange();
+ }
}
- }
- pUserTyp->UpdateFields();
- if ( GetFormatField() != nullptr )
- {
- SwTextInputField* pTextInputField = dynamic_cast< SwTextInputField* >(GetFormatField()->GetTextField());
- if ( pTextInputField != nullptr )
+ pUserTyp->UpdateFields();
+ if (bUnlock)
{
- pTextInputField->UnlockNotifyContentChange();
+ SwTextInputField *const pTextInputField =
+ dynamic_cast<SwTextInputField*>(GetFormatField()->GetTextField());
+ if (pTextInputField != nullptr)
+ {
+ pTextInputField->UnlockNotifyContentChange();
+ }
}
}
}
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index 66ccc2670f73..3e7ffb0604fa 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -557,10 +557,14 @@ SwTextInputField::~SwTextInputField()
{
}
-void SwTextInputField::LockNotifyContentChange()
+bool SwTextInputField::LockNotifyContentChange()
{
- assert(!m_bLockNotifyContentChange); // not nestable
+ if (m_bLockNotifyContentChange)
+ {
+ return false;
+ }
m_bLockNotifyContentChange = true;
+ return true;
}
void SwTextInputField::UnlockNotifyContentChange()
More information about the Libreoffice-commits
mailing list