summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-02-12 17:35:17 +0000
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-02-20 12:00:26 +0000
commit21e6d5e42204e5a3e10de43a2b3ef880f4934aa0 (patch)
tree59b1fb821ee2597ccd2a6519f3f25a27eda64b7f
parent2190facc78a9e882558be7a9ffdd35f4df6222c1 (diff)
Resolves: tdf#87663 update checker tries to add icon to toc preview toolbar
i.e. CRASH when attempting to add ToC to document if the updatechecker fires while this dialog is activating/active because the preview has hidden menubars which have no associated window Change-Id: I45a254dba647910d7743f6d8173c2547dd82c791 (cherry picked from commit c6b40488c07149a2fcc8023dce4e9efb9e2fdf89) Reviewed-on: https://gerrit.libreoffice.org/14446 Reviewed-by: Eike Rathke <erack@redhat.com> Reviewed-by: Michael Stahl <mstahl@redhat.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--vcl/source/window/menu.cxx72
1 files changed, 48 insertions, 24 deletions
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 546725aed72b..8a6fa57edfb2 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2381,13 +2381,13 @@ void Menu::HighlightItem( sal_uInt16 nItemPos )
}
// - MenuBar -
-
IMenuBarWindow* MenuBar::getMenuBarWindow()
{
// so far just a dynamic_cast, hopefully to be turned into something saner
// at some stage
IMenuBarWindow *pWin = dynamic_cast<IMenuBarWindow*>(pWindow);
- assert(pWin);
+ //either there is no window (fdo#87663) or it is an IMenuBarWindow
+ assert(!pWindow || pWin);
return pWin;
}
@@ -2419,15 +2419,19 @@ MenuBar::~MenuBar()
void MenuBar::ClosePopup(Menu *pMenu)
{
- getMenuBarWindow()->PopupClosed(pMenu);
+ IMenuBarWindow* pMenuWin = getMenuBarWindow();
+ if (!pMenuWin)
+ return;
+ pMenuWin->PopupClosed(pMenu);
}
sal_uLong MenuBar::DeactivateMenuBar(sal_uLong nFocusId)
{
- nFocusId = getMenuBarWindow()->GetFocusId();
+ IMenuBarWindow* pMenuWin = getMenuBarWindow();
+ nFocusId = pMenuWin ? pMenuWin->GetFocusId() : 0;
if (nFocusId)
{
- getMenuBarWindow()->SetFocusId(0);
+ pMenuWin->SetFocusId(0);
ImplGetSVData()->maWinData.mbNoDeactivate = false;
}
@@ -2453,7 +2457,9 @@ void MenuBar::ShowButtons( bool bClose, bool bFloat, bool bHide )
mbCloseBtnVisible = bClose;
mbFloatBtnVisible = bFloat;
mbHideBtnVisible = bHide;
- getMenuBarWindow()->ShowButtons(bClose, bFloat, bHide);
+ IMenuBarWindow* pMenuWin = getMenuBarWindow();
+ if (pMenuWin)
+ pMenuWin->ShowButtons(bClose, bFloat, bHide);
}
}
@@ -2462,7 +2468,9 @@ void MenuBar::SetDisplayable( bool bDisplayable )
if( bDisplayable != mbDisplayable )
{
mbDisplayable = bDisplayable;
- getMenuBarWindow()->LayoutChanged();
+ IMenuBarWindow* pMenuWin = getMenuBarWindow();
+ if (pMenuWin)
+ pMenuWin->LayoutChanged();
}
}
@@ -2495,7 +2503,9 @@ void MenuBar::ImplDestroy( MenuBar* pMenu, bool bDelete )
vcl::Window *pWindow = pMenu->ImplGetWindow();
if (pWindow && bDelete)
{
- pMenu->getMenuBarWindow()->KillActivePopup();
+ IMenuBarWindow* pMenuWin = pMenu->getMenuBarWindow();
+ if (pMenuWin)
+ pMenuWin->KillActivePopup();
delete pWindow;
}
pMenu->pWindow = NULL;
@@ -2512,29 +2522,34 @@ bool MenuBar::ImplHandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu )
// check for enabled, if this method is called from another window...
vcl::Window* pWin = ImplGetWindow();
- if ( pWin && pWin->IsEnabled() && pWin->IsInputEnabled() && ! pWin->IsInModalMode() )
- bDone = getMenuBarWindow()->HandleKeyEvent( rKEvent, bFromMenu );
+ if (pWin && pWin->IsEnabled() && pWin->IsInputEnabled() && !pWin->IsInModalMode())
+ {
+ IMenuBarWindow* pMenuWin = getMenuBarWindow();
+ bDone = pMenuWin ? pMenuWin->HandleKeyEvent(rKEvent, bFromMenu) : false;
+ }
return bDone;
}
void MenuBar::SelectItem(sal_uInt16 nId)
{
- IMenuBarWindow* pMenuWin = getMenuBarWindow();
-
if (pWindow)
{
pWindow->GrabFocus();
nId = GetItemPos( nId );
- // #99705# popup the selected menu
- pMenuWin->SetAutoPopup( true );
- if (ITEMPOS_INVALID != pMenuWin->GetHighlightedItem())
+ IMenuBarWindow* pMenuWin = getMenuBarWindow();
+ if (pMenuWin)
{
- pMenuWin->KillActivePopup();
- pMenuWin->ChangeHighlightItem( ITEMPOS_INVALID, false );
+ // #99705# popup the selected menu
+ pMenuWin->SetAutoPopup( true );
+ if (ITEMPOS_INVALID != pMenuWin->GetHighlightedItem())
+ {
+ pMenuWin->KillActivePopup();
+ pMenuWin->ChangeHighlightItem( ITEMPOS_INVALID, false );
+ }
+ if (nId != ITEMPOS_INVALID)
+ pMenuWin->ChangeHighlightItem( nId, false );
}
- if (nId != ITEMPOS_INVALID)
- pMenuWin->ChangeHighlightItem( nId, false );
}
}
@@ -2612,27 +2627,36 @@ bool MenuBar::HandleMenuCommandEvent( Menu *pMenu, sal_uInt16 nCommandEventId )
sal_uInt16 MenuBar::AddMenuBarButton( const Image& i_rImage, const Link& i_rLink, const OUString& i_rToolTip, sal_uInt16 i_nPos )
{
- return getMenuBarWindow()->AddMenuBarButton(i_rImage, i_rLink, i_rToolTip, i_nPos);
+ IMenuBarWindow* pMenuWin = getMenuBarWindow();
+ return pMenuWin ? pMenuWin->AddMenuBarButton(i_rImage, i_rLink, i_rToolTip, i_nPos) : 0;
}
void MenuBar::SetMenuBarButtonHighlightHdl( sal_uInt16 nId, const Link& rLink )
{
- getMenuBarWindow()->SetMenuBarButtonHighlightHdl(nId, rLink);
+ IMenuBarWindow* pMenuWin = getMenuBarWindow();
+ if (!pMenuWin)
+ return;
+ pMenuWin->SetMenuBarButtonHighlightHdl(nId, rLink);
}
Rectangle MenuBar::GetMenuBarButtonRectPixel( sal_uInt16 nId )
{
- return getMenuBarWindow()->GetMenuBarButtonRectPixel(nId);
+ IMenuBarWindow* pMenuWin = getMenuBarWindow();
+ return pMenuWin ? pMenuWin->GetMenuBarButtonRectPixel(nId) : Rectangle();
}
void MenuBar::RemoveMenuBarButton( sal_uInt16 nId )
{
- getMenuBarWindow()->RemoveMenuBarButton(nId);
+ IMenuBarWindow* pMenuWin = getMenuBarWindow();
+ if (!pMenuWin)
+ return;
+ pMenuWin->RemoveMenuBarButton(nId);
}
bool MenuBar::HandleMenuButtonEvent( Menu *, sal_uInt16 i_nButtonId )
{
- return getMenuBarWindow()->HandleMenuButtonEvent(i_nButtonId);
+ IMenuBarWindow* pMenuWin = getMenuBarWindow();
+ return pMenuWin ? pMenuWin->HandleMenuButtonEvent(i_nButtonId) : false;
}
// bool PopupMenu::bAnyPopupInExecute = false;