vcl/source/window/menu.cxx | 72 ++++++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 24 deletions(-)
New commits: commit b72573c15f123633a691bc76098405f24b17ecc2 Author: Caolán McNamara <caol...@redhat.com> Date: Thu Feb 12 17:35:17 2015 +0000 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/14445 Reviewed-by: Eike Rathke <er...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 546725a..8a6fa57 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;
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits