VirtualBox

Ignore:
Timestamp:
Jul 1, 2020 10:34:34 AM (5 years ago)
Author:
vboxsync
Message:

DnD/URIObject: Follow-up fixes for r138893 + r138894.

File:
1 edited

Legend:

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

    r85005 r85017  
    3434
    3535DnDURIObject::DnDURIObject(Type enmType /* = Type_Unknown */, const RTCString &strPathAbs /* = "" */)
     36    : m_enmType(Type_Unknown)
    3637{
    3738    int rc2 = Init(enmType, strPathAbs);
     
    5758        case Type_File:
    5859        {
    59             LogRel2(("DnD: Closing file '%s'\n", m_strPathAbs.c_str()));
    60 
    61             rc = RTFileClose(u.File.hFile);
    62             if (RT_SUCCESS(rc))
     60            if (RTFileIsValid(u.File.hFile))
    6361            {
    64                 u.File.hFile = NIL_RTFILE;
    65                 RT_ZERO(u.File.objInfo);
     62                LogRel2(("DnD: Closing file '%s'\n", m_strPathAbs.c_str()));
     63
     64                rc = RTFileClose(u.File.hFile);
     65                if (RT_SUCCESS(rc))
     66                {
     67                    u.File.hFile = NIL_RTFILE;
     68                    RT_ZERO(u.File.objInfo);
     69                }
     70                else
     71                    LogRel(("DnD: Closing file '%s' failed with %Rrc\n", m_strPathAbs.c_str(), rc));
    6672            }
    67             else
    68                 LogRel(("DnD: Closing file '%s' failed with %Rrc\n", m_strPathAbs.c_str(), rc));
    6973            break;
    7074        }
     
    7276        case Type_Directory:
    7377        {
    74             LogRel2(("DnD: Closing directory '%s'\n", m_strPathAbs.c_str()));
    75 
    76             rc = RTDirClose(u.Dir.hDir);
    77             if (RT_SUCCESS(rc))
     78            if (RTDirIsValid(u.Dir.hDir))
    7879            {
    79                 u.Dir.hDir = NIL_RTDIR;
    80                 RT_ZERO(u.Dir.objInfo);
     80                LogRel2(("DnD: Closing directory '%s'\n", m_strPathAbs.c_str()));
     81
     82                rc = RTDirClose(u.Dir.hDir);
     83                if (RT_SUCCESS(rc))
     84                {
     85                    u.Dir.hDir = NIL_RTDIR;
     86                    RT_ZERO(u.Dir.objInfo);
     87                }
     88                else
     89                    LogRel(("DnD: Closing directory '%s' failed with %Rrc\n", m_strPathAbs.c_str(), rc));
    8190            }
    82             else
    83                 LogRel(("DnD: Closing directory '%s' failed with %Rrc\n", m_strPathAbs.c_str(), rc));
    8491            break;
    8592        }
     
    163170int DnDURIObject::Init(Type enmType, const RTCString &strPathAbs /* = */)
    164171{
    165     AssertReturn(enmType == Type_Unknown, VERR_WRONG_ORDER);
     172    AssertReturn(m_enmType == Type_Unknown, VERR_WRONG_ORDER);
    166173
    167174    int rc;
    168175
    169     switch (m_enmType)
     176    switch (enmType)
    170177    {
    171178        case Type_File:
     
    187194    if (enmType != Type_Unknown)
    188195    {
    189         AssertReturn(m_strPathAbs.isNotEmpty(), VERR_INVALID_PARAMETER);
    190         rc = DnDPathConvert(m_strPathAbs.mutableRaw(), m_strPathAbs.capacity(), DNDPATHCONVERT_FLAGS_TO_NATIVE);
     196        AssertReturn(strPathAbs.isNotEmpty(), VERR_INVALID_PARAMETER);
     197        RTCString strPathAbsCopy = strPathAbs;
     198        rc = DnDPathConvert(strPathAbsCopy.mutableRaw(), strPathAbsCopy.capacity(), DNDPATHCONVERT_FLAGS_TO_NATIVE);
    191199        if (RT_SUCCESS(rc))
    192200        {
    193201            m_enmType    = enmType;
    194             m_strPathAbs = strPathAbs;
     202            m_strPathAbs = strPathAbsCopy;
    195203        }
    196204        else
    197             LogRel2(("DnD: Absolute file path for guest file on the host is now '%s'\n", m_strPathAbs.c_str()));
     205            LogRel2(("DnD: Absolute file path for guest file on the host is now '%s'\n", strPathAbs.c_str()));
    198206    }
    199207    else
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