How can I check if an object was deleted?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I check if an object was deleted?

omer.tal
Hey guys,

I'm implementing an RTSP server. When the client disconnects, the media gets
destroyed.
I do however, keep a pointer to my appsrc element somewhere.

How can I check if the element hasn't been destroyed?
I've tried G_IS_OBJECT but that just returns true even though the element
was destroyed...

For now I just keep a boolean member of my class and set and unset it using
the /media-configured/, and /unprepared/ signals, but that just seems wrong.

Thanks and best of wishes.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How can I check if an object was deleted?

Sebastian Dröge-3
On Sun, 2021-04-18 at 06:50 -0500, omer.tal wrote:

>
> I'm implementing an RTSP server. When the client disconnects, the media gets
> destroyed.
> I do however, keep a pointer to my appsrc element somewhere.
>
> How can I check if the element hasn't been destroyed?
> I've tried G_IS_OBJECT but that just returns true even though the element
> was destroyed...
>
> For now I just keep a boolean member of my class and set and unset it using
> the /media-configured/, and /unprepared/ signals, but that just seems wrong.

You could use a `GWeakRef` for this. It will not keep the object alive
but allows you to safely get a strong reference to it when needed, and
would return `NULL` if the object disappeared in the meantime.

--
Sebastian Dröge, Centricular Ltd · https://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel