[Libreoffice-commits] core.git: sw/inc sw/source

Caolán McNamara caolanm at redhat.com
Tue Nov 7 16:10:12 UTC 2017


 sw/inc/redline.hxx                            |    3 ++-
 sw/source/core/doc/DocumentRedlineManager.cxx |    2 +-
 sw/source/core/doc/docredln.cxx               |   12 ++++++------
 sw/source/uibase/shells/textfld.cxx           |    2 +-
 4 files changed, 10 insertions(+), 9 deletions(-)

New commits:
commit 3503b65a36b5f3bcf4bfea59d519d52c10fa7b3e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Nov 7 09:13:06 2017 +0000

    ofz#4066 Bad-cast
    
    and a cluster of others around here. This pRedl has been deleted at this point.
    
    This doesn't matter for most users, seeing as !LibreOfficeKit::isActive() is
    the usual case so the deleted pRedl isn't fully accesssed.
    
    Because the deleted pRedl won't be found in GetRedlineTable when deleted,
    rework this a little to avoid the problem.
    
    Change-Id: I5c2f405cdae0b0c804ee7452629a14206516962d
    Reviewed-on: https://gerrit.libreoffice.org/44390
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index ae7c37a780ee..29b3b0287aeb 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -274,9 +274,10 @@ public:
 
     bool operator<( const SwRangeRedline& ) const;
     void dumpAsXml(struct _xmlTextWriter* pWriter) const;
-    void MaybeNotifyModification();
 };
 
+SW_DLLPUBLIC void MaybeNotifyRedlineModification(SwRangeRedline* pRedline, SwDoc* pDoc);
+
 /// Base object for 'Redlines' that are not of 'Ranged' type (like table row insert\delete)
 class SW_DLLPUBLIC SwExtraRedline
 {
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 08e81dbe8fc1..8085f0059944 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -1248,7 +1248,7 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
                             delete pNewRedl;
                             pNewRedl = nullptr;
                             if (eCmpPos == SwComparePosition::Inside)
-                                pRedl->MaybeNotifyModification();
+                                MaybeNotifyRedlineModification(pRedl, &m_rDoc);
                             break;
 
                         case SwComparePosition::Outside:
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 71072603c730..347c8cc8c91f 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1053,17 +1053,17 @@ SwRangeRedline::~SwRangeRedline()
     delete pRedlineData;
 }
 
-void SwRangeRedline::MaybeNotifyModification()
+void MaybeNotifyRedlineModification(SwRangeRedline* pRedline, SwDoc* pDoc)
 {
     if (!comphelper::LibreOfficeKit::isActive())
         return;
 
-    const SwRedlineTable& rRedTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
+    const SwRedlineTable& rRedTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
     for (SwRedlineTable::size_type i = 0; i < rRedTable.size(); ++i)
     {
-        if (rRedTable[i] == this)
+        if (rRedTable[i] == pRedline)
         {
-            SwRedlineTable::LOKRedlineNotification(RedlineNotification::Modify, this);
+            SwRedlineTable::LOKRedlineNotification(RedlineNotification::Modify, pRedline);
             break;
         }
     }
@@ -1074,7 +1074,7 @@ void SwRangeRedline::SetStart( const SwPosition& rPos, SwPosition* pSttPtr )
     if( !pSttPtr ) pSttPtr = Start();
     *pSttPtr = rPos;
 
-    MaybeNotifyModification();
+    MaybeNotifyRedlineModification(this, GetDoc());
 }
 
 void SwRangeRedline::SetEnd( const SwPosition& rPos, SwPosition* pEndPtr )
@@ -1082,7 +1082,7 @@ void SwRangeRedline::SetEnd( const SwPosition& rPos, SwPosition* pEndPtr )
     if( !pEndPtr ) pEndPtr = End();
     *pEndPtr = rPos;
 
-    MaybeNotifyModification();
+    MaybeNotifyRedlineModification(this, GetDoc());
 }
 
 /// Do we have a valid Selection?
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index eb7a92cd1a58..359d937919d9 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -537,7 +537,7 @@ void SwTextShell::ExecField(SfxRequest &rReq)
                     {
                         rSh.SetRedlineComment(sCommentText);
                         GetView().AttrChangedNotify(GetShellPtr());
-                        const_cast<SwRangeRedline*>(pRedline)->MaybeNotifyModification();
+                        MaybeNotifyRedlineModification(const_cast<SwRangeRedline*>(pRedline), pRedline->GetDoc());
                         break;
                     }
 


More information about the Libreoffice-commits mailing list