Kaydet (Commit) 2eb92eae authored tarafından Michael Stahl's avatar Michael Stahl

sw: fix recursive SwTextInputField::LockNotifyContentChange

(related: tdf#123968)

The assertion added in commit 742baabb
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: 's avatarMichael Stahl <Michael.Stahl@cib.de>
üst 19ddbc1f
......@@ -87,7 +87,7 @@ public:
virtual ~SwTextInputField() override;
void LockNotifyContentChange();
bool LockNotifyContentChange();
void UnlockNotifyContentChange();
virtual void NotifyContentChange( SwFormatField& rFormatField ) override;
......
......@@ -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]()
{
......
......@@ -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();
}
}
}
}
......
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment