Kaydet (Commit) edfa0562 authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz#7121 NamedDBs::insert takes ownership of its argument

at one point this was based on std::auto_ptr and didn't
free its arg on failure

Change-Id: I8aeed6876d80b7ebe4ebb5e2cfd12e00420bd207
Reviewed-on: https://gerrit.libreoffice.org/51932Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 3acc5a23
......@@ -262,7 +262,7 @@ public:
Deletes p if it could not be inserted, i.e. duplicate name.
@return <TRUE/> if inserted, else <FALSE/>.
*/
SAL_WARN_UNUSED_RESULT bool insert(ScDBData* p);
bool insert(ScDBData* p);
void erase(const iterator& itr);
bool empty() const;
......
......@@ -1581,8 +1581,6 @@ void Test::testSharedFormulaUpdateOnDBChange()
// Define database range 'MyRange' for A1:A2.
ScDBData* pData = new ScDBData("MyRange", 0, 0, 0, 0, 1);
bool bInserted = pDBs->getNamedDBs().insert(pData);
if (!bInserted)
delete pData;
CPPUNIT_ASSERT_MESSAGE("Failed to insert a new database range.", bInserted);
// Insert in C2:C4 a group of formula cells that reference MyRange.
......@@ -1606,8 +1604,6 @@ void Test::testSharedFormulaUpdateOnDBChange()
ScDBCollection aNewDBs(m_pDoc);
ScDBData* pNewData = new ScDBData("MyRange", 0, 0, 0, 0, 3);
bInserted = aNewDBs.getNamedDBs().insert(pNewData);
if (!bInserted)
delete pNewData;
CPPUNIT_ASSERT_MESSAGE("Failed to insert a new database range.", bInserted);
std::vector<ScRange> aDeleted;
......
......@@ -444,10 +444,7 @@ void SAL_CALL ScXMLDatabaseRangeContext::endFastElement( sal_Int32 /*nElement*/
if (pData.get())
{
setAutoFilterFlags(*pDoc, *pData);
if (pDoc->GetDBCollection()->getNamedDBs().insert(pData.get()))
{
pData.release();
}
pDoc->GetDBCollection()->getNamedDBs().insert(pData.release());
}
}
}
......
......@@ -170,7 +170,6 @@ bool ScDBDocFunc::RenameDBRange( const OUString& rOld, const OUString& rNew )
bool bInserted = rDBs.insert(pNewData);
if (!bInserted) // error -> restore old state
{
delete pNewData;
rDoc.SetDBCollection(std::move(pUndoColl)); // belongs to the document then
}
......
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