[Libreoffice-commits] core.git: sfx2/source
Szymon Kłos
eszkadev at gmail.com
Thu Mar 16 08:20:27 UTC 2017
sfx2/source/notebookbar/NotebookbarTabControl.cxx | 47 ++++++++++++++++------
1 file changed, 36 insertions(+), 11 deletions(-)
New commits:
commit 3a122347b9a47f1ff7103364e90b77bc605fafce
Author: Szymon Kłos <eszkadev at gmail.com>
Date: Thu Mar 16 08:26:55 2017 +0100
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 at libreoffice.org>
Reviewed-by: Szymon Kłos <eszkadev at gmail.com>
diff --git a/sfx2/source/notebookbar/NotebookbarTabControl.cxx b/sfx2/source/notebookbar/NotebookbarTabControl.cxx
index b4a9465..47a2300 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();
More information about the Libreoffice-commits
mailing list