boom
boom

Reputation: 6166

releasing Glib::RefPtr

How can i release the pointer sourceImage after finishing using it.

Glib::RefPtr<Gdk::Pixbuf> sourceImage = Gdk::Pixbuf::create_from_file(inSourcePath.c_str());

Upvotes: 1

Views: 986

Answers (2)

jonner
jonner

Reputation: 6509

As mentioned, you don't need to release it. Just let the RefPtr go out of scope and it will be released automatically. However, if for some reason you do want to release it manually, you can simply call sourceImage.reset()

Upvotes: 4

Mark
Mark

Reputation: 108567

You don't release it.

When [object] goes out of scope an unref() will happen in the background and you don't need to worry about it anymore. There's no new so there's no delete.

Upvotes: 0

Related Questions