glib r7289 - in trunk/gio: . win32



Author: tml
Date: Sat Aug  2 23:51:51 2008
New Revision: 7289
URL: http://svn.gnome.org/viewvc/glib?rev=7289&view=rev

Log:
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.



Modified:
   trunk/gio/ChangeLog
   trunk/gio/win32/gwin32directorymonitor.c

Modified: trunk/gio/win32/gwin32directorymonitor.c
==============================================================================
--- trunk/gio/win32/gwin32directorymonitor.c	(original)
+++ trunk/gio/win32/gwin32directorymonitor.c	Sat Aug  2 23:51:51 2008
@@ -69,7 +69,8 @@
 	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 @@
 	
 	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;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]