diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2017-03-16 08:26:55 +0100 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2017-03-16 08:20:02 +0000 |
commit | 3a122347b9a47f1ff7103364e90b77bc605fafce (patch) | |
tree | 0e0b404a77796b98bfddaaf859e2dd3667a83414 /sfx2 | |
parent | 8ae9dcec653c4ad3eeb8c3e1fa9b1684e2bd64a2 (diff) |
Notebookbar: fixed crash after customization
+ removed listener
+ prevent from using invalid pointers
Change-Id: I3a846d2344148456d3edba23296a4781496eba8b
Reviewed-on: https://gerrit.libreoffice.org/35248
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Szymon Kłos <eszkadev@gmail.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/notebookbar/NotebookbarTabControl.cxx | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/sfx2/source/notebookbar/NotebookbarTabControl.cxx b/sfx2/source/notebookbar/NotebookbarTabControl.cxx index b4a946502222..47a230097542 100644 --- a/sfx2/source/notebookbar/NotebookbarTabControl.cxx +++ b/sfx2/source/notebookbar/NotebookbarTabControl.cxx @@ -53,17 +53,20 @@ public: { try { - Reference<XComponentContext> xContext = comphelper::getProcessComponentContext(); - const Reference<XModuleManager> xModuleManager = ModuleManager::create( xContext ); - Reference<XFrame> xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); - OUString aModuleName = xModuleManager->identify( xFrame ); - - Reference<XUIConfigurationManager> m_xConfigManager; - Reference<XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier( - theModuleUIConfigurationManagerSupplier::get( xContext ) ); - m_xConfigManager.set( xModuleCfgMgrSupplier->getUIConfigurationManager( aModuleName ) ); - css::uno::Reference< css::ui::XUIConfiguration > xConfig( m_xConfigManager, css::uno::UNO_QUERY_THROW ); - xConfig->addConfigurationListener( this ); + if( SfxViewFrame::Current() ) + { + Reference<XComponentContext> xContext = comphelper::getProcessComponentContext(); + const Reference<XModuleManager> xModuleManager = ModuleManager::create( xContext ); + Reference<XFrame> xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); + OUString aModuleName = xModuleManager->identify( xFrame ); + + Reference<XUIConfigurationManager> m_xConfigManager; + Reference<XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier( + theModuleUIConfigurationManagerSupplier::get( xContext ) ); + m_xConfigManager.set( xModuleCfgMgrSupplier->getUIConfigurationManager( aModuleName ) ); + css::uno::Reference< css::ui::XUIConfiguration > xConfig( m_xConfigManager, css::uno::UNO_QUERY_THROW ); + xConfig->addConfigurationListener( this ); + } } catch( const css::uno::RuntimeException& ) {} } @@ -90,6 +93,25 @@ public: virtual void SAL_CALL disposing(const ::css::lang::EventObject&) override { + try + { + if( SfxViewFrame::Current() ) + { + Reference<XComponentContext> xContext = comphelper::getProcessComponentContext(); + const Reference<XModuleManager> xModuleManager = ModuleManager::create( xContext ); + Reference<XFrame> xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); + OUString aModuleName = xModuleManager->identify( xFrame ); + + Reference<XUIConfigurationManager> m_xConfigManager; + Reference<XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier( + theModuleUIConfigurationManagerSupplier::get( xContext ) ); + m_xConfigManager.set( xModuleCfgMgrSupplier->getUIConfigurationManager( aModuleName ) ); + css::uno::Reference< css::ui::XUIConfiguration > xConfig( m_xConfigManager, css::uno::UNO_QUERY_THROW ); + xConfig->removeConfigurationListener( this ); + } + } + catch( const css::uno::RuntimeException& ) {} + m_pParent.clear(); } }; @@ -130,6 +152,9 @@ void NotebookbarTabControl::StateChanged(StateChangedType nStateChange) if( m_bInitialized && m_bInvalidate && SfxViewFrame::Current() ) { ToolBox* pToolBox = GetToolBox(); + if( !pToolBox ) + return; + pToolBox->Clear(); Reference<XComponentContext> xContext = comphelper::getProcessComponentContext(); |