Kaydet (Commit) e5f81b69 authored tarafından Caolán McNamara's avatar Caolán McNamara Kaydeden (comit) Andras Timar

Related: tdf#92434 children cleared but parent hasn't completed dispose yet

Table::dispose is being executed, so its not IsDisposed yet, but this
a11y code gets called during the dispose and the children have been cleared
at this point

Change-Id: I20aa9b15b1c5c3da91af58ac61f59fcf52619d58
(cherry picked from commit 4bb2d015)
Reviewed-on: https://gerrit.libreoffice.org/16825Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst e1eb1ee4
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <tools/rtti.hxx> #include <tools/rtti.hxx>
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
#include "TableWindowData.hxx" #include "TableWindowData.hxx"
#include "TableWindowListBox.hxx"
#include <vector> #include <vector>
#include <vcl/window.hxx> #include <vcl/window.hxx>
...@@ -41,7 +42,6 @@ namespace dbaui ...@@ -41,7 +42,6 @@ namespace dbaui
const sal_uInt16 SIZING_LEFT = 0x0004; const sal_uInt16 SIZING_LEFT = 0x0004;
const sal_uInt16 SIZING_RIGHT = 0x0008; const sal_uInt16 SIZING_RIGHT = 0x0008;
class OTableWindowListBox;
class OJoinDesignView; class OJoinDesignView;
class OJoinTableView; class OJoinTableView;
class OTableWindowAccess; class OTableWindowAccess;
...@@ -55,8 +55,8 @@ namespace dbaui ...@@ -55,8 +55,8 @@ namespace dbaui
protected: protected:
// and the table itself (needed for me as I want to lock it as long as the window is alive) // and the table itself (needed for me as I want to lock it as long as the window is alive)
VclPtr<FixedImage> m_aTypeImage; VclPtr<FixedImage> m_aTypeImage;
VclPtr<OTableWindowTitle> m_aTitle; VclPtr<OTableWindowTitle> m_xTitle;
VclPtr<OTableWindowListBox> m_pListBox; VclPtr<OTableWindowListBox> m_xListBox;
OTableWindowAccess* m_pAccessible; OTableWindowAccess* m_pAccessible;
private: private:
...@@ -146,9 +146,9 @@ namespace dbaui ...@@ -146,9 +146,9 @@ namespace dbaui
OUString GetTableName() const { return m_pData->GetTableName(); } OUString GetTableName() const { return m_pData->GetTableName(); }
OUString GetWinName() const { return m_pData->GetWinName(); } OUString GetWinName() const { return m_pData->GetWinName(); }
OUString GetComposedName() const { return m_pData->GetComposedName(); } OUString GetComposedName() const { return m_pData->GetComposedName(); }
OTableWindowListBox* GetListBox() const { return m_pListBox; } VclPtr<OTableWindowListBox> GetListBox() const { return m_xListBox; }
TTableWindowData::value_type GetData() const { return m_pData; } TTableWindowData::value_type GetData() const { return m_pData; }
OTableWindowTitle& GetTitleCtrl() { return *m_aTitle.get(); } VclPtr<OTableWindowTitle> GetTitleCtrl() { return m_xTitle; }
/** returns the name which should be used when displaying join or relations /** returns the name which should be used when displaying join or relations
@return @return
......
...@@ -98,8 +98,8 @@ bool OQueryTableWindow::Init() ...@@ -98,8 +98,8 @@ bool OQueryTableWindow::Init()
SetAliasName(sAliasName); SetAliasName(sAliasName);
// SetAliasName passes it as WinName, hence it uses the base class // SetAliasName passes it as WinName, hence it uses the base class
// reset the title // reset the title
m_aTitle->SetText( pWinData->GetWinName() ); m_xTitle->SetText( pWinData->GetWinName() );
m_aTitle->Show(); m_xTitle->Show();
getTableView()->getDesignView()->getController().InvalidateFeature(ID_BROWSER_QUERY_EXECUTE); getTableView()->getDesignView()->getController().InvalidateFeature(ID_BROWSER_QUERY_EXECUTE);
return bSuccess; return bSuccess;
...@@ -132,10 +132,10 @@ void OQueryTableWindow::OnEntryDoubleClicked(SvTreeListEntry* pEntry) ...@@ -132,10 +132,10 @@ void OQueryTableWindow::OnEntryDoubleClicked(SvTreeListEntry* pEntry)
OSL_ENSURE(pInf != NULL, "OQueryTableWindow::OnEntryDoubleClicked : field doesn't have FieldInfo !"); OSL_ENSURE(pInf != NULL, "OQueryTableWindow::OnEntryDoubleClicked : field doesn't have FieldInfo !");
// build up DragInfo // build up DragInfo
OTableFieldDescRef aInfo = new OTableFieldDesc(GetTableName(),m_pListBox->GetEntryText(pEntry)); OTableFieldDescRef aInfo = new OTableFieldDesc(GetTableName(), m_xListBox->GetEntryText(pEntry));
aInfo->SetTabWindow(this); aInfo->SetTabWindow(this);
aInfo->SetAlias(GetAliasName()); aInfo->SetAlias(GetAliasName());
aInfo->SetFieldIndex(m_pListBox->GetModel()->GetAbsPos(pEntry)); aInfo->SetFieldIndex(m_xListBox->GetModel()->GetAbsPos(pEntry));
aInfo->SetDataType(pInf->GetDataType()); aInfo->SetDataType(pInf->GetDataType());
// and insert corresponding field // and insert corresponding field
...@@ -144,13 +144,13 @@ void OQueryTableWindow::OnEntryDoubleClicked(SvTreeListEntry* pEntry) ...@@ -144,13 +144,13 @@ void OQueryTableWindow::OnEntryDoubleClicked(SvTreeListEntry* pEntry)
bool OQueryTableWindow::ExistsField(const OUString& strFieldName, OTableFieldDescRef& rInfo) bool OQueryTableWindow::ExistsField(const OUString& strFieldName, OTableFieldDescRef& rInfo)
{ {
OSL_ENSURE(m_pListBox != nullptr, "OQueryTableWindow::ExistsField : doesn't have ::com::sun::star::form::ListBox !"); OSL_ENSURE(m_xListBox != nullptr, "OQueryTableWindow::ExistsField : doesn't have ::com::sun::star::form::ListBox !");
OSL_ENSURE(rInfo.is(),"OQueryTableWindow::ExistsField: invalid argument for OTableFieldDescRef!"); OSL_ENSURE(rInfo.is(),"OQueryTableWindow::ExistsField: invalid argument for OTableFieldDescRef!");
Reference< XConnection> xConnection = getTableView()->getDesignView()->getController().getConnection(); Reference< XConnection> xConnection = getTableView()->getDesignView()->getController().getConnection();
bool bExists = false; bool bExists = false;
if(xConnection.is()) if(xConnection.is())
{ {
SvTreeListEntry* pEntry = m_pListBox->First(); SvTreeListEntry* pEntry = m_xListBox->First();
try try
{ {
Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData(); Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
...@@ -158,7 +158,7 @@ bool OQueryTableWindow::ExistsField(const OUString& strFieldName, OTableFieldDes ...@@ -158,7 +158,7 @@ bool OQueryTableWindow::ExistsField(const OUString& strFieldName, OTableFieldDes
while (pEntry) while (pEntry)
{ {
if (bCase(strFieldName,OUString(m_pListBox->GetEntryText(pEntry)))) if (bCase(strFieldName,OUString(m_xListBox->GetEntryText(pEntry))))
{ {
OTableFieldInfo* pInf = static_cast<OTableFieldInfo*>(pEntry->GetUserData()); OTableFieldInfo* pInf = static_cast<OTableFieldInfo*>(pEntry->GetUserData());
assert(pInf && "OQueryTableWindow::ExistsField : field doesn't have FieldInfo !"); assert(pInf && "OQueryTableWindow::ExistsField : field doesn't have FieldInfo !");
...@@ -167,12 +167,12 @@ bool OQueryTableWindow::ExistsField(const OUString& strFieldName, OTableFieldDes ...@@ -167,12 +167,12 @@ bool OQueryTableWindow::ExistsField(const OUString& strFieldName, OTableFieldDes
rInfo->SetField(strFieldName); rInfo->SetField(strFieldName);
rInfo->SetTable(GetTableName()); rInfo->SetTable(GetTableName());
rInfo->SetAlias(GetAliasName()); rInfo->SetAlias(GetAliasName());
rInfo->SetFieldIndex(m_pListBox->GetModel()->GetAbsPos(pEntry)); rInfo->SetFieldIndex(m_xListBox->GetModel()->GetAbsPos(pEntry));
rInfo->SetDataType(pInf->GetDataType()); rInfo->SetDataType(pInf->GetDataType());
bExists = true; bExists = true;
break; break;
} }
pEntry = m_pListBox->Next(pEntry); pEntry = m_xListBox->Next(pEntry);
} }
} }
catch(SQLException&) catch(SQLException&)
......
...@@ -96,8 +96,7 @@ OTableWindow::OTableWindow( vcl::Window* pParent, const TTableWindowData::value_ ...@@ -96,8 +96,7 @@ OTableWindow::OTableWindow( vcl::Window* pParent, const TTableWindowData::value_
: ::comphelper::OContainerListener(m_aMutex) : ::comphelper::OContainerListener(m_aMutex)
,Window( pParent, WB_3DLOOK|WB_MOVEABLE ) ,Window( pParent, WB_3DLOOK|WB_MOVEABLE )
,m_aTypeImage( VclPtr<FixedImage>::Create(this) ) ,m_aTypeImage( VclPtr<FixedImage>::Create(this) )
,m_aTitle( VclPtr<OTableWindowTitle>::Create(this) ) ,m_xTitle( VclPtr<OTableWindowTitle>::Create(this) )
,m_pListBox(NULL)
,m_pAccessible(NULL) ,m_pAccessible(NULL)
,m_pData( pTabWinData ) ,m_pData( pTabWinData )
,m_nMoveCount(0) ,m_nMoveCount(0)
...@@ -130,17 +129,17 @@ OTableWindow::~OTableWindow() ...@@ -130,17 +129,17 @@ OTableWindow::~OTableWindow()
void OTableWindow::dispose() void OTableWindow::dispose()
{ {
if (m_pListBox) if (m_xListBox)
{ {
OSL_ENSURE(m_pListBox->GetEntryCount()==0,"Forgot to call EmptyListbox()!"); OSL_ENSURE(m_xListBox->GetEntryCount()==0,"Forgot to call EmptyListbox()!");
} }
m_pListBox.disposeAndClear(); m_xListBox.disposeAndClear();
if ( m_pContainerListener.is() ) if ( m_pContainerListener.is() )
m_pContainerListener->dispose(); m_pContainerListener->dispose();
m_pAccessible = NULL; m_pAccessible = NULL;
m_aTypeImage.disposeAndClear(); m_aTypeImage.disposeAndClear();
m_aTitle.disposeAndClear(); m_xTitle.disposeAndClear();
vcl::Window::dispose(); vcl::Window::dispose();
} }
...@@ -194,7 +193,7 @@ VclPtr<OTableWindowListBox> OTableWindow::CreateListBox() ...@@ -194,7 +193,7 @@ VclPtr<OTableWindowListBox> OTableWindow::CreateListBox()
bool OTableWindow::FillListBox() bool OTableWindow::FillListBox()
{ {
m_pListBox->Clear(); m_xListBox->Clear();
if ( !m_pContainerListener.is() ) if ( !m_pContainerListener.is() )
{ {
Reference< XContainer> xContainer(m_pData->getColumns(),UNO_QUERY); Reference< XContainer> xContainer(m_pData->getColumns(),UNO_QUERY);
...@@ -208,7 +207,7 @@ bool OTableWindow::FillListBox() ...@@ -208,7 +207,7 @@ bool OTableWindow::FillListBox()
if (GetData()->IsShowAll()) if (GetData()->IsShowAll())
{ {
SvTreeListEntry* pEntry = m_pListBox->InsertEntry( OUString("*") ); SvTreeListEntry* pEntry = m_xListBox->InsertEntry( OUString("*") );
pEntry->SetUserData( createUserData(NULL,false) ); pEntry->SetUserData( createUserData(NULL,false) );
} }
...@@ -236,9 +235,9 @@ bool OTableWindow::FillListBox() ...@@ -236,9 +235,9 @@ bool OTableWindow::FillListBox()
bool bPrimaryKeyColumn = xPKeyColumns.is() && xPKeyColumns->hasByName( *pIter ); bool bPrimaryKeyColumn = xPKeyColumns.is() && xPKeyColumns->hasByName( *pIter );
// is this column in the primary key // is this column in the primary key
if ( bPrimaryKeyColumn ) if ( bPrimaryKeyColumn )
pEntry = m_pListBox->InsertEntry(*pIter, aPrimKeyImage, aPrimKeyImage); pEntry = m_xListBox->InsertEntry(*pIter, aPrimKeyImage, aPrimKeyImage);
else else
pEntry = m_pListBox->InsertEntry(*pIter); pEntry = m_xListBox->InsertEntry(*pIter);
Reference<XPropertySet> xColumn(xColumns->getByName(*pIter),UNO_QUERY); Reference<XPropertySet> xColumn(xColumns->getByName(*pIter),UNO_QUERY);
if ( xColumn.is() ) if ( xColumn.is() )
...@@ -267,16 +266,16 @@ void OTableWindow::deleteUserData(void*& _pUserData) ...@@ -267,16 +266,16 @@ void OTableWindow::deleteUserData(void*& _pUserData)
void OTableWindow::clearListBox() void OTableWindow::clearListBox()
{ {
if ( m_pListBox ) if ( m_xListBox )
{ {
SvTreeListEntry* pEntry = m_pListBox->First(); SvTreeListEntry* pEntry = m_xListBox->First();
while(pEntry) while(pEntry)
{ {
void* pUserData = pEntry->GetUserData(); void* pUserData = pEntry->GetUserData();
deleteUserData(pUserData); deleteUserData(pUserData);
SvTreeListEntry* pNextEntry = m_pListBox->Next(pEntry); SvTreeListEntry* pNextEntry = m_xListBox->Next(pEntry);
m_pListBox->GetModel()->Remove(pEntry); m_xListBox->GetModel()->Remove(pEntry);
pEntry = pNextEntry; pEntry = pNextEntry;
} }
} }
...@@ -302,24 +301,24 @@ void OTableWindow::impl_updateImage() ...@@ -302,24 +301,24 @@ void OTableWindow::impl_updateImage()
bool OTableWindow::Init() bool OTableWindow::Init()
{ {
// create list box if necessary // create list box if necessary
if ( !m_pListBox ) if ( !m_xListBox )
{ {
m_pListBox = CreateListBox(); m_xListBox = CreateListBox();
OSL_ENSURE( m_pListBox != nullptr, "OTableWindow::Init() : CreateListBox returned NULL !" ); OSL_ENSURE( m_xListBox != nullptr, "OTableWindow::Init() : CreateListBox returned NULL !" );
m_pListBox->SetSelectionMode( MULTIPLE_SELECTION ); m_xListBox->SetSelectionMode( MULTIPLE_SELECTION );
} }
// Set the title // Set the title
m_aTitle->SetText( m_pData->GetWinName() ); m_xTitle->SetText( m_pData->GetWinName() );
m_aTitle->Show(); m_xTitle->Show();
m_pListBox->Show(); m_xListBox->Show();
// add the fields to the ListBox // add the fields to the ListBox
clearListBox(); clearListBox();
bool bSuccess = FillListBox(); bool bSuccess = FillListBox();
if ( bSuccess ) if ( bSuccess )
m_pListBox->SelectAll( false ); m_xListBox->SelectAll( false );
impl_updateImage(); impl_updateImage();
...@@ -474,11 +473,11 @@ void OTableWindow::Resize() ...@@ -474,11 +473,11 @@ void OTableWindow::Resize()
nTitleHeight = aImageSize.Height(); nTitleHeight = aImageSize.Height();
nPositionX += aImageSize.Width() + CalcZoom( 2 ); nPositionX += aImageSize.Width() + CalcZoom( 2 );
m_aTitle->SetPosSizePixel( Point( nPositionX, nPositionY ), Size( aOutSize.Width() - nPositionX - n5Pos, nTitleHeight ) ); m_xTitle->SetPosSizePixel( Point( nPositionX, nPositionY ), Size( aOutSize.Width() - nPositionX - n5Pos, nTitleHeight ) );
long nTitleToList = CalcZoom( 3 ); long nTitleToList = CalcZoom( 3 );
m_pListBox->SetPosSizePixel( m_xListBox->SetPosSizePixel(
Point( n5Pos, nPositionY + nTitleHeight + nTitleToList ), Point( n5Pos, nPositionY + nTitleHeight + nTitleToList ),
Size( aOutSize.Width() - 2 * n5Pos, aOutSize.Height() - ( nPositionY + nTitleHeight + nTitleToList ) - n5Pos ) Size( aOutSize.Width() - 2 * n5Pos, aOutSize.Height() - ( nPositionY + nTitleHeight + nTitleToList ) - n5Pos )
); );
...@@ -488,26 +487,26 @@ void OTableWindow::Resize() ...@@ -488,26 +487,26 @@ void OTableWindow::Resize()
void OTableWindow::SetBoldTitle( bool bBold ) void OTableWindow::SetBoldTitle( bool bBold )
{ {
vcl::Font aFont = m_aTitle->GetFont(); vcl::Font aFont = m_xTitle->GetFont();
aFont.SetWeight( bBold?WEIGHT_BOLD:WEIGHT_NORMAL ); aFont.SetWeight( bBold?WEIGHT_BOLD:WEIGHT_NORMAL );
m_aTitle->SetFont( aFont ); m_xTitle->SetFont( aFont );
m_aTitle->Invalidate(); m_xTitle->Invalidate();
} }
void OTableWindow::GetFocus() void OTableWindow::GetFocus()
{ {
Window::GetFocus(); Window::GetFocus();
// we have to forward the focus to our listbox to enable keystokes // we have to forward the focus to our listbox to enable keystokes
if(m_pListBox) if(m_xListBox)
m_pListBox->GrabFocus(); m_xListBox->GrabFocus();
} }
void OTableWindow::setActive(bool _bActive) void OTableWindow::setActive(bool _bActive)
{ {
SetBoldTitle( _bActive ); SetBoldTitle( _bActive );
m_bActive = _bActive; m_bActive = _bActive;
if (!_bActive && m_pListBox && m_pListBox->GetSelectionCount() != 0) if (!_bActive && m_xListBox && m_xListBox->GetSelectionCount() != 0)
m_pListBox->SelectAll(false); m_xListBox->SelectAll(false);
} }
void OTableWindow::Remove() void OTableWindow::Remove()
...@@ -544,14 +543,14 @@ void OTableWindow::EnumValidFields(::std::vector< OUString>& arrstrFields) ...@@ -544,14 +543,14 @@ void OTableWindow::EnumValidFields(::std::vector< OUString>& arrstrFields)
{ {
arrstrFields.clear(); arrstrFields.clear();
// This default implementation counts every item in the ListBox ... for any other behaviour it must be over-written // This default implementation counts every item in the ListBox ... for any other behaviour it must be over-written
if ( m_pListBox ) if ( m_xListBox )
{ {
arrstrFields.reserve(m_pListBox->GetEntryCount()); arrstrFields.reserve(m_xListBox->GetEntryCount());
SvTreeListEntry* pEntryLoop = m_pListBox->First(); SvTreeListEntry* pEntryLoop = m_xListBox->First();
while (pEntryLoop) while (pEntryLoop)
{ {
arrstrFields.push_back(m_pListBox->GetEntryText(pEntryLoop)); arrstrFields.push_back(m_xListBox->GetEntryText(pEntryLoop));
pEntryLoop = m_pListBox->Next(pEntryLoop); pEntryLoop = m_xListBox->Next(pEntryLoop);
} }
} }
} }
...@@ -571,8 +570,8 @@ void OTableWindow::StateChanged( StateChangedType nType ) ...@@ -571,8 +570,8 @@ void OTableWindow::StateChanged( StateChangedType nType )
aFont.Merge( GetControlFont() ); aFont.Merge( GetControlFont() );
SetZoomedPointFont(*this, aFont); SetZoomedPointFont(*this, aFont);
m_aTitle->SetZoom(GetZoom()); m_xTitle->SetZoom(GetZoom());
m_pListBox->SetZoom(GetZoom()); m_xListBox->SetZoom(GetZoom());
Resize(); Resize();
Invalidate(); Invalidate();
} }
...@@ -599,11 +598,11 @@ void OTableWindow::Command(const CommandEvent& rEvt) ...@@ -599,11 +598,11 @@ void OTableWindow::Command(const CommandEvent& rEvt)
ptWhere = rEvt.GetMousePosPixel(); ptWhere = rEvt.GetMousePosPixel();
else else
{ {
SvTreeListEntry* pCurrent = m_pListBox->GetCurEntry(); SvTreeListEntry* pCurrent = m_xListBox->GetCurEntry();
if ( pCurrent ) if ( pCurrent )
ptWhere = m_pListBox->GetEntryPosition(pCurrent); ptWhere = m_xListBox->GetEntryPosition(pCurrent);
else else
ptWhere = m_aTitle->GetPosPixel(); ptWhere = m_xTitle->GetPosPixel();
} }
PopupMenu aContextMenu(ModuleRes(RID_MENU_JOINVIEW_TABLE)); PopupMenu aContextMenu(ModuleRes(RID_MENU_JOINVIEW_TABLE));
...@@ -758,7 +757,7 @@ bool OTableWindow::PreNotify(NotifyEvent& rNEvt) ...@@ -758,7 +757,7 @@ bool OTableWindow::PreNotify(NotifyEvent& rNEvt)
OUString OTableWindow::getTitle() const OUString OTableWindow::getTitle() const
{ {
return m_aTitle->GetText(); return m_xTitle->GetText();
} }
void OTableWindow::_elementInserted( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception) void OTableWindow::_elementInserted( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
......
...@@ -105,16 +105,24 @@ namespace dbaui ...@@ -105,16 +105,24 @@ namespace dbaui
{ {
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
Reference< XAccessible > aRet; Reference< XAccessible > aRet;
if(m_pTable && !m_pTable->IsDisposed()) if (m_pTable && !m_pTable->IsDisposed())
{ {
switch(i) switch(i)
{ {
case 0: case 0:
aRet = m_pTable->GetTitleCtrl().GetAccessible(); {
VclPtr<OTableWindowTitle> xCtrl(m_pTable->GetTitleCtrl());
if (xCtrl)
aRet = xCtrl->GetAccessible();
break; break;
}
case 1: case 1:
aRet = m_pTable->GetListBox()->GetAccessible(); {
VclPtr<OTableWindowListBox> xCtrl(m_pTable->GetListBox());
if (xCtrl)
aRet = xCtrl->GetAccessible();
break; break;
}
default: default:
throw IndexOutOfBoundsException(); throw IndexOutOfBoundsException();
} }
......
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