https://bugs.documentfoundation.org/show_bug.cgi?id=100782

            Bug ID: 100782
           Summary: Have XPropertyList and its derivatives hold smart
                    pointers
           Product: LibreOffice
           Version: Inherited From OOo
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: LibreOffice
          Assignee: libreoffice-bugs@lists.freedesktop.org
          Reporter: katarina.behr...@cib.de

XPropertyList and its derivatives (XHatchList, XGradientList, XColorList etc.)
hold their items in a vector of raw pointers. Methods such as Replace, Remove
return the pointer to the item and it is up to the caller to delete the item,
which results in butt-ugly code e.g. like this:

XColorEntry* pEntry = pColorList->Remove( nPos );
assert( pEntry && "ColorEntry not found !" );
delete pEntry;

Or this:

XColorEntry* pEntry = new XColorEntry(aCurrentColor, aName);
delete pColorList->Replace(pEntry, nPos);

This hack is about replacing raw pointers with smart pointers in those
containers (and of course adapt the code using them).

Code pointers: start from include/svx/xtable.hxx,
svx/source/xoutdev/xtable.cxx. Replace std::vector< XPropertyEntry*>  with
std::vector< std::unique_ptr > ( or maybe shared_ptr ... I didn't check all the
usage of this class ). 

Adapt users of those lists to use smart instead of raw pointers, compile, rinse
and repeat.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
Libreoffice-bugs@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to