Kaydet (Commit) f565a4b3 authored tarafından Carsten Driesner's avatar Carsten Driesner

#i107087# TabWindowService must set member pointer to zero on…

#i107087# TabWindowService must set member pointer to zero on VCLEVENT_OBJECT_DYING. The window life time is controlled by the docking window! Adding missing RemoveEventListener call.
üst 875ac204
...@@ -125,6 +125,7 @@ public: ...@@ -125,6 +125,7 @@ public:
~FwkTabWindow(); ~FwkTabWindow();
void AddEventListener( const Link& rEventListener ); void AddEventListener( const Link& rEventListener );
void RemoveEventListener( const Link& rEventListener );
FwkTabPage* AddTabPage( sal_Int32 nIndex, const css::uno::Sequence< css::beans::NamedValue >& rProperties ); FwkTabPage* AddTabPage( sal_Int32 nIndex, const css::uno::Sequence< css::beans::NamedValue >& rProperties );
void ActivatePage( sal_Int32 nIndex ); void ActivatePage( sal_Int32 nIndex );
void RemovePage( sal_Int32 nIndex ); void RemovePage( sal_Int32 nIndex );
......
...@@ -48,13 +48,13 @@ ...@@ -48,13 +48,13 @@
#include <macros/xinterface.hxx> #include <macros/xinterface.hxx>
#include <macros/xtypeprovider.hxx> #include <macros/xtypeprovider.hxx>
#include <macros/xserviceinfo.hxx> #include <macros/xserviceinfo.hxx>
#include <general.h> #include <general.h>
#include <stdtypes.h> #include <stdtypes.h>
//_________________________________________________________________________________________________________________ //_________________________________________________________________________________________________________________
// interface includes // interface includes
//_________________________________________________________________________________________________________________ //_________________________________________________________________________________________________________________
#include <com/sun/star/awt/XSimpleTabController.hpp> #include <com/sun/star/awt/XSimpleTabController.hpp>
#include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
//_________________________________________________________________________________________________________________ //_________________________________________________________________________________________________________________
// other includes // other includes
//_________________________________________________________________________________________________________________ //_________________________________________________________________________________________________________________
#include <cppuhelper/weak.hxx> #include <cppuhelper/weak.hxx>
#include <vcl/window.hxx> #include <vcl/window.hxx>
...@@ -81,31 +81,31 @@ namespace framework{ ...@@ -81,31 +81,31 @@ namespace framework{
//_________________________________________________________________________________________________________________ //_________________________________________________________________________________________________________________
struct TTabPageInfo struct TTabPageInfo
{ {
public: public:
TTabPageInfo() TTabPageInfo()
: m_nIndex ( -1 ) : m_nIndex ( -1 )
, m_bCreated (sal_False) , m_bCreated (sal_False)
, m_pPage ( NULL ) , m_pPage ( NULL )
, m_lProperties ( ) , m_lProperties ( )
{} {}
TTabPageInfo(::sal_Int32 nID) TTabPageInfo(::sal_Int32 nID)
: m_nIndex ( nID ) : m_nIndex ( nID )
, m_bCreated (sal_False) , m_bCreated (sal_False)
, m_pPage ( NULL ) , m_pPage ( NULL )
, m_lProperties ( ) , m_lProperties ( )
{} {}
public: public:
::sal_Int32 m_nIndex; ::sal_Int32 m_nIndex;
::sal_Bool m_bCreated; ::sal_Bool m_bCreated;
FwkTabPage* m_pPage; FwkTabPage* m_pPage;
css::uno::Sequence< css::beans::NamedValue > m_lProperties; css::uno::Sequence< css::beans::NamedValue > m_lProperties;
}; };
typedef ::std::hash_map< ::sal_Int32 , typedef ::std::hash_map< ::sal_Int32 ,
TTabPageInfo , TTabPageInfo ,
Int32HashCode , Int32HashCode ,
...@@ -118,10 +118,11 @@ typedef ::std::hash_map< ::sal_Int32 , ...@@ -118,10 +118,11 @@ typedef ::std::hash_map< ::sal_Int32 ,
class TabWindowService : public css::lang::XTypeProvider class TabWindowService : public css::lang::XTypeProvider
, public css::lang::XServiceInfo , public css::lang::XServiceInfo
, public css::awt::XSimpleTabController , public css::awt::XSimpleTabController
, public css::lang::XComponent
, public ThreadHelpBase , public ThreadHelpBase
, public TransactionBase , public TransactionBase
, public PropertySetHelper , public PropertySetHelper
, public ::cppu::OWeakObject , public ::cppu::OWeakObject
{ {
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
// public methods // public methods
...@@ -132,7 +133,7 @@ class TabWindowService : public css::lang::XTypeProvider ...@@ -132,7 +133,7 @@ class TabWindowService : public css::lang::XTypeProvider
//--------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------
// constructor / destructor // constructor / destructor
//--------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------
TabWindowService( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); TabWindowService( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
virtual ~TabWindowService(); virtual ~TabWindowService();
...@@ -186,8 +187,8 @@ class TabWindowService : public css::lang::XTypeProvider ...@@ -186,8 +187,8 @@ class TabWindowService : public css::lang::XTypeProvider
DECL_DLLPRIVATE_LINK( EventListener, VclSimpleEvent * ); DECL_DLLPRIVATE_LINK( EventListener, VclSimpleEvent * );
void impl_checkTabIndex (::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException); void impl_checkTabIndex (::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException);
TTabPageInfoHash::iterator impl_getTabPageInfo(::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException); TTabPageInfoHash::iterator impl_getTabPageInfo(::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException);
FwkTabWindow* mem_TabWin (); FwkTabWindow* mem_TabWin ();
/* /*
::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
...@@ -203,26 +204,26 @@ class TabWindowService : public css::lang::XTypeProvider ...@@ -203,26 +204,26 @@ class TabWindowService : public css::lang::XTypeProvider
private: private:
/// reference to factory, which has created this instance /// reference to factory, which has created this instance
css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
/// the tab window as XWindow ( to hold window* alive !) /// the tab window as XWindow ( to hold window* alive !)
css::uno::Reference< css::awt::XWindow > m_xTabWin; css::uno::Reference< css::awt::XWindow > m_xTabWin;
/// the VCL tab window /// the VCL tab window
FwkTabWindow* m_pTabWin; FwkTabWindow* m_pTabWin;
/// container of inserted tab pages /// container of inserted tab pages
TTabPageInfoHash m_lTabPageInfos; TTabPageInfoHash m_lTabPageInfos;
/// container of the added TabListener /// container of the added TabListener
::cppu::OMultiTypeInterfaceContainerHelper m_lListener; ::cppu::OMultiTypeInterfaceContainerHelper m_lListener;
/// counter of the tabpage indexes /// counter of the tabpage indexes
::sal_Int32 m_nPageIndexCounter; ::sal_Int32 m_nPageIndexCounter;
/// index of the current active page /// index of the current active page
::sal_Int32 m_nCurrentPageIndex; ::sal_Int32 m_nCurrentPageIndex;
/// title of the tabcontrolled window /// title of the tabcontrolled window
::rtl::OUString m_sTitle; ::rtl::OUString m_sTitle;
......
...@@ -65,7 +65,6 @@ namespace framework ...@@ -65,7 +65,6 @@ namespace framework
{ {
// class FwkTabControl --------------------------------------------------- // class FwkTabControl ---------------------------------------------------
FwkTabControl::FwkTabControl( Window* pParent, const ResId& rResId ) : FwkTabControl::FwkTabControl( Window* pParent, const ResId& rResId ) :
TabControl( pParent, rResId ) TabControl( pParent, rResId )
...@@ -336,6 +335,11 @@ void FwkTabWindow::AddEventListener( const Link& rEventListener ) ...@@ -336,6 +335,11 @@ void FwkTabWindow::AddEventListener( const Link& rEventListener )
m_aTabCtrl.AddEventListener( rEventListener ); m_aTabCtrl.AddEventListener( rEventListener );
} }
void FwkTabWindow::RemoveEventListener( const Link& rEventListener )
{
m_aTabCtrl.RemoveEventListener( rEventListener );
}
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
FwkTabPage* FwkTabWindow::AddTabPage( sal_Int32 nIndex, const uno::Sequence< beans::NamedValue >& rProperties ) FwkTabPage* FwkTabWindow::AddTabPage( sal_Int32 nIndex, const uno::Sequence< beans::NamedValue >& rProperties )
......
...@@ -75,18 +75,20 @@ namespace framework{ ...@@ -75,18 +75,20 @@ namespace framework{
// css::uno::XInterface, XTypeProvider, XServiceInfo // css::uno::XInterface, XTypeProvider, XServiceInfo
//***************************************************************************************************************** //*****************************************************************************************************************
DEFINE_XINTERFACE_5 ( TabWindowService , DEFINE_XINTERFACE_6 ( TabWindowService ,
OWeakObject , OWeakObject ,
DIRECT_INTERFACE(css::lang::XTypeProvider ), DIRECT_INTERFACE(css::lang::XTypeProvider ),
DIRECT_INTERFACE(css::lang::XServiceInfo ), DIRECT_INTERFACE(css::lang::XServiceInfo ),
DIRECT_INTERFACE(css::lang::XComponent),
DIRECT_INTERFACE(css::awt::XSimpleTabController), DIRECT_INTERFACE(css::awt::XSimpleTabController),
DIRECT_INTERFACE(css::beans::XPropertySet ), DIRECT_INTERFACE(css::beans::XPropertySet ),
DIRECT_INTERFACE(css::beans::XPropertySetInfo ) DIRECT_INTERFACE(css::beans::XPropertySetInfo )
) )
DEFINE_XTYPEPROVIDER_5 ( TabWindowService , DEFINE_XTYPEPROVIDER_6 ( TabWindowService ,
css::lang::XTypeProvider , css::lang::XTypeProvider ,
css::lang::XServiceInfo , css::lang::XServiceInfo ,
css::lang::XComponent ,
css::awt::XSimpleTabController , css::awt::XSimpleTabController ,
css::beans::XPropertySet , css::beans::XPropertySet ,
css::beans::XPropertySetInfo css::beans::XPropertySetInfo
...@@ -100,7 +102,7 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( TabWindowService , ...@@ -100,7 +102,7 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( TabWindowService ,
DEFINE_INIT_SERVICE ( TabWindowService, DEFINE_INIT_SERVICE ( TabWindowService,
{ {
impl_initializePropInfo(); impl_initializePropInfo();
m_aTransactionManager.setWorkingMode( E_WORK ); m_aTransactionManager.setWorkingMode( E_WORK );
} }
) )
...@@ -141,7 +143,7 @@ TabWindowService::TabWindowService( const css::uno::Reference< css::lang::XMulti ...@@ -141,7 +143,7 @@ TabWindowService::TabWindowService( const css::uno::Reference< css::lang::XMulti
// destructor // destructor
//***************************************************************************************************************** //*****************************************************************************************************************
TabWindowService::~TabWindowService() TabWindowService::~TabWindowService()
{ {
} }
//***************************************************************************************************************** //*****************************************************************************************************************
...@@ -286,8 +288,11 @@ void SAL_CALL TabWindowService::dispose() ...@@ -286,8 +288,11 @@ void SAL_CALL TabWindowService::dispose()
m_lListener.disposeAndClear (aEvent); m_lListener.disposeAndClear (aEvent);
if (m_pTabWin)
m_pTabWin->RemoveEventListener( LINK( this, TabWindowService, EventListener ) );
m_pTabWin = NULL; m_pTabWin = NULL;
m_xTabWin.clear (); m_xTabWin.clear();
} }
//***************************************************************************************************************** //*****************************************************************************************************************
...@@ -357,6 +362,7 @@ css::uno::Any SAL_CALL TabWindowService::impl_getPropertyValue(const ::rtl::OUSt ...@@ -357,6 +362,7 @@ css::uno::Any SAL_CALL TabWindowService::impl_getPropertyValue(const ::rtl::OUSt
//***************************************************************************************************************** //*****************************************************************************************************************
IMPL_LINK( TabWindowService, EventListener, VclSimpleEvent*, pEvent ) IMPL_LINK( TabWindowService, EventListener, VclSimpleEvent*, pEvent )
{ {
if ( !pEvent && !pEvent->ISA(VclWindowEvent)) if ( !pEvent && !pEvent->ISA(VclWindowEvent))
return 0; return 0;
...@@ -369,6 +375,11 @@ IMPL_LINK( TabWindowService, EventListener, VclSimpleEvent*, pEvent ) ...@@ -369,6 +375,11 @@ IMPL_LINK( TabWindowService, EventListener, VclSimpleEvent*, pEvent )
if (nEventId == VCLEVENT_OBJECT_DYING) if (nEventId == VCLEVENT_OBJECT_DYING)
{ {
m_lListener.disposeAndClear (aEvent); m_lListener.disposeAndClear (aEvent);
m_pTabWin->RemoveEventListener( LINK( this, TabWindowService, EventListener ) );
m_pTabWin = NULL;
m_xTabWin.clear();
return 0; return 0;
} }
...@@ -454,9 +465,9 @@ FwkTabWindow* TabWindowService::mem_TabWin () ...@@ -454,9 +465,9 @@ FwkTabWindow* TabWindowService::mem_TabWin ()
FwkTabWindow* pWin = NULL; FwkTabWindow* pWin = NULL;
if ( ! m_xTabWin.is ()) if ( ! m_xTabWin.is ())
{ {
Window* pFakeParent = dynamic_cast< Window* >(Application::GetDefaultDevice ()); Window* pFakeParent = dynamic_cast< Window* >(Application::GetDefaultDevice ());
m_pTabWin = new FwkTabWindow (pFakeParent); m_pTabWin = new FwkTabWindow (pFakeParent);
m_xTabWin = VCLUnoHelper::GetInterface (m_pTabWin); m_xTabWin = VCLUnoHelper::GetInterface (m_pTabWin);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment