View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000452 | Far Manager | _Common | public | 2007-12-27 08:30 | 2007-12-28 06:04 |
Reporter | vsergiy | Assigned To | vskirdin | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Fixed in Version | 1.80 alpha 1 | ||||
Summary | 0000452: Bug, doubling code and improvements in hotplug.cpp | ||||
Description | F9 -> Commands -> Hotplug devices list 1. Не проверялся результат функции GetDeviceProperty() – при этом strDescription или strFriendlyName могли содержать предыдущее значение (от предыдущего устройства). 2. Дублирование кода построения ListItem.strName. 3. Не проверялось отключено устройство или нет (CM_PROB_DISABLED). Патч в комплекте. | ||||
Tags | No tags attached. | ||||
Build | 397 | ||||
2007-12-27 08:30
|
hotplug.cpp.patch (4,450 bytes)
Index: hotplug.cpp =================================================================== --- hotplug.cpp (revision 1407) +++ hotplug.cpp (working copy) @@ -51,9 +51,9 @@ MY_EXTERN_C const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } #define VolumeClassGuid GUID_DEVINTERFACE_VOLUME MY_DEFINE_GUID(GUID_DEVINTERFACE_VOLUME, 0x53f5630dL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); -#define CM_DRP_FRIENDLYNAME (0x0000000D) -#define CM_DRP_DEVICEDESC (0x00000001) -#define CM_DRP_CAPABILITIES (0x00000010) +#define CM_DRP_FRIENDLYNAME (0x0000000D) +#define CM_DRP_DEVICEDESC (0x00000001) +#define CM_DRP_CAPABILITIES (0x00000010) #define CM_DEVCAP_REMOVABLE (0x00000004) #define CM_DEVCAP_SURPRISEREMOVALOK (0x00000080) #define CM_DEVCAP_DOCKDEVICE (0x00000008) @@ -197,49 +197,43 @@ if ( nCount ) { struct MenuItemEx ListItem; - string strFriendlyName; - string strDescription; for (int I = 0; I < nCount; I++) { + string strFriendlyName; + string strDescription; + DEVINST hDevInst=pInfo[I].hDevInst; - GetDeviceProperty (hDevInst,CM_DRP_FRIENDLYNAME,strFriendlyName,true); - RemoveExternalSpaces(strFriendlyName); - GetDeviceProperty (hDevInst,CM_DRP_DEVICEDESC,strDescription,true); - RemoveExternalSpaces(strDescription); - ListItem.Clear (); - if ( !strDescription.IsEmpty() ) - ListItem.strName = strDescription; - - if ( !strFriendlyName.IsEmpty() && StrCmpI(strDescription, strFriendlyName) ) + if (GetDeviceProperty (hDevInst,CM_DRP_DEVICEDESC,strDescription,true)) { - if ( !strDescription.IsEmpty() ) - ListItem.strName += L" \""; - - ListItem.strName += strFriendlyName; - - if ( !strDescription.IsEmpty() ) - ListItem.strName += L"\""; + if (!strDescription.IsEmpty ()) + { + RemoveExternalSpaces(strDescription); + ListItem.strName = strDescription; + } } - if(StrCmpI(strDescription,strFriendlyName) && !strFriendlyName.IsEmpty ()) + if (GetDeviceProperty (hDevInst,CM_DRP_FRIENDLYNAME,strFriendlyName,true)) { - //TruncStr(szDescription,sizeof(ListItem.Name)-1); - ListItem.strName = strDescription + L" \"" + strFriendlyName + L"\""; + RemoveExternalSpaces(strFriendlyName); + if (!strDescription.IsEmpty ()) + { + if (!strFriendlyName.IsEmpty () && StrCmpI(strDescription,strFriendlyName) ) + { + ListItem.strName += L" \"" + strFriendlyName + L"\""; + } + } + else if (!strFriendlyName.IsEmpty ()) + { + ListItem.strName = strFriendlyName; + } } - else - { - if(!strDescription.IsEmpty ()) - ListItem.strName = strDescription; - } - RemoveExternalSpaces(ListItem.strName); if(!ListItem.strName.IsEmpty ()) HotPlugList->SetUserData((void*)(INT_PTR)I,sizeof(I),HotPlugList->AddItem(&ListItem)); - } } @@ -283,10 +277,8 @@ case KEY_CTRLR: { - if(pInfo) FreeHotplugDevicesInfo (pInfo); - pInfo=NULL; HotPlugList.Hide(); HotPlugList.DeleteItems(); @@ -470,7 +462,9 @@ /**+ A device is considered a HotPlug device if the following are TRUE: -- Does NOT have problem CM_PROB_DEVICE_NOT_THERE +- does NOT have problem CM_PROB_DEVICE_NOT_THERE +- does NOT have problem CM_PROB_HELD_FOR_EJECT +- does NOT have problem CM_PROB_DISABLED - has Capability CM_DEVCAP_REMOVABLE - does NOT have Capability CM_DEVCAP_SURPRISEREMOVALOK - does NOT have Capability CM_DEVCAP_DOCKDEVICE @@ -511,6 +505,7 @@ { if ( (Problem != CM_PROB_DEVICE_NOT_THERE) && (Problem != CM_PROB_HELD_FOR_EJECT) && //��������, ���� ������� �� ������ ������� ����� + (Problem != CM_PROB_DISABLED) && (Capabilities & CM_DEVCAP_REMOVABLE) && !(Capabilities & CM_DEVCAP_SURPRISEREMOVALOK) && !(Capabilities & CM_DEVCAP_DOCKDEVICE) ) @@ -773,6 +768,7 @@ void FreeHotplugDevicesInfo (DeviceInfo *pInfo) { xf_free (pInfo); + pInfo=NULL; } bool GetDeviceProperty ( |
|
после 397 |
|
Кхе... а зачем в FreeHotplugDevicesInfo() добавлена строка: pInfo=NULL; Толку от нее никакого, т.к. pInfo для FreeHotplugDevicesInfo - всего лишь локальная переменная... |
|
Это указатель, который был передан из вызывающей функции. Добавлено было чтобы не присваивать каждый раз значение NULL указателю на DeviceInfo *pInfo после вызова FreeHotplugDevicesInfo(). |
|
NULL присваиватся локальной переменной pInfo в функции FreeHotplugDevicesInfo() - здесь она как раз локальная. Это не та переменная, которая используется в функциях, вызывающие FreeHotplugDevicesInfo. |
|
да, действительно так. |
Date Modified | Username | Field | Change |
---|---|---|---|
2007-12-27 08:30 | vsergiy | New Issue | |
2007-12-27 08:30 | vsergiy | File Added: hotplug.cpp.patch | |
2007-12-28 03:37 | vskirdin | Status | new => assigned |
2007-12-28 03:37 | vskirdin | Assigned To | => vskirdin |
2007-12-28 03:38 | vskirdin | Note Added: 0001084 | |
2007-12-28 03:38 | vskirdin | Status | assigned => feedback |
2007-12-28 03:44 | vskirdin | Note Added: 0001085 | |
2007-12-28 03:56 | vsergiy | Note Added: 0001086 | |
2007-12-28 04:07 | vskirdin | Note Added: 0001088 | |
2007-12-28 05:01 | vsergiy | Note Added: 0001089 | |
2007-12-28 05:10 | vsergiy | Status | feedback => resolved |
2007-12-28 05:10 | vsergiy | Resolution | open => fixed |
2007-12-28 06:04 | vskirdin | Build | => 397 |
2007-12-28 06:04 | vskirdin | Status | resolved => closed |
2007-12-28 06:04 | vskirdin | Fixed in Version | => 1.80 alpha 1 |