[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/sfx2 sfx2/source
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Mon Nov 25 12:34:38 UTC 2019
include/sfx2/sidebar/SidebarChildWindow.hxx | 5 --
include/sfx2/sidebar/SidebarDockingWindow.hxx | 9 ++--
sfx2/source/sidebar/SidebarChildWindow.cxx | 1
sfx2/source/sidebar/SidebarDockingWindow.cxx | 56 +++++++++++---------------
4 files changed, 30 insertions(+), 41 deletions(-)
New commits:
commit 98a7e776decd1082d3946fc3e00960be458242be
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Fri Nov 22 21:07:21 2019 -0500
Commit: Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Mon Nov 25 13:33:59 2019 +0100
sidebar: reset the LOKNotifier when the ViewShell changes
The ViewShell (which implements the LOKNotifier interface)
changes during the lifetime of the SidebarDockingWindow.
This is extremely problematic, because we assign the
LOKNotifier to a window, and use it to emit notifications
to the LOKit clients. When the ViewShell changes, a window
(the SidebarDockingWindow in this case) may end up using
an old ViewShell instance, which may have just been destroyed.
Now we properly reset the LOKNotifier to make sure we are
using the current ViewShell at all times. This is still
not ideal, since we may use the wrong ViewShell to send
out notifications, but we can't control that as we are at
the mercy of the mechanism that changes the current ViewShell.
This also removes obsolete flags to control which
document-types supported sidebar, as well as other misc
cleanups.
Change-Id: Ic208f64596a39feb7354958cf4d5e1e033d87b5b
Reviewed-on: https://gerrit.libreoffice.org/83627
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/include/sfx2/sidebar/SidebarChildWindow.hxx b/include/sfx2/sidebar/SidebarChildWindow.hxx
index e37cf443ec86..1fcb25431d94 100644
--- a/include/sfx2/sidebar/SidebarChildWindow.hxx
+++ b/include/sfx2/sidebar/SidebarChildWindow.hxx
@@ -39,11 +39,6 @@ public:
SFX_DECL_CHILDWINDOW_WITHID(SidebarChildWindow);
static sal_Int32 GetDefaultWidth(vcl::Window const * pWindow);
-
- bool IsSidebarVisibleInLOK() const { return mbSidebarVisibleInLOK; }
-
-private:
- const bool mbSidebarVisibleInLOK;
};
diff --git a/include/sfx2/sidebar/SidebarDockingWindow.hxx b/include/sfx2/sidebar/SidebarDockingWindow.hxx
index 5706b8a4ddea..a3297eb3afa8 100644
--- a/include/sfx2/sidebar/SidebarDockingWindow.hxx
+++ b/include/sfx2/sidebar/SidebarDockingWindow.hxx
@@ -62,14 +62,15 @@ protected:
SfxChildAlignment eRequestedAlignment) override;
private:
+
+ /// Notify LOKit that we closed and release the LOKNotifier.
+ void LOKClose();
+
+private:
::rtl::Reference<sfx2::sidebar::SidebarController> mpSidebarController;
bool mbIsReadyToDrag;
std::unique_ptr<svt::AcceleratorExecute> mpAccel;
- void DoDispose();
-
- const bool mbSidebarVisibleInLOK;
- const SfxViewShell* mpOldViewShell;
std::unique_ptr<SidebarNotifyIdle> mpIdleNotify;
};
diff --git a/sfx2/source/sidebar/SidebarChildWindow.cxx b/sfx2/source/sidebar/SidebarChildWindow.cxx
index 0690061a634b..99f30bed1fef 100644
--- a/sfx2/source/sidebar/SidebarChildWindow.cxx
+++ b/sfx2/source/sidebar/SidebarChildWindow.cxx
@@ -33,7 +33,6 @@ SFX_IMPL_DOCKINGWINDOW_WITHID(SidebarChildWindow, SID_SIDEBAR);
SidebarChildWindow::SidebarChildWindow(vcl::Window* pParentWindow, sal_uInt16 nId,
SfxBindings* pBindings, SfxChildWinInfo* pInfo)
: SfxChildWindow(pParentWindow, nId)
- , mbSidebarVisibleInLOK(pInfo && (pInfo->aModule == "scalc" || pInfo->aModule == "simpress" || pInfo->aModule == "swriter"))
{
auto pDockWin = VclPtr<SidebarDockingWindow>::Create(
pBindings, *this, pParentWindow, WB_STDDOCKWIN | WB_OWNERDRAWDECORATION | WB_CLIPCHILDREN
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index a0ed9440180d..b40f47eb4bad 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -88,8 +88,6 @@ SidebarDockingWindow::SidebarDockingWindow(SfxBindings* pSfxBindings, SidebarChi
: SfxDockingWindow(pSfxBindings, &rChildWindow, pParentWindow, nBits)
, mpSidebarController()
, mbIsReadyToDrag(false)
- , mbSidebarVisibleInLOK(rChildWindow.IsSidebarVisibleInLOK())
- , mpOldViewShell(SfxViewShell::Current())
, mpIdleNotify(new SidebarNotifyIdle(*this))
{
// Get the XFrame from the bindings.
@@ -112,23 +110,26 @@ SidebarDockingWindow::~SidebarDockingWindow()
void SidebarDockingWindow::dispose()
{
- DoDispose();
- SfxDockingWindow::dispose();
-}
-
-void SidebarDockingWindow::DoDispose()
-{
if (comphelper::LibreOfficeKit::isActive())
- {
- if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
- pNotifier->notifyWindow(GetLOKWindowId(), "close");
- }
+ LOKClose();
Reference<lang::XComponent> xComponent (static_cast<XWeak*>(mpSidebarController.get()), UNO_QUERY);
mpSidebarController.clear();
if (xComponent.is())
- {
xComponent->dispose();
+
+ SfxDockingWindow::dispose();
+}
+
+void SidebarDockingWindow::LOKClose()
+{
+ assert(comphelper::LibreOfficeKit::isActive());
+ if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
+ {
+ mpIdleNotify->Stop();
+
+ pNotifier->notifyWindow(GetLOKWindowId(), "close");
+ ReleaseLOKNotifier();
}
}
@@ -145,7 +146,9 @@ void SidebarDockingWindow::GetFocus()
bool SidebarDockingWindow::Close()
{
- mpSidebarController->SetFloatingDeckClosed( true );
+ if (mpSidebarController.is())
+ mpSidebarController->SetFloatingDeckClosed(true);
+
return SfxDockingWindow::Close();
}
@@ -158,25 +161,16 @@ void SidebarDockingWindow::Resize()
void SidebarDockingWindow::NotifyResize()
{
- if (comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current() && mbSidebarVisibleInLOK)
+ if (comphelper::LibreOfficeKit::isActive() && mpSidebarController.is() && SfxViewShell::Current())
{
- // When a new view is attached, and Sidebar is created (SidebarDockingWindow is constructed),
- // unfortunately we still have the *old* ViewShell (and ViewFrame). This happens because
- // we get multiple NotifyResize are called while SfxBaseController::ConnectSfxFrame_Impl
- // goes through the motions of creating and attaching a new frame/view.
- // Problem is that once we SetLOKNotifier on a window, we can't change it. So we better
- // set the correct one. Worse, if we set the old one, we will change the sidebar of the
- // wrong view, messing things up badly for the users.
- // Knowing the above, we wait until the dust settles, by observing when the ViewShell is
- // changed from the time we were created.
- // Note: this means we *cannot* create a sidebar post attaching a new view because the
- // ViewShell will not change, and therefore we will never SetLOKNotifier. To avoid that
- // we hide sidebars instead of closing (see OnMenuItemSelected in SidebarController).
- if (mpSidebarController.is() && !GetLOKNotifier())
- SetLOKNotifier(SfxViewShell::Current());
-
- if (GetLOKNotifier())
+ const vcl::ILibreOfficeKitNotifier* pCurrentView = SfxViewShell::Current();
+ if (GetLOKNotifier() != pCurrentView)
{
+ // ViewShell not yet set, or has changed. Reset it.
+ // Note GetLOKWindowId will return a new value after resetting, so we must notify clients.
+ LOKClose();
+
+ SetLOKNotifier(pCurrentView);
mpIdleNotify->Start();
}
}
More information about the Libreoffice-commits
mailing list