[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - 3 commits - desktop/source sc/qa sc/source sfx2/source sw/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Sep 1 10:10:09 UTC 2016


 desktop/source/lib/init.cxx                   |   19 +++++++++++++++----
 sc/qa/unit/tiledrendering/tiledrendering.cxx  |    6 ++++++
 sc/source/ui/inc/gridwin.hxx                  |    4 ++--
 sc/source/ui/inc/tabvwsh.hxx                  |    2 ++
 sc/source/ui/view/gridwin.cxx                 |   21 ++++++++++++++++-----
 sc/source/ui/view/tabvwshc.cxx                |    9 +++++++++
 sfx2/source/view/lokhelper.cxx                |    4 ++++
 sw/source/core/doc/DocumentRedlineManager.cxx |    3 ++-
 8 files changed, 56 insertions(+), 12 deletions(-)

New commits:
commit 945d7d44072e7a8d7d460c662729ad3cc7334ba2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 1 10:04:24 2016 +0200

    sfx2: nullptr pViewShell was seen in SfxLokHelper::getView()
    
    I'm not sure how to trigger this reliably, but Pranav got this:
    
    	#0  0x00007fb2f471bbf0 in SfxLokHelper::getView(SfxViewShell*) (pViewShell=0x0) at sfx2/source/view/lokhelper.cxx:82
    	#1  0x00007fb2f75edf4f in doc_paintPartTile(LibreOfficeKitDocument*, unsigned char*, int, int, int, int, int, int, int) (pThis=0x7fb290253c40, pBuffer=0x281fbd0 "", nPart=0, nCanvasWidth=1024, nCanvasHeight=256, nTilePosX=0, nTilePosY=11520, nTileWidth=15360, nTileHeight=3840) at desktop/source/lib/init.cxx:1338
    
    Given that SfxViewShell::Current() may indeed return nullptr (e.g.
    during shutdown), change SfxLokHelper::getView() to return -1 in that
    case, and adapt client code to handle that.
    
    Change-Id: Ia191c843c8a993f3d7157de432af57964c0a8f63
    Reviewed-on: https://gerrit.libreoffice.org/28583
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit f96fa389f950dd97bd213402fb5ea6eb114f9ab7)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 616521d..b32792c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1335,7 +1335,10 @@ void doc_paintPartTile(LibreOfficeKitDocument* pThis,
 
     // Disable callbacks while we are painting.
     LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
-    std::size_t nView = SfxLokHelper::getView();
+    int nView = SfxLokHelper::getView();
+    if (nView < 0)
+        return;
+
     pDocument->mpCallbackFlushHandlers[nView]->setPartTilePainting(true);
     try
     {
@@ -1408,7 +1411,10 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
     SolarMutexGuard aGuard;
     LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
 
-    std::size_t nView = SfxLokHelper::getView();
+    int nView = SfxLokHelper::getView();
+    if (nView < 0)
+        return;
+
     pDocument->mpCallbackFlushHandlers[nView].reset(new CallbackFlushHandler(pThis, pCallback, pData));
 
     if (SfxViewShell* pViewShell = SfxViewFrame::Current()->GetViewShell())
@@ -1477,7 +1483,9 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
     LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
 
     std::vector<beans::PropertyValue> aPropertyValuesVector(jsonToPropertyValuesVector(pArguments));
-    std::size_t nView = SfxLokHelper::getView();
+    int nView = SfxLokHelper::getView();
+    if (nView < 0)
+        return;
 
     // handle potential interaction
     if (gImpl && aCommand == ".uno:Save")
@@ -1562,7 +1570,10 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
     }
 
     LibLODocument_Impl* pLib = static_cast<LibLODocument_Impl*>(pThis);
-    std::size_t nView = SfxLokHelper::getView();
+    int nView = SfxLokHelper::getView();
+    if (nView < 0)
+        return;
+
     if (pLib->mpCallbackFlushHandlers[nView])
     {
         pLib->mpCallbackFlushHandlers[nView]->queue(LOK_CALLBACK_MOUSE_POINTER, aPointerString.getStr());
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 6870787..0e7af55 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -79,6 +79,10 @@ int SfxLokHelper::getView(SfxViewShell* pViewShell)
 {
     if (!pViewShell)
         pViewShell = SfxViewShell::Current();
+    // Still no valid view shell? Then no idea.
+    if (!pViewShell)
+        return -1;
+
     return pViewShell->GetViewShellId();
 }
 
commit 2da960dbf792f07cc16b2b2743f83041286de1a1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 1 09:11:37 2016 +0200

    sc lok: implement SfxViewShell::NotifyCursor() API
    
    This way a new Calc view gets the cell cursors of existing views even if
    they don't move after registering the LOK callback in the new view.
    
    Change-Id: I5babc9921d37217ac199d4c19ed33cbb9620d119
    Reviewed-on: https://gerrit.libreoffice.org/28581
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit fcf417a77369853195d6727b2db8df290663256e)

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index e738807..a61397a 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -410,8 +410,14 @@ void ScTiledRenderingTest::testViewCursors()
     ViewCallback aView1;
     SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
     SfxLokHelper::createView();
+    pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
     ViewCallback aView2;
+    aView2.m_bViewCursorInvalidated = false;
+    aView2.m_bOwnCursorInvalidated = false;
     SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+    // This was false, the new view did not get the view (cell) cursor of the old view.
+    CPPUNIT_ASSERT(aView2.m_bViewCursorInvalidated);
+    CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated);
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DOWN);
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DOWN);
     Scheduler::ProcessEventsToIdle();
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 017ca86..0432532 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -288,7 +288,6 @@ class ScGridWindow : public vcl::Window, public DropTargetHelper, public DragSou
     void            GetSelectionRects( ::std::vector< Rectangle >& rPixelRects );
 
 
