diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-21 10:33:18 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-28 08:46:25 +0200 |
commit | 39d19a88bd4f0bd22aa843b630ab50f9b2708d87 (patch) | |
tree | a3d64993cb85ca6b066c3a6840ebf16dee286b8f | |
parent | 7fd67ca9361cc15732c505004ab4471bd2cf7f99 (diff) |
loplugin:useuniqueptr in OTableConnection
Change-Id: I4fe5c706d0aec4b2b81bdbe9e9a59e771af4a02e
Reviewed-on: https://gerrit.libreoffice.org/54854
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
5 files changed, 13 insertions, 14 deletions
diff --git a/dbaccess/source/ui/inc/TableConnection.hxx b/dbaccess/source/ui/inc/TableConnection.hxx index 7b6725772796..04759077eff8 100644 --- a/dbaccess/source/ui/inc/TableConnection.hxx +++ b/dbaccess/source/ui/inc/TableConnection.hxx @@ -36,7 +36,7 @@ namespace dbaui class OTableConnection : public vcl::Window { - std::vector<OConnectionLine*> m_vConnLine; + std::vector<std::unique_ptr<OConnectionLine>> m_vConnLine; TTableConnectionData::value_type m_pData; VclPtr<OJoinTableView> m_pParent; @@ -88,7 +88,7 @@ namespace dbaui tools::Rectangle GetBoundingRect() const; const TTableConnectionData::value_type& GetData() const { return m_pData; } - const std::vector<OConnectionLine*>& GetConnLineList() const { return m_vConnLine; } + const std::vector<std::unique_ptr<OConnectionLine>>& GetConnLineList() const { return m_vConnLine; } OJoinTableView* GetParent() const { return m_pParent; } virtual void Draw(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect); using Window::Draw; diff --git a/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx index 04a9da583b56..bd90d9688490 100644 --- a/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx +++ b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx @@ -18,6 +18,7 @@ */ #include <ConnectionLineAccess.hxx> +#include <ConnectionLine.hxx> #include <JoinTableView.hxx> #include <com/sun/star/accessibility/AccessibleRole.hpp> #include <com/sun/star/accessibility/AccessibleRelationType.hpp> diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx index f361ca0b125d..dda98512cb77 100644 --- a/dbaccess/source/ui/querydesign/JoinTableView.cxx +++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx @@ -892,8 +892,8 @@ void OJoinTableView::SelectConn(OTableConnection* pConn) SvTreeListEntry* pFirstSourceVisible = pSourceBox->GetFirstEntryInView(); SvTreeListEntry* pFirstDestVisible = pDestBox->GetFirstEntryInView(); - const std::vector<OConnectionLine*>& rLines = pConn->GetConnLineList(); - std::vector<OConnectionLine*>::const_reverse_iterator aIter = rLines.rbegin(); + const std::vector<std::unique_ptr<OConnectionLine>>& rLines = pConn->GetConnLineList(); + auto aIter = rLines.rbegin(); for(;aIter != rLines.rend();++aIter) { if ((*aIter)->IsValid()) @@ -1144,8 +1144,8 @@ void OJoinTableView::Command(const CommandEvent& rEvt) { if (rSelConnection) { - const std::vector<OConnectionLine*>& rLines = rSelConnection->GetConnLineList(); - std::vector<OConnectionLine*>::const_iterator aIter = std::find_if(rLines.begin(), rLines.end(),std::mem_fn(&OConnectionLine::IsValid)); + const std::vector<std::unique_ptr<OConnectionLine>>& rLines = rSelConnection->GetConnLineList(); + auto aIter = std::find_if(rLines.begin(), rLines.end(),std::mem_fn(&OConnectionLine::IsValid)); if( aIter != rLines.end() ) executePopup((*aIter)->getMidPoint(), rSelConnection); } diff --git a/dbaccess/source/ui/querydesign/TableConnection.cxx b/dbaccess/source/ui/querydesign/TableConnection.cxx index 21f82f792feb..25ce126c306d 100644 --- a/dbaccess/source/ui/querydesign/TableConnection.cxx +++ b/dbaccess/source/ui/querydesign/TableConnection.cxx @@ -57,13 +57,11 @@ namespace dbaui OConnectionLineDataVec& rLineData = GetData()->GetConnLineDataList(); m_vConnLine.reserve(rLineData.size()); for (auto const& elem : rLineData) - m_vConnLine.push_back( new OConnectionLine(this, elem) ); + m_vConnLine.emplace_back( new OConnectionLine(this, elem) ); } void OTableConnection::clearLineData() { - for (auto const& elem : m_vConnLine) - delete elem; m_vConnLine.clear(); } void OTableConnection::UpdateLineList() @@ -85,10 +83,10 @@ namespace dbaui // copy linelist if(! rConn.GetConnLineList().empty() ) { - const std::vector<OConnectionLine*>& rLine = rConn.GetConnLineList(); + const std::vector<std::unique_ptr<OConnectionLine>>& rLine = rConn.GetConnLineList(); m_vConnLine.reserve(rLine.size()); for (auto const& elem : rLine) - m_vConnLine.push_back( new OConnectionLine(*elem)); + m_vConnLine.emplace_back( new OConnectionLine(*elem)); } // as the data are not mine, I also do not delete the old @@ -146,7 +144,7 @@ namespace dbaui return std::any_of(m_vConnLine.begin(), m_vConnLine.end(), [&rMousePos] - ( const OConnectionLine* pLine ) + ( const std::unique_ptr<OConnectionLine> & pLine ) { return pLine->CheckHit( rMousePos ); } ); } diff --git a/dbaccess/source/ui/relationdesign/RTableConnection.cxx b/dbaccess/source/ui/relationdesign/RTableConnection.cxx index b76016d14c1a..56e7549c1998 100644 --- a/dbaccess/source/ui/relationdesign/RTableConnection.cxx +++ b/dbaccess/source/ui/relationdesign/RTableConnection.cxx @@ -60,7 +60,7 @@ void ORelationTableConnection::Draw(vcl::RenderContext& rRenderContext, const to long nTemp; const OConnectionLine* pTopLine = nullptr; - const std::vector<OConnectionLine*>& rConnLineList = GetConnLineList(); + const std::vector<std::unique_ptr<OConnectionLine>>& rConnLineList = GetConnLineList(); for (auto const& elem : rConnLineList) { @@ -71,7 +71,7 @@ void ORelationTableConnection::Draw(vcl::RenderContext& rRenderContext, const to if(nTemp < nTop) { nTop = nTemp; - pTopLine = elem; + pTopLine = elem.get(); } } } |