[Libreoffice-commits] core.git: dbaccess/source

Caolán McNamara caolanm at redhat.com
Tue Jul 7 09:02:46 PDT 2015


 dbaccess/source/ui/inc/TableWindow.hxx               |   10 +-
 dbaccess/source/ui/querydesign/QTableWindow.cxx      |   18 ++--
 dbaccess/source/ui/querydesign/TableWindow.cxx       |   83 +++++++++----------
 dbaccess/source/ui/querydesign/TableWindowAccess.cxx |   14 ++-
 4 files changed, 66 insertions(+), 59 deletions(-)

New commits:
commit 4bb2d015b332aa5e7623b4edba53f0503c64bbba
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jul 7 16:54:40 2015 +0100

    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

diff --git a/dbaccess/source/ui/inc/TableWindow.hxx b/dbaccess/source/ui/inc/TableWindow.hxx
index a2c704a..c120d0e 100644
--- a/dbaccess/source/ui/inc/TableWindow.hxx
+++ b/dbaccess/source/ui/inc/TableWindow.hxx
@@ -25,6 +25,7 @@
 #include <tools/rtti.hxx>
 #include <rtl/ref.hxx>
 #include "TableWindowData.hxx"
+#include "TableWindowListBox.hxx"
 #include <vector>
 #include <vcl/window.hxx>
 
@@ -41,7 +42,6 @@ namespace dbaui
     const sal_uInt16 SIZING_LEFT    = 0x0004;
     const sal_uInt16 SIZING_RIGHT   = 0x0008;
 
-    class OTableWindowListBox;
     class OJoinDesignView;
     class OJoinTableView;
     class OTableWindowAccess;
@@ -55,8 +55,8 @@ namespace dbaui
     protected:
         // 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<OTableWindowTitle>   m_aTitle;
-        VclPtr<OTableWindowListBox>    m_pListBox;
+        VclPtr<OTableWindowTitle>   m_xTitle;
+        VclPtr<OTableWindowListBox> m_xListBox;
         OTableWindowAccess*     m_pAccessible;
 
     private:
@@ -146,9 +146,9 @@ namespace dbaui
         OUString             GetTableName() const { return m_pData->GetTableName(); }
         OUString             GetWinName() const { return m_pData->GetWinName(); }
         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; }
-        OTableWindowTitle&           GetTitleCtrl() { return *m_aTitle.get(); }
+        VclPtr<OTableWindowTitle>    GetTitleCtrl() { return m_xTitle; }
 
         /** returns the name which should be used when displaying join or relations
             @return
diff --git a/dbaccess/source/ui/querydesign/QTableWindow.cxx b/dbaccess/source/ui/querydesign/QTableWindow.cxx
index 289da9c..a422c6c 100644
--- a/dbaccess/source/ui/querydesign/QTableWindow.cxx
+++ b/dbaccess/source/ui/querydesign/QTableWindow.cxx
@@ -97,8 +97,8 @@ bool OQueryTableWindow::Init()
     SetAliasName(sAliasName);
         // SetAliasName passes it as WinName, hence it uses the base class
     // reset the title
-    m_aTitle->SetText( pWinData->GetWinName() );
-    m_aTitle->Show();
+    m_xTitle->SetText( pWinData->GetWinName() );
+    m_xTitle->Show();
 
     getTableView()->getDesignView()->getController().InvalidateFeature(ID_BROWSER_QUERY_EXECUTE);
     return bSuccess;
@@ -131,10 +131,10 @@ void OQueryTableWindow::OnEntryDoubleClicked(SvTreeListEntry* pEntry)
     OSL_ENSURE(pInf != NULL, "OQueryTableWindow::OnEntryDoubleClicked : field doesn't have FieldInfo !");
 
     // 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->SetAlias(GetAliasName());
-    aInfo->SetFieldIndex(m_pListBox->GetModel()->GetAbsPos(pEntry));
+    aInfo->SetFieldIndex(m_xListBox->GetModel()->GetAbsPos(pEntry));
     aInfo->SetDataType(pInf->GetDataType());
 
     // and insert corresponding field
@@ -143,13 +143,13 @@ void OQueryTableWindow::OnEntryDoubleClicked(SvTreeListEntry* pEntry)
 
 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!");
     Reference< XConnection> xConnection = getTableView()->getDesignView()->getController().getConnection();
     bool bExists = false;
     if(xConnection.is())
     {
-        SvTreeListEntry* pEntry = m_pListBox->First();
+        SvTreeListEntry* pEntry = m_xListBox->First();
         try
         {
             Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
@@ -157,7 +157,7 @@ bool OQueryTableWindow::ExistsField(const OUString& strFieldName, OTableFieldDes
 
             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());
                     assert(pInf && "OQueryTableWindow::ExistsField : field doesn't have FieldInfo !");
@@ -166,12 +166,12 @@ bool OQueryTableWindow::ExistsField(const OUString& strFieldName, OTableFieldDes
                     rInfo->SetField(strFieldName);
                     rInfo->SetTable(GetTableName());
                     rInfo->SetAlias(GetAliasName());
-                    rInfo->SetFieldIndex(m_pListBox->GetModel()->GetAbsPos(pEntry));
+                    rInfo->SetFieldIndex(m_xListBox->GetModel()->GetAbsPos(pEntry));
                     rInfo->SetDataType(pInf->GetDataType());
                     bExists = true;
                     break;
                 }
-                pEntry = m_pListBox->Next(pEntry);
+                pEntry = m_xListBox->Next(pEntry);
             }
         }
         catch(SQLException&)
diff --git a/dbaccess/source/ui/querydesign/TableWindow.cxx b/dbaccess/source/ui/querydesign/TableWindow.cxx
index cd8638c..3e78a61 100644
--- a/dbaccess/source/ui/querydesign/TableWindow.cxx
+++ b/dbaccess/source/ui/querydesign/TableWindow.cxx
@@ -96,8 +96,7 @@ OTableWindow::OTableWindow( vcl::Window* pParent, const TTableWindowData::value_
           : ::comphelper::OContainerListener(m_aMutex)
           ,Window( pParent, WB_3DLOOK|WB_MOVEABLE )
           ,m_aTypeImage( VclPtr<FixedImage>::Create(this) )
-          ,m_aTitle( VclPtr<OTableWindowTitle>::Create(this) )
-          ,m_pListBox(NULL)
+          ,m_xTitle( VclPtr<OTableWindowTitle>::Create(this) )
           ,m_pAccessible(NULL)
           ,m_pData( pTabWinData )
           ,m_nMoveCount(0)
@@ -130,17 +129,17 @@ OTableWindow::~OTableWindow()
 
 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() )
         m_pContainerListener->dispose();
 
     m_pAccessible = NULL;
     m_aTypeImage.disposeAndClear();
-    m_aTitle.disposeAndClear();
+    m_xTitle.disposeAndClear();
     vcl::Window::dispose();
 }
 
@@ -194,7 +193,7 @@ VclPtr<OTableWindowListBox> OTableWindow::CreateListBox()
 
 bool OTableWindow::FillListBox()
 {
-    m_pListBox->Clear();
+    m_xListBox->Clear();
     if ( !m_pContainerListener.is() )
     {
         Reference< XContainer> xContainer(m_pData->getColumns(),UNO_QUERY);
@@ -208,7 +207,7 @@ bool OTableWindow::FillListBox()
 
     if (GetData()->IsShowAll())
     {
-        SvTreeListEntry* pEntry = m_pListBox->InsertEntry( OUString("*") );
+        SvTreeListEntry* pEntry = m_xListBox->InsertEntry( OUString("*") );
         pEntry->SetUserData( createUserData(NULL,false) );
     }
 
@@ -236,9 +235,9 @@ bool OTableWindow::FillListBox()
                 bool bPrimaryKeyColumn = xPKeyColumns.is() && xPKeyColumns->hasByName( *pIter );
                 // is this column in the primary key
                 if ( bPrimaryKeyColumn )
-                    pEntry = m_pListBox->InsertEntry(*pIter, aPrimKeyImage, aPrimKeyImage);
+                    pEntry = m_xListBox->InsertEntry(*pIter, aPrimKeyImage, aPrimKeyImage);
                 else
-                    pEntry = m_pListBox->InsertEntry(*pIter);
+                    pEntry = m_xListBox->InsertEntry(*pIter);
 
                 Reference<XPropertySet> xColumn(xColumns->getByName(*pIter),UNO_QUERY);
                 if ( xColumn.is() )
@@ -267,16 +266,16 @@ void OTableWindow::deleteUserData(void*& _pUserData)
 
 void OTableWindow::clearListBox()
 {
-    if ( m_pListBox )
+    if ( m_xListBox )
     {
-        SvTreeListEntry* pEntry = m_pListBox->First();
+        SvTreeListEntry* pEntry = m_xListBox->First();
 
         while(pEntry)
         {
             void* pUserData = pEntry->GetUserData();
             deleteUserData(pUserData);
-            SvTreeListEntry* pNextEntry = m_pListBox->Next(pEntry);
-            m_pListBox->GetModel()->Remove(pEntry);
+            SvTreeListEntry* pNextEntry = m_xListBox->Next(pEntry);
+            m_xListBox->GetModel()->Remove(pEntry);
             pEntry = pNextEntry;
         }
     }
@@ -302,24 +301,24 @@ void OTableWindow::impl_updateImage()
 bool OTableWindow::Init()
 {
     // create list box if necessary
-    if ( !m_pListBox )
+    if ( !m_xListBox )
     {
-        m_pListBox = CreateListBox();
-        OSL_ENSURE( m_pListBox != nullptr, "OTableWindow::Init() : CreateListBox returned NULL !" );
-        m_pListBox->SetSelectionMode( MULTIPLE_SELECTION );
+        m_xListBox = CreateListBox();
+        OSL_ENSURE( m_xListBox != nullptr, "OTableWindow::Init() : CreateListBox returned NULL !" );
+        m_xListBox->SetSelectionMode( MULTIPLE_SELECTION );
     }
 
     // Set the title
-    m_aTitle->SetText( m_pData->GetWinName() );
-    m_aTitle->Show();
+    m_xTitle->SetText( m_pData->GetWinName() );
+    m_xTitle->Show();
 
-    m_pListBox->Show();
+    m_xListBox->Show();
 
     // add the fields to the ListBox
     clearListBox();
     bool bSuccess = FillListBox();
     if ( bSuccess )
-        m_pListBox->SelectAll( false );
+        m_xListBox->SelectAll( false );
 
     impl_updateImage();
 
@@ -474,11 +473,11 @@ void OTableWindow::Resize()
         nTitleHeight = aImageSize.Height();
 
     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 );
 
-    m_pListBox->SetPosSizePixel(
+    m_xListBox->SetPosSizePixel(
         Point( n5Pos, nPositionY + nTitleHeight + nTitleToList ),
         Size( aOutSize.Width() - 2 * n5Pos, aOutSize.Height() - ( nPositionY + nTitleHeight + nTitleToList ) - n5Pos )
     );
@@ -488,26 +487,26 @@ void OTableWindow::Resize()
 
 void OTableWindow::SetBoldTitle( bool bBold )
 {
-    vcl::Font aFont = m_aTitle->GetFont();
+    vcl::Font aFont = m_xTitle->GetFont();
     aFont.SetWeight( bBold?WEIGHT_BOLD:WEIGHT_NORMAL );
-    m_aTitle->SetFont( aFont );
-    m_aTitle->Invalidate();
+    m_xTitle->SetFont( aFont );
+    m_xTitle->Invalidate();
 }
 
 void OTableWindow::GetFocus()
 {
     Window::GetFocus();
     // we have to forward the focus to our listbox to enable keystokes
-    if(m_pListBox)
-        m_pListBox->GrabFocus();
+    if(m_xListBox)
+        m_xListBox->GrabFocus();
 }
 
 void OTableWindow::setActive(bool _bActive)
 {
     SetBoldTitle( _bActive );
     m_bActive = _bActive;
-    if (!_bActive && m_pListBox && m_pListBox->GetSelectionCount() != 0)
-        m_pListBox->SelectAll(false);
+    if (!_bActive && m_xListBox && m_xListBox->GetSelectionCount() != 0)
+        m_xListBox->SelectAll(false);
 }
 
 void OTableWindow::Remove()
@@ -544,14 +543,14 @@ void OTableWindow::EnumValidFields(::std::vector< OUString>& arrstrFields)
 {
     arrstrFields.clear();
     // 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());
-        SvTreeListEntry* pEntryLoop = m_pListBox->First();
+        arrstrFields.reserve(m_xListBox->GetEntryCount());
+        SvTreeListEntry* pEntryLoop = m_xListBox->First();
         while (pEntryLoop)
         {
-            arrstrFields.push_back(m_pListBox->GetEntryText(pEntryLoop));
-            pEntryLoop = m_pListBox->Next(pEntryLoop);
+            arrstrFields.push_back(m_xListBox->GetEntryText(pEntryLoop));
+            pEntryLoop = m_xListBox->Next(pEntryLoop);
         }
     }
 }
@@ -571,8 +570,8 @@ void OTableWindow::StateChanged( StateChangedType nType )
             aFont.Merge( GetControlFont() );
         SetZoomedPointFont(*this, aFont);
 
-        m_aTitle->SetZoom(GetZoom());
-        m_pListBox->SetZoom(GetZoom());
+        m_xTitle->SetZoom(GetZoom());
+        m_xListBox->SetZoom(GetZoom());
         Resize();
         Invalidate();
     }
@@ -599,11 +598,11 @@ void OTableWindow::Command(const CommandEvent& rEvt)
                     ptWhere = rEvt.GetMousePosPixel();
                 else
                 {
-                    SvTreeListEntry* pCurrent = m_pListBox->GetCurEntry();
+                    SvTreeListEntry* pCurrent = m_xListBox->GetCurEntry();
                     if ( pCurrent )
-                        ptWhere = m_pListBox->GetEntryPosition(pCurrent);
+                        ptWhere = m_xListBox->GetEntryPosition(pCurrent);
                     else
-                        ptWhere = m_aTitle->GetPosPixel();
+                        ptWhere = m_xTitle->GetPosPixel();
                 }
 
                 PopupMenu aContextMenu(ModuleRes(RID_MENU_JOINVIEW_TABLE));
@@ -758,7 +757,7 @@ bool OTableWindow::PreNotify(NotifyEvent& rNEvt)
 
 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)
diff --git a/dbaccess/source/ui/querydesign/TableWindowAccess.cxx b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx
index eb1941a..a2fb614 100644
--- a/dbaccess/source/ui/querydesign/TableWindowAccess.cxx
+++ b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx
@@ -105,16 +105,24 @@ namespace dbaui
     {
         ::osl::MutexGuard aGuard( m_aMutex );
         Reference< XAccessible > aRet;
-        if(m_pTable && !m_pTable->IsDisposed())
+        if (m_pTable && !m_pTable->IsDisposed())
         {
             switch(i)
             {
                 case 0:
-                    aRet = m_pTable->GetTitleCtrl().GetAccessible();
+                {
+                    VclPtr<OTableWindowTitle> xCtrl(m_pTable->GetTitleCtrl());
+                    if (xCtrl)
+                        aRet = xCtrl->GetAccessible();
                     break;
+                }
                 case 1:
-                    aRet = m_pTable->GetListBox()->GetAccessible();
+                {
+                    VclPtr<OTableWindowListBox> xCtrl(m_pTable->GetListBox());
+                    if (xCtrl)
+                        aRet = xCtrl->GetAccessible();
                     break;
+                }
                 default:
                     throw IndexOutOfBoundsException();
             }


More information about the Libreoffice-commits mailing list