diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-05-26 11:41:27 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-05-26 11:57:50 +0100 |
commit | 3185d9b8fbaad56fc7170a277569b5e441d946f4 (patch) | |
tree | a7c563a8c5e976906e2ee3c63f2d8085063ca69b /dbaccess/source/ui/querydesign | |
parent | e55f83e1731e1031c63d8463b57c434cceb126e3 (diff) |
Related: tdf#97854 confirm that on !bDelete there's a ref to the connection
so that its not deleted on removal from the vector
Change-Id: I6c1f7691ee415abf0f419fdd7fcf2341fe2bd1f3
Diffstat (limited to 'dbaccess/source/ui/querydesign')
-rw-r--r-- | dbaccess/source/ui/querydesign/JoinTableView.cxx | 38 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/QueryTableView.cxx | 34 |
2 files changed, 38 insertions, 34 deletions
diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx index 340f91abebff..d12eca785cad 100644 --- a/dbaccess/source/ui/querydesign/JoinTableView.cxx +++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx @@ -242,9 +242,9 @@ sal_uLong OJoinTableView::GetTabWinCount() return m_aTableMap.size(); } -bool OJoinTableView::RemoveConnection( OTableConnection* _pConn, bool _bDelete ) +bool OJoinTableView::RemoveConnection(VclPtr<OTableConnection>& rConn, bool _bDelete) { - VclPtr<OTableConnection> xConn(_pConn); + VclPtr<OTableConnection> xConn(rConn); DeselectConn(xConn); @@ -356,14 +356,14 @@ void OJoinTableView::RemoveTabWin( OTableWindow* pTabWin ) auto aIter = m_vTableConnection.rbegin(); while(aIter != m_vTableConnection.rend() && bRemove) { - OTableConnection* pTabConn = (*aIter); - if( - ( pData == pTabConn->GetData()->getReferencingTable()) || - ( pData == pTabConn->GetData()->getReferencedTable()) - ) + VclPtr<OTableConnection>& rTabConn = (*aIter); + if ( + (pData == rTabConn->GetData()->getReferencingTable()) || + (pData == rTabConn->GetData()->getReferencedTable()) + ) { - bRemove = RemoveConnection( pTabConn ,true); - aIter = m_vTableConnection.rbegin(); + bRemove = RemoveConnection(rTabConn, true); + aIter = m_vTableConnection.rbegin(); } else ++aIter; @@ -809,7 +809,7 @@ void OJoinTableView::Tracking( const TrackingEvent& rTEvt ) } } -void OJoinTableView::ConnDoubleClicked( OTableConnection* /*pConnection*/ ) +void OJoinTableView::ConnDoubleClicked(VclPtr<OTableConnection>& /*rConnection*/) { } @@ -854,7 +854,7 @@ void OJoinTableView::KeyInput( const KeyEvent& rEvt ) if( !bCtrl && !bShift && (nCode==KEY_DELETE) ) { if (GetSelectedConn()) - RemoveConnection( GetSelectedConn() ,true); + RemoveConnection(GetSelectedConn(), true); } else Window::KeyInput( rEvt ); @@ -1126,16 +1126,16 @@ bool OJoinTableView::IsAddAllowed() return true; } -void OJoinTableView::executePopup(const Point& _aPos,OTableConnection* _pSelConnection) +void OJoinTableView::executePopup(const Point& _aPos, VclPtr<OTableConnection>& rSelConnection) { PopupMenu aContextMenu( ModuleRes( RID_MENU_JOINVIEW_CONNECTION ) ); switch (aContextMenu.Execute(this, _aPos)) { case SID_DELETE: - RemoveConnection( _pSelConnection ,true); + RemoveConnection(rSelConnection, true); break; case ID_QUERY_EDIT_JOINCONNECTION: - ConnDoubleClicked( _pSelConnection ); // is the same as double clicked + ConnDoubleClicked(rSelConnection); // is the same as double clicked break; } } @@ -1152,21 +1152,21 @@ void OJoinTableView::Command(const CommandEvent& rEvt) if( m_vTableConnection.empty() ) return; - OTableConnection* pSelConnection = GetSelectedConn(); + VclPtr<OTableConnection>& rSelConnection = GetSelectedConn(); // when it wasn't a mouse event use the selected connection if (!rEvt.IsMouseEvent()) { - if( pSelConnection ) + if (rSelConnection) { - const ::std::vector<OConnectionLine*>& rLines = pSelConnection->GetConnLineList(); + const ::std::vector<OConnectionLine*>& rLines = rSelConnection->GetConnLineList(); ::std::vector<OConnectionLine*>::const_iterator aIter = ::std::find_if(rLines.begin(), rLines.end(),::std::mem_fun(&OConnectionLine::IsValid)); if( aIter != rLines.end() ) - executePopup((*aIter)->getMidPoint(),pSelConnection); + executePopup((*aIter)->getMidPoint(), rSelConnection); } } else { - DeselectConn(pSelConnection); + DeselectConn(rSelConnection); const Point& aMousePos = rEvt.GetMousePosPixel(); auto aIter = m_vTableConnection.begin(); diff --git a/dbaccess/source/ui/querydesign/QueryTableView.cxx b/dbaccess/source/ui/querydesign/QueryTableView.cxx index 8a36b91642b4..67bd063ec99d 100644 --- a/dbaccess/source/ui/querydesign/QueryTableView.cxx +++ b/dbaccess/source/ui/querydesign/QueryTableView.cxx @@ -635,12 +635,12 @@ void OQueryTableView::AddConnection(const OJoinExchangeData& jxdSource, const OJ } } -void OQueryTableView::ConnDoubleClicked(OTableConnection* pConnection) +void OQueryTableView::ConnDoubleClicked(VclPtr<OTableConnection>& rConnection) { - if( openJoinDialog(this,pConnection->GetData(),false) ) + if (openJoinDialog(this, rConnection->GetData(), false)) { - connectionModified(this,pConnection,false); - SelectConn( pConnection ); + connectionModified(this, rConnection, false); + SelectConn(rConnection); } } @@ -673,17 +673,19 @@ void OQueryTableView::createNewConnection() } } -bool OQueryTableView::RemoveConnection( OTableConnection* _pConnection,bool /*_bDelete*/ ) +bool OQueryTableView::RemoveConnection(VclPtr<OTableConnection>& rConnection, bool /*_bDelete*/) { + VclPtr<OQueryTableConnection> xConnection(static_cast<OQueryTableConnection*>(rConnection.get())); // we don't want that our connection will be deleted, we put it in the undo manager - bool bRet = OJoinTableView::RemoveConnection( _pConnection,false); + bool bRet = OJoinTableView::RemoveConnection(rConnection, false); // add undo action - addUndoAction( this, - new OQueryDelTabConnUndoAction(this), - static_cast< OQueryTableConnection*>(_pConnection), - true); + addUndoAction(this, + new OQueryDelTabConnUndoAction(this), + xConnection.get(), + true); + return bRet; } @@ -782,11 +784,12 @@ void OQueryTableView::GetConnection(OQueryTableConnection* pConn) addConnection( pConn ); } -void OQueryTableView::DropConnection(OQueryTableConnection* pConn) +void OQueryTableView::DropConnection(VclPtr<OQueryTableConnection>& rConn) { // Pay attention to the selection // remove from me and the document - RemoveConnection( pConn ,false); + VclPtr<OTableConnection> xConn(rConn.get()); + RemoveConnection(xConn, false); } void OQueryTableView::HideTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction ) @@ -826,17 +829,18 @@ void OQueryTableView::HideTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUndoAc auto aIter2 = rTabConList.begin(); for(;aIter2 != rTabConList.end();)// the end may change { - OQueryTableConnection* pTmpEntry = static_cast<OQueryTableConnection*>((*aIter2).get()); + VclPtr<OTableConnection> xTmpEntry = *aIter2; + OQueryTableConnection* pTmpEntry = static_cast<OQueryTableConnection*>(xTmpEntry.get()); OSL_ENSURE(pTmpEntry,"OQueryTableConnection is null!"); if( pTmpEntry->GetAliasName(JTCS_FROM) == pTabWin->GetAliasName() || pTmpEntry->GetAliasName(JTCS_TO) == pTabWin->GetAliasName() ) { // add to undo list - pUndoAction->InsertConnection(pTmpEntry); + pUndoAction->InsertConnection(xTmpEntry); // call base class because we append an undo action // but this time we are in a undo action list - OJoinTableView::RemoveConnection(pTmpEntry,false); + OJoinTableView::RemoveConnection(xTmpEntry, false); aIter2 = rTabConList.begin(); ++nCnt; } |