VirtualBox

Changeset 38213 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Jul 28, 2011 9:35:47 AM (13 years ago)
Author:
vboxsync
Message:

main/usb/win: replug device fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/HostUSBDeviceImpl.cpp

    r35812 r38213  
    10861086    if (mUsb != aDev)
    10871087    {
     1088#ifdef RT_OS_WINDOWS
     1089        /* we used this logic of string comparison in HostUSBDevice::compare
     1090         * now we need to preserve strings from the old device if the new device has zero strings
     1091         * this ensures the device is correctly matched later on
     1092         * otherwise we may end up with a phantom misconfigured device instance */
     1093        if ((mUniSubState == kHostUSBDeviceSubState_AwaitingDetach /* (In case we don't get the detach notice.) */
     1094                   || mUniSubState == kHostUSBDeviceSubState_AwaitingReAttach)
     1095               && (!aDev->pszSerialNumber || !*aDev->pszSerialNumber)
     1096               && (!aDev->pszManufacturer || !*aDev->pszManufacturer)
     1097               && (!aDev->pszProduct      || !*aDev->pszProduct))
     1098        {
     1099            aDev->u64SerialHash = mUsb->u64SerialHash;
     1100
     1101            if (mUsb->pszSerialNumber && *mUsb->pszSerialNumber)
     1102            {
     1103                if (aDev->pszSerialNumber)
     1104                    RTStrFree((char *)aDev->pszSerialNumber);
     1105
     1106                /* since we're going to free old device later on,
     1107                 * we can just assign the string from it to the new device
     1108                 * and zero up the string filed for the old device */
     1109                aDev->pszSerialNumber = mUsb->pszSerialNumber;
     1110                mUsb->pszSerialNumber = NULL;
     1111            }
     1112
     1113            if (mUsb->pszManufacturer && *mUsb->pszManufacturer)
     1114            {
     1115                if (aDev->pszManufacturer)
     1116                    RTStrFree((char *)aDev->pszManufacturer);
     1117
     1118                /* since we're going to free old device later on,
     1119                 * we can just assign the string from it to the new device
     1120                 * and zero up the string filed for the old device */
     1121                aDev->pszManufacturer = mUsb->pszManufacturer;
     1122                mUsb->pszManufacturer = NULL;
     1123            }
     1124
     1125            if (mUsb->pszProduct && *mUsb->pszProduct)
     1126            {
     1127                if (aDev->pszProduct)
     1128                    RTStrFree((char *)aDev->pszProduct);
     1129
     1130                /* since we're going to free old device later on,
     1131                 * we can just assign the string from it to the new device
     1132                 * and zero up the string filed for the old device */
     1133                aDev->pszProduct = mUsb->pszProduct;
     1134                mUsb->pszProduct = NULL;
     1135            }
     1136        }
     1137#endif
    10881138        aDev->pNext = mUsb->pNext;
    10891139        aDev->pPrev = mUsb->pPrev;
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