Welcome Guest Search | Active Topics | Log In | Register

Destroying a squirrel object from C
#1 Posted : Monday, June 6, 2016 10:09:31 AM(UTC)
Rank: Member

Groups: Registered
Joined: 5/19/2016(UTC)
Posts: 15
Location: UK

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)

I successfully create squirrel objects from C.

However, because they contain references to reference counted C++ objects (which I have bound to squirrel using Sqrat), there is a point at which I need to destroy the squirrel objects (this allowing their referenced C++ objects to die).

I tried using sq_deleteslot to delete the reference to the object from the root, but this doesn't seem to be having the desired effect.

as an illustration


class ViewHandler
    constructor(view)  // view is a reference to a Reference counted C++ class CView
         view_ = view; // view can't die until this reference is removed

    view_ = null;

#2 Posted : Saturday, June 25, 2016 8:07:07 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/19/2011(UTC)
Posts: 9

Thanks: 0 times
Was thanked: 1 time(s) in 1 post(s)
You can't manually delete Squirrel objects; they'll only be destroyed when the last reference to them goes away (or some time later, if you enabled the garbage collector)

You could effectively kill the C++ object by setting its pointers to NULL, but you'd need to do a null check every time you use it, and throw a Squirrel exception with sq_throwerror.

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.074 seconds.