[glib] Correct reference and implement close_fn (#578769)
- From: Tor Lillqvist <tml src gnome org>
- To: svn-commits-list gnome org
- Subject: [glib] Correct reference and implement close_fn (#578769)
- Date: Wed, 27 May 2009 08:15:50 -0400 (EDT)
commit 209a662c2fb664bed2bf4e26bbda784ca7c0739d
Author: Hans Breuer <hans breuer org>
Date: Wed May 27 15:12:31 2009 +0300
Correct reference and implement close_fn (#578769)
Do proper referencing and unreferencing of
GWinHttpFileInputStream::file and
GWinHttpFileInputStream::file::vfs. Implement
GWinHttpFileInputStream::close_fn.
---
gio/win32/gwinhttpfile.c | 5 ++++-
gio/win32/gwinhttpfileinputstream.c | 23 ++++++++++++++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/gio/win32/gwinhttpfile.c b/gio/win32/gwinhttpfile.c
index 6bd05b7..a4709ed 100644
--- a/gio/win32/gwinhttpfile.c
+++ b/gio/win32/gwinhttpfile.c
@@ -24,6 +24,7 @@
#include "config.h"
+#include <stdio.h>
#include <string.h>
#include <wchar.h>
@@ -60,6 +61,8 @@ g_winhttp_file_finalize (GObject *object)
g_free (file->url.lpszUrlPath);
g_free (file->url.lpszExtraInfo);
+ g_object_unref (file->vfs);
+
G_OBJECT_CLASS (g_winhttp_file_parent_class)->finalize (object);
}
@@ -96,7 +99,7 @@ _g_winhttp_file_new (GWinHttpVfs *vfs,
return NULL;
file = g_object_new (G_TYPE_WINHTTP_FILE, NULL);
- file->vfs = vfs;
+ file->vfs = g_object_ref (vfs);
memset (&file->url, 0, sizeof (file->url));
file->url.dwStructSize = sizeof (file->url);
diff --git a/gio/win32/gwinhttpfileinputstream.c b/gio/win32/gwinhttpfileinputstream.c
index 3a90374..f18a93a 100644
--- a/gio/win32/gwinhttpfileinputstream.c
+++ b/gio/win32/gwinhttpfileinputstream.c
@@ -57,6 +57,10 @@ static gssize g_winhttp_file_input_stream_read (GInputStream *stream,
GCancellable *cancellable,
GError **error);
+static gboolean g_winhttp_file_input_stream_close (GInputStream *stream,
+ GCancellable *cancellable,
+ GError **error);
+
static void
g_winhttp_file_input_stream_finalize (GObject *object)
{
@@ -69,6 +73,9 @@ g_winhttp_file_input_stream_finalize (GObject *object)
if (winhttp_stream->connection != NULL)
G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpCloseHandle (winhttp_stream->connection);
+ g_object_unref (winhttp_stream->file);
+ winhttp_stream->file = NULL;
+
G_OBJECT_CLASS (g_winhttp_file_input_stream_parent_class)->finalize (object);
}
@@ -81,6 +88,7 @@ g_winhttp_file_input_stream_class_init (GWinHttpFileInputStreamClass *klass)
gobject_class->finalize = g_winhttp_file_input_stream_finalize;
stream_class->read_fn = g_winhttp_file_input_stream_read;
+ stream_class->close_fn = g_winhttp_file_input_stream_close;
}
static void
@@ -105,7 +113,7 @@ _g_winhttp_file_input_stream_new (GWinHttpFile *file,
stream = g_object_new (G_TYPE_WINHTTP_FILE_INPUT_STREAM, NULL);
- stream->file = file;
+ stream->file = g_object_ref (file);
stream->request_sent = FALSE;
stream->connection = connection;
stream->request = request;
@@ -156,3 +164,16 @@ g_winhttp_file_input_stream_read (GInputStream *stream,
return bytes_read;
}
+
+static gboolean
+g_winhttp_file_input_stream_close (GInputStream *stream,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GWinHttpFileInputStream *winhttp_stream = G_WINHTTP_FILE_INPUT_STREAM (stream);
+
+ if (winhttp_stream->connection != NULL)
+ G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpCloseHandle (winhttp_stream->connection);
+ winhttp_stream->connection = NULL;
+ return TRUE;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]