-    void            updateLibreOfficeKitCellCursor();
 protected:
     virtual void    PrePaint(vcl::RenderContext& rRenderContext) override;
     virtual void    Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) override;
@@ -429,11 +428,12 @@ public:
 
     /// @see ScModelObj::getCellCursor().
     OString         getCellCursor(const Fraction& rZoomX,
-                                  const Fraction& rZoomY);
+                                  const Fraction& rZoomY) const;
     OString         getCellCursor(int nOutputWidth,
                                   int nOutputHeight,
                                   long nTileWidth,
                                   long nTileHeight);
+    void updateLibreOfficeKitCellCursor(SfxViewShell* pOtherShell) const;
 
 protected:
     void ImpCreateOverlayObjects();
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 6a2ae9b..cd0f3e0 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -387,6 +387,8 @@ public:
     void SetForceFocusOnCurCell(bool bFlag) { bForceFocusOnCurCell=bFlag; }
     /// See SfxViewShell::getPart().
     int getPart() const override;
+    /// See SfxViewShell::NotifyCursor().
+    void NotifyCursor(SfxViewShell* pViewShell) const override;
 };
 
 #endif
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 205a9e6..bbb18e0 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5817,7 +5817,8 @@ OString ScGridWindow::getCellCursor( int nOutputWidth, int nOutputHeight,
     return getCellCursor(zoomX, zoomY);
 }
 
-OString ScGridWindow::getCellCursor(const Fraction& rZoomX, const Fraction& rZoomY) {
+OString ScGridWindow::getCellCursor(const Fraction& rZoomX, const Fraction& rZoomY) const
+{
     // GridWindow stores a shown cell cursor in mpOOCursors, hence
     // we can use that to determine whether we would want to be showing
     // one (client-side) for tiled rendering too.
@@ -5849,12 +5850,22 @@ OString ScGridWindow::getCellCursor(const Fraction& rZoomX, const Fraction& rZoo
     return aRect.toString();
 }
 
-void ScGridWindow::updateLibreOfficeKitCellCursor()
+void ScGridWindow::updateLibreOfficeKitCellCursor(SfxViewShell* pOtherShell) const
 {
     OString aCursor = getCellCursor(pViewData->GetZoomX(), pViewData->GetZoomY());
     ScTabViewShell* pViewShell = pViewData->GetViewShell();
-    pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, aCursor.getStr());
-    SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", aCursor);
+    if (pOtherShell)
+    {
+        if (pOtherShell == pViewShell)
+            pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, aCursor.getStr());
+        else
+            SfxLokHelper::notifyOtherView(pViewShell, pOtherShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", aCursor);
+    }
+    else
+    {
+        pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, aCursor.getStr());
+        SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", aCursor);
+    }
 }
 
 void ScGridWindow::CursorChanged()
@@ -6145,7 +6156,7 @@ void ScGridWindow::UpdateCursorOverlay()
         if (comphelper::LibreOfficeKit::isActive())
         {
             mpOOCursors.reset(new sdr::overlay::OverlayObjectList);
-            updateLibreOfficeKitCellCursor();
+            updateLibreOfficeKitCellCursor(nullptr);
         }
         else
         {
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 9cdc11e..e84893b 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -541,4 +541,13 @@ int ScTabViewShell::getPart() const
     return GetViewData().GetTabNo();
 }
 
+void ScTabViewShell::NotifyCursor(SfxViewShell* pViewShell) const
+{
+    const ScGridWindow* pGridWindow = GetViewData().GetActiveWin();
+    if (!pGridWindow)
+        return;
+
+    pGridWindow->updateLibreOfficeKitCellCursor(pViewShell);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit f502cdb7000f8e61e3530370b28f160e6ef499c6
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 1 09:36:02 2016 +0200

    CppunitTest_sw_filters_test: fix ASan build
    
    MaybeNotifyModification() should be called only in the POS_INSIDE case,
    not when POS_EQUAL gets there via the fallthrough.
    
    Change-Id: I8a05ee508a14f62b12e93799b2e98a33041d6f33
    Reviewed-on: https://gerrit.libreoffice.org/28582
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit 3a897f7cbf44f44f2baa750f85d9aecbbbd2b6f9)

diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index ed98e0c..34a281f 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -1215,7 +1215,8 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall
                             }
                             delete pNewRedl;
                             pNewRedl = nullptr;
-                            pRedl->MaybeNotifyModification();
+                            if (eCmpPos == POS_INSIDE)
+                                pRedl->MaybeNotifyModification();
                             break;
 
                         case POS_OUTSIDE:


More information about the Libreoffice-commits mailing list