[Libreoffice-bugs] [Bug 39995] New: GDIMetaFile::ReplaceAction now releases replaced action, while previous implementation didn't

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu Aug 11 11:20:43 CEST 2011


https://bugs.freedesktop.org/show_bug.cgi?id=39995

           Summary: GDIMetaFile::ReplaceAction now releases replaced
                    action, while previous implementation didn't
           Product: LibreOffice
           Version: LibO Master
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: medium
         Component: Libreoffice
        AssignedTo: libreoffice-bugs at lists.freedesktop.org
        ReportedBy: caolanm at redhat.com


inc/vcl/metaact.hxx

class MetaAction
...
    sal_uLong                           mnRefCount;
    void                                Duplicate()  { mnRefCount++; }
    void                                Delete() { if ( 0 == --mnRefCount )
delete this; }

i.e. its reference counted...

In the old 3-4 series we had...
inc/vcl/gdimtf.hxx
    MetaAction*     ReplaceAction( MetaAction* pAction, sal_uLong nAction ) {
return (MetaAction*) Replace( pAction, nAction ); }

i.e. there was no effort made within "ReplaceAction" itself to
decrement/increment the ref count

which is why we have...

svtools/source/graphic/grfmgr2.cxx
909: rOutMtf.ReplaceAction( pModAct = pAct->Clone(), nCurPos );
910: pAct->Delete();


but now we have...

MetaAction* GDIMetaFile::ReplaceAction(MetaAction* pAction, size_t nAction)     
{                                                                               
 if ( nAction < aList.size() )
 {
   ::std::vector< MetaAction* >::iterator it = aList.begin();
   ::std::advance( it, nAction );
   (*it)->Delete();
   *it = pAction;
 }
 return pAction;
} 

i.e. we release the old one when we replace it, which looks good, except that
the caller of this is *also* releasing the old one because the previous
implementation didn't release it.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the Libreoffice-bugs mailing list