mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
Correct reference and implement close_fn (#578769)
Do proper referencing and unreferencing of GWinHttpFileInputStream::file and GWinHttpFileInputStream::file::vfs. Implement GWinHttpFileInputStream::close_fn.
This commit is contained in:
parent
623f99dc3d
commit
209a662c2f
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
@ -60,6 +61,8 @@ g_winhttp_file_finalize (GObject *object)
|
|||||||
g_free (file->url.lpszUrlPath);
|
g_free (file->url.lpszUrlPath);
|
||||||
g_free (file->url.lpszExtraInfo);
|
g_free (file->url.lpszExtraInfo);
|
||||||
|
|
||||||
|
g_object_unref (file->vfs);
|
||||||
|
|
||||||
G_OBJECT_CLASS (g_winhttp_file_parent_class)->finalize (object);
|
G_OBJECT_CLASS (g_winhttp_file_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +99,7 @@ _g_winhttp_file_new (GWinHttpVfs *vfs,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
file = g_object_new (G_TYPE_WINHTTP_FILE, 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));
|
memset (&file->url, 0, sizeof (file->url));
|
||||||
file->url.dwStructSize = sizeof (file->url);
|
file->url.dwStructSize = sizeof (file->url);
|
||||||
|
@ -57,6 +57,10 @@ static gssize g_winhttp_file_input_stream_read (GInputStream *stream,
|
|||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
static gboolean g_winhttp_file_input_stream_close (GInputStream *stream,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_winhttp_file_input_stream_finalize (GObject *object)
|
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)
|
if (winhttp_stream->connection != NULL)
|
||||||
G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpCloseHandle (winhttp_stream->connection);
|
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);
|
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;
|
gobject_class->finalize = g_winhttp_file_input_stream_finalize;
|
||||||
|
|
||||||
stream_class->read_fn = g_winhttp_file_input_stream_read;
|
stream_class->read_fn = g_winhttp_file_input_stream_read;
|
||||||
|
stream_class->close_fn = g_winhttp_file_input_stream_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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 = g_object_new (G_TYPE_WINHTTP_FILE_INPUT_STREAM, NULL);
|
||||||
|
|
||||||
stream->file = file;
|
stream->file = g_object_ref (file);
|
||||||
stream->request_sent = FALSE;
|
stream->request_sent = FALSE;
|
||||||
stream->connection = connection;
|
stream->connection = connection;
|
||||||
stream->request = request;
|
stream->request = request;
|
||||||
@ -156,3 +164,16 @@ g_winhttp_file_input_stream_read (GInputStream *stream,
|
|||||||
|
|
||||||
return bytes_read;
|
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;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user