VirtualBox

Ignore:
Timestamp:
Jul 10, 2015 6:09:14 AM (9 years ago)
Author:
vboxsync
Message:

DnD: Changed DnDURIList's allocation scheme for stored DnDURIObject objects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/DragAndDrop/DnDURIList.cpp

    r56903 r56909  
    4343DnDURIList::~DnDURIList(void)
    4444{
     45    Clear();
    4546}
    4647
     
    6061            LogFlowFunc(("File '%s' -> '%s' (%RU64)\n", pcszSource, pcszTarget, (uint64_t)objInfo.cbObject));
    6162
    62             DnDURIObject objFile(DnDURIObject::File, pcszSource, pcszTarget);
    63             if (fFlags & DNDURILIST_FLAGS_KEEP_OPEN) /* Shall we keep the file open while being added to this list? */
    64             {
    65                 /** @todo Add a standard fOpen mode for this list. */
    66                 rc = objFile.Open(DnDURIObject::Source, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE, objInfo.Attr.fMode);
    67             }
    68 
    69             if (RT_SUCCESS(rc))
    70             {
    71                 m_lstTree.append(objFile);
    72 
    73                 m_cTotal++;
    74                 m_cbTotal += (uint64_t)objInfo.cbObject;
    75             }
     63            DnDURIObject *pObjFile= new DnDURIObject(DnDURIObject::File, pcszSource, pcszTarget);
     64            if (pObjFile)
     65            {
     66                if (fFlags & DNDURILIST_FLAGS_KEEP_OPEN) /* Shall we keep the file open while being added to this list? */
     67                {
     68                    /** @todo Add a standard fOpen mode for this list. */
     69                    rc = pObjFile->Open(DnDURIObject::Source, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE, objInfo.Attr.fMode);
     70                }
     71
     72                if (RT_SUCCESS(rc))
     73                {
     74                    m_lstTree.append(pObjFile);
     75
     76                    m_cTotal++;
     77                    m_cbTotal += pObjFile->GetSize();
     78                }
     79            }
     80            else
     81                rc = VERR_NO_MEMORY;
    7682        }
    7783        else if (RTFS_IS_DIRECTORY(objInfo.Attr.fMode))
     
    7985            LogFlowFunc(("Directory '%s' -> '%s' \n", pcszSource, pcszTarget));
    8086
    81             m_lstTree.append(DnDURIObject(DnDURIObject::Directory, pcszSource, pcszTarget,
    82                              objInfo.Attr.fMode, 0 /* Size */));
     87            DnDURIObject *pObjDir= new DnDURIObject(DnDURIObject::Directory, pcszSource, pcszTarget,
     88                                                    objInfo.Attr.fMode, 0 /* Size */);
     89            if (pObjDir)
     90            {
     91                m_lstTree.append(pObjDir);
     92            }
     93            else
     94                rc = VERR_NO_MEMORY;
    8395
    8496            /** @todo Add DNDURILIST_FLAGS_KEEP_OPEN handling. */
     
    397409{
    398410    m_lstRoot.clear();
     411
     412    for (size_t i = 0; i < m_lstTree.size(); i++)
     413    {
     414        DnDURIObject *pCurObj = m_lstTree.at(i);
     415        AssertPtr(pCurObj);
     416        RTMemFree(pCurObj);
     417    }
    399418    m_lstTree.clear();
    400419
     
    408427        return;
    409428
    410     DnDURIObject &curObj = m_lstTree.first();
    411 
    412     uint64_t cbSize = curObj.GetSize();
     429    DnDURIObject *pCurObj = m_lstTree.first();
     430    AssertPtr(pCurObj);
     431
     432    uint64_t cbSize = pCurObj->GetSize();
    413433    Assert(m_cbTotal >= cbSize);
    414434    m_cbTotal -= cbSize; /* Adjust total size. */
    415435
    416     curObj.Close();
     436    pCurObj->Close();
     437    RTMemFree(pCurObj);
    417438
    418439    m_lstTree.removeFirst();
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette