sfx2/source/notebookbar/NotebookBarPopupMenu.cxx | 43 +++++++++++++---------- sfx2/source/notebookbar/SfxNotebookBar.cxx | 3 - 2 files changed, 27 insertions(+), 19 deletions(-)
New commits: commit 89df751d4729c18c74b39ab4a1a5fddee878a16d Author: Szymon KÅos <eszka...@gmail.com> Date: Tue Aug 2 13:25:00 2016 +0200 GSoC notebookbar: avoid crash while opening menu Change-Id: I9fb4d329e13d8bfc429adc40c7663645b811a8b8 Reviewed-on: https://gerrit.libreoffice.org/27790 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Szymon KÅos <eszka...@gmail.com> diff --git a/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx b/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx index d0cd103..a78b15c 100644 --- a/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx +++ b/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx @@ -25,14 +25,18 @@ NotebookBarPopupMenu::NotebookBarPopupMenu(ResId aRes) { if (SfxViewFrame::Current()) { - for (int i = 0; i < GetItemCount(); ++i) + SfxDispatcher* pDispatcher = SfxViewFrame::Current()->GetBindings().GetDispatcher(); + if (pDispatcher) { - const SfxPoolItem* pItem; - SfxItemState eState = SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(GetItemId(i), pItem); - if (eState == SfxItemState::DISABLED) - this->EnableItem(GetItemId(i), false); - else - this->EnableItem(GetItemId(i)); + for (int i = 0; i < GetItemCount(); ++i) + { + const SfxPoolItem* pItem; + SfxItemState eState = pDispatcher->QueryState(GetItemId(i), pItem); + if (eState == SfxItemState::DISABLED) + this->EnableItem(GetItemId(i), false); + else + this->EnableItem(GetItemId(i)); + } } } else @@ -63,18 +67,23 @@ void NotebookBarPopupMenu::Execute(NotebookBar* pNotebookbar, if (xURLTransformer.is()) xURLTransformer->parseStrict(aUrl); - css::uno::Reference<css::frame::XDispatch> xDispatch; - css::uno::Reference<css::frame::XDispatchProvider> xDispatchProvider(xFrame, UNO_QUERY); - - if (xDispatchProvider.is()) + if (xFrame.is()) { - xDispatch = xDispatchProvider->queryDispatch(aUrl, OUString(), 0); - } - if (xDispatch.is()) - { - Sequence<com::sun::star::beans::PropertyValue> aArgs; - xDispatch->dispatch(aUrl, aArgs); + css::uno::Reference<css::frame::XDispatch> xDispatch; + css::uno::Reference<css::frame::XDispatchProvider> xDispatchProvider(xFrame, UNO_QUERY); + + if (xDispatchProvider.is()) + { + xDispatch = xDispatchProvider->queryDispatch(aUrl, OUString(), 0); + } + if (xDispatch.is()) + { + Sequence<com::sun::star::beans::PropertyValue> aArgs; + xDispatch->dispatch(aUrl, aArgs); + } } + else + SAL_WARN("sfx", "Can't create XDispatchProvider"); } } } diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index c09439d..ad8e7e5 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -130,9 +130,8 @@ IMPL_STATIC_LINK_TYPED(SfxNotebookBar, ToggleMenubar, NotebookBar*, pNotebookbar { if (pNotebookbar) { - VclPtr<NotebookBarPopupMenu> pMenu = VclPtr<NotebookBarPopupMenu>::Create(SfxResId(RID_MENU_NOTEBOOKBAR)); + ScopedVclPtrInstance<NotebookBarPopupMenu> pMenu(SfxResId(RID_MENU_NOTEBOOKBAR)); pMenu->Execute(pNotebookbar, m_xFrame); - pMenu->Clear(); } }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits