X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbindable.h;h=20b6482a9ec92009e555e9cdbe34519e49699787;hb=946266e823c07025f115b5e4f5523b496dcb393e;hp=8a5821b957cf4dd1569e3e840d6ad2ee8207e5ed;hpb=2c9a7979a41def3ee4c7fea7163718af25a26e61;p=libs%2Fgl.git diff --git a/source/bindable.h b/source/bindable.h index 8a5821b9..20b6482a 100644 --- a/source/bindable.h +++ b/source/bindable.h @@ -15,6 +15,7 @@ protected: static const T *cur_obj; Bindable() { } + ~Bindable() { if(cur_obj==this) T::unbind(); } static bool set_current(const T *obj) { @@ -39,8 +40,11 @@ A helper class for Bindables that revert to a default object on unbind. template class BindableWithDefault: protected Bindable { + friend class Bindable; + protected: BindableWithDefault() { } + ~BindableWithDefault() { if(this==&default_object()) Bindable::set_current(0); } public: static const T *current()