Bug 541036 - Gnumeric crashes when trying to open Desktop or user's folder
authorTor Lillqvist <tml@novell.com>
Sat, 2 Aug 2008 23:51:51 +0000 (23:51 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Sat, 2 Aug 2008 23:51:51 +0000 (23:51 +0000)
2008-08-03  Tor Lillqvist  <tml@novell.com>

Bug 541036 - Gnumeric crashes when trying to open Desktop or
user's folder under Windows

* win32/gwin32directorymonitor.c
(g_win32_directory_monitor_constructor): Ignore error from
CreateFile() when opening directory. Instead of asserting, just
store INVALID_HANDLE_VALUE then in
GWin32DirectoryMonitorPrivate::hDirectory. Also ignore error from
ReadDirectoryChangesW().
(g_win32_directory_monitor_cancel): Don't attempt to close
directory handle if it is INVALID_HANDLE_VALUE.

svn path=/trunk/; revision=7289

gio/ChangeLog
gio/win32/gwin32directorymonitor.c

index 50b45cb..8392600 100644 (file)
@@ -1,3 +1,17 @@
+2008-08-03  Tor Lillqvist  <tml@novell.com>
+
+       Bug 541036 - Gnumeric crashes when trying to open Desktop or
+       user's folder under Windows
+
+       * win32/gwin32directorymonitor.c
+       (g_win32_directory_monitor_constructor): Ignore error from
+       CreateFile() when opening directory. Instead of asserting, just
+       store INVALID_HANDLE_VALUE then in
+       GWin32DirectoryMonitorPrivate::hDirectory. Also ignore error from
+       ReadDirectoryChangesW().
+       (g_win32_directory_monitor_cancel): Don't attempt to close
+       directory handle if it is INVALID_HANDLE_VALUE.
+
 2008-08-01  Matthias Clasen  <mclasen@redhat.com>
 
        * gdesktopappinfo.c: Remove debug spew
index b3db62d..732b762 100644 (file)
@@ -69,7 +69,8 @@ static gboolean g_win32_directory_monitor_cancel (GFileMonitor* base) {
        self = G_WIN32_DIRECTORY_MONITOR (base);
        
        /* this triggers a last callback() with nBytes=0 */ 
-       CloseHandle (self->priv->hDirectory);
+       if (self->priv->hDirectory != INVALID_HANDLE_VALUE)
+         CloseHandle (self->priv->hDirectory);
 
        if (G_FILE_MONITOR_CLASS (g_win32_directory_monitor_parent_class)->cancel)
        (*G_FILE_MONITOR_CLASS (g_win32_directory_monitor_parent_class)->cancel) (base);
@@ -130,13 +131,17 @@ static GObject * g_win32_directory_monitor_constructor (GType type, guint n_cons
        
        self->priv->hDirectory = CreateFile (dirname, FILE_LIST_DIRECTORY, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, 
                NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL); 
-       g_assert (self->priv->hDirectory != INVALID_HANDLE_VALUE); /* harsh */
+       if (self->priv->hDirectory == INVALID_HANDLE_VALUE)
+         {
+           /* Ignore errors */
+           return obj;
+         }
 
        result = ReadDirectoryChangesW (self->priv->hDirectory, (gpointer)self->priv->file_notify_buffer, self->priv->buffer_allocated_bytes, FALSE, 
                FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES |
                FILE_NOTIFY_CHANGE_SIZE, &self->priv->buffer_filled_bytes, &self->priv->overlapped, g_win32_directory_monitor_callback);
-       g_assert (result); /* harsh */
-
+       /* Ignore errors */
+       
        return obj;
 }