summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-01-28 15:57:10 +0000
committerMichael Stahl <mstahl@redhat.com>2015-02-02 14:45:22 +0000
commit092a73d070e05f54990151fdc4e66e8adac8097d (patch)
treeba919f4cc1f9b002f441fb2f8439f5099bb9eda4
parent291aa47b6039acb80472769362ce6dca14bd98cb (diff)
Related: tdf#82942 multiple crashes on changing text in SwInputFields
i.e. load doc keeping setting text of "LINE" + ok as each popup appears will crash eventually Change-Id: Ibc4bb8fe65bd5dd380c0fe833e5ece2b39de5dbe (cherry picked from commit 1ecf795ffaf8c63280ea92f776b53558b3227504) WaE: overriding destructor declaration not explicitly marked 'virtual' Change-Id: I4f155f8a28afa6a16b1859b254a339d8374a769b (cherry picked from commit e6a1f33e500c4fb5e38e7d6de7ddb55af8fa8650) coverity#1267699 Uninitialized pointer field Change-Id: I9d830e56bd06208664296f3310cd61b97588d160 (cherry picked from commit 51af2166d16ea5d47ee9b92ada2d95adff168bb2) Reviewed-on: https://gerrit.libreoffice.org/14261 Tested-by: Michael Stahl <mstahl@redhat.com> Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--sw/source/uibase/wrtsh/wrtsh2.cxx57
1 files changed, 34 insertions, 23 deletions
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index 786ce997ad29..e8da12b00f08 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -175,7 +175,35 @@ void SwWrtShell::UpdateInputFlds( SwInputFieldList* pLst )
class FieldDeletionModify : public SwModify
{
public:
- FieldDeletionModify(AbstractFldInputDlg* pInputFieldDlg) : mpInputFieldDlg(pInputFieldDlg) {}
+ FieldDeletionModify(AbstractFldInputDlg* pInputFieldDlg, SwField* pFld)
+ : mpInputFieldDlg(pInputFieldDlg)
+ , mpFmtFld(NULL)
+ {
+ SwInputField *const pInputField(dynamic_cast<SwInputField*>(pFld));
+ SwSetExpField *const pSetExpFld(dynamic_cast<SwSetExpField*>(pFld));
+
+ if (pInputField && pInputField->GetFmtFld())
+ {
+ mpFmtFld = pInputField->GetFmtFld();
+ }
+ else if (pSetExpFld && pSetExpFld->GetFmtFld())
+ {
+ mpFmtFld = pSetExpFld->GetFmtFld();
+ }
+
+ // Register for possible field deletion while dialog is open
+ if (mpFmtFld)
+ mpFmtFld->Add(this);
+ }
+
+ virtual ~FieldDeletionModify()
+ {
+ if (mpFmtFld)
+ {
+ // Dialog closed, remove modification listener
+ mpFmtFld->Remove(this);
+ }
+ }
void Modify( const SfxPoolItem* pOld, const SfxPoolItem *) SAL_OVERRIDE
{
@@ -186,6 +214,7 @@ class FieldDeletionModify : public SwModify
{
case RES_REMOVE_UNO_OBJECT:
case RES_OBJECTDYING:
+ mpFmtFld = NULL;
mpInputFieldDlg->EndDialog(RET_CANCEL);
break;
}
@@ -193,10 +222,10 @@ class FieldDeletionModify : public SwModify
}
private:
AbstractFldInputDlg* mpInputFieldDlg;
+ SwFmtFld* mpFmtFld;
};
// Start input dialog for a specific field
-
bool SwWrtShell::StartInputFldDlg( SwField* pFld, bool bNextButton,
vcl::Window* pParentWin, OString* pWindowState )
{
@@ -208,29 +237,11 @@ bool SwWrtShell::StartInputFldDlg( SwField* pFld, bool bNextButton,
if(pWindowState && !pWindowState->isEmpty())
pDlg->SetWindowState(*pWindowState);
- FieldDeletionModify aModify(pDlg.get());
- SwInputField *const pInputField(dynamic_cast<SwInputField*>(pFld));
- SwSetExpField *const pSetExpFld(dynamic_cast<SwSetExpField*>(pFld));
- if (pInputField && pInputField->GetFmtFld())
- {
- // Register for possible input field deletion while dialog is open
- pInputField->GetFmtFld()->Add(&aModify);
- }
- else if (pSetExpFld && pSetExpFld->GetFmtFld())
- {
- pSetExpFld->GetFmtFld()->Add(&aModify);
- }
-
- bool bRet = RET_CANCEL == pDlg->Execute();
+ bool bRet;
- if (pInputField && pInputField->GetFmtFld())
- {
- // Dialog closed, remove modification listener
- pInputField->GetFmtFld()->Remove(&aModify);
- }
- else if (pSetExpFld && pSetExpFld->GetFmtFld())
{
- pSetExpFld->GetFmtFld()->Remove(&aModify);
+ FieldDeletionModify aModify(pDlg.get(), pFld);
+ bRet = RET_CANCEL == pDlg->Execute();
}
if(pWindowState)