[Libreoffice-commits] core.git: sfx2/source
Szymon Kłos
eszkadev at gmail.com
Wed Aug 3 08:10:52 UTC 2016
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 <eszkadev at 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 <ci at libreoffice.org>
Reviewed-by: Szymon Kłos <eszkadev at 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();
}
}
More information about the Libreoffice-commits
mailing list