GCancellable is not really cancellable?
- From: Felipe Contreras <felipe contreras gmail com>
- To: gtk-devel-list <gtk-devel-list gnome org>
- Subject: GCancellable is not really cancellable?
- Date: Sun, 25 Apr 2010 22:05:43 +0300
Hi,
I am writing code that calls g_input_stream_read_async() and pass a
custom connection object as user_data; when the object is destroyed I
would expect the callback to not be called again, as obviously I don't
care about the result of the operation any more, in fact I know
exactly what I would get (connection closed).
Intuitively, I added a GCancellable, and called g_cancellable_cancel()
when my object is destroyed; to my surprise nothing changed.
Apparently the callback is always called, reading from GAsyncResult
documentation:
---
The callback for an asynchronous operation is called only once, and is
always called, even in the case of a cancelled operation. On
cancellation the result is a G_IO_ERROR_CANCELLED error.
---
So what am I supposed to do? ref() the object each time I do an async
operation, and unref() it each time the operation finishes, while also
keeping an extra field in order to find out if the object has been
disposed?
What's the point? Wouldn't it be better to truly cancel the operation?
Cheers.
--
Felipe Contreras
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]