Alexandre Julliard : explorer: Avoid repeated notifications on device removal.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Oct 3 10:04:22 CDT 2006


Module: wine
Branch: master
Commit: ab6fa810d7f36dc345e8946272043f85c34bf1d2
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=ab6fa810d7f36dc345e8946272043f85c34bf1d2

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Oct  3 12:40:39 2006 +0200

explorer: Avoid repeated notifications on device removal.

---

 programs/explorer/device.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/programs/explorer/device.c b/programs/explorer/device.c
index 0b86b43..e3309fa 100644
--- a/programs/explorer/device.c
+++ b/programs/explorer/device.c
@@ -143,13 +143,14 @@ done:
     return drive;
 }
 
-static void set_mount_point( struct dos_drive *drive, const char *mount_point )
+static BOOL set_mount_point( struct dos_drive *drive, const char *mount_point )
 {
     char *path, *p;
     struct stat path_st, mnt_st;
+    BOOL modified = FALSE;
 
-    if (drive->drive == -1) return;
-    if (!(path = get_dosdevices_path())) return;
+    if (drive->drive == -1) return FALSE;
+    if (!(path = get_dosdevices_path())) return FALSE;
     p = path + strlen(path) - 3;
     *p = 'a' + drive->drive;
     p[2] = 0;
@@ -162,11 +163,16 @@ static void set_mount_point( struct dos_
         {
             unlink( path );
             symlink( mount_point, path );
+            modified = TRUE;
         }
     }
-    else unlink( path );
+    else
+    {
+        if (unlink( path ) != -1) modified = TRUE;
+    }
 
     HeapFree( GetProcessHeap(), 0, path );
+    return modified;
 }
 
 BOOL add_dos_device( const char *udi, const char *device,
@@ -227,7 +233,7 @@ BOOL remove_dos_device( const char *udi 
 
         if (drive->drive != -1)
         {
-            set_mount_point( drive, "" );
+            BOOL modified = set_mount_point( drive, "" );
 
             /* clear the registry key too */
             if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Drives", &hkey ))
@@ -238,7 +244,7 @@ BOOL remove_dos_device( const char *udi 
                 RegCloseKey( hkey );
             }
 
-            send_notify( drive->drive, DBT_DEVICEREMOVECOMPLETE );
+            if (modified) send_notify( drive->drive, DBT_DEVICEREMOVECOMPLETE );
         }
 
         list_remove( &drive->entry );




More information about the wine-cvs mailing list