Hard to get a RefPtr<> to this.
Submitted by gonen
Link to original bug (#547306)
Description
Hi,
I'm writing a button actor, that inherits from clutter::actor, and I want to use an effectTemplate when the button is pressed.
I wrote the following code in my function button_actor::real_released()
m_press_effect->fade(this, 0x44,sigc::bind(sigc::ptr_fun(do_nothing), m_press_effect));
m_press_effect is of type Clutter::EffectTemplate, and the problem is that fade's first parameter is not actor pointer, but a actor smart pointer Glib::RefPtrClutter::Actor).
I cannot wrap this with smart pointer like :
m_press_effect->fade(Glib::RefPtrClutter::Actor(this), 0x44,sigc::bind(sigc::ptr_fun(do_nothing), m_press_effect));
because at the end of the function, the reference count will go to 0, and it will do 'delete this' which is very bad.
Is there any other way to write this? I wonder how GTKmm and other mm projects solve similar problems like this.
Another small problem, is that some functions in clutter can get NULL, but in case you use reference, you cannot pass NULL.
Version: 2.17.x