-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Sajjadul,

On 13/10/2013 1:12, Sajjadul Islam wrote:
> Thanks for the suggestion of the singleton design . I tried to design a 
> template base
> class as follows :
> 
> Code: ... template<class T> class Singleton { public: /** * Init the actual
> singleton. * Must be called BEFORE the class is used, like this: */ static 
> void
> init() { assert( singletonClass_.get() == NULL); singletonClass_ = new T; }
> 
> 
> /** * Get Pointer of the actual class * @return Pointer of the actual class 
> */ static
> T* getPtr() { assert( singletonClass_.get() != NULL); return
> singletonClass_.release(); } ... But it crashes at the assertion. I tried 
> without
> assertion , then debugger simply exits at the point where i call: ... 
> osgOpenCL::Context *cxt = osgOpenCL::Singleton<osgOpenCL::Context>::getPtr();

Did you call 'init' on the singleton class before this?

Also, the 'getPtr' is buggy, since it calls 'release' on the singleton object.  
This
will work the first time round, but delete the object afterwards and will crash 
on
subsequent calls.

Cheers,
/ulrich

- -- 
Fingerprint 0227 8EE1 2C64 8EF4 DA11 9864 FF16 0114 B9DA 3318
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (Darwin)

iQEcBAEBAgAGBQJSYQ9qAAoJEP8WARS52jMYWY8H+wR8F/mt7t6DWYbBr7TVwTmA
/w1UO9B+VtV2ZOlX/E/Z3U6ooKZu4K/jKYU0gihqOCUVNVmops3BILr9AGRStgu6
e6Z/rSxYB7zQRjJl3D25gfg9Y+s+/oe2668Yyq8XQmZ6FABbSVTHnNEXRnwQO+XB
n2po44cQ/i+O5pIbACWr3PgDvejcIxf/AvJoIArz+R5j3jZUC/4ig6k6o6tFn8Uo
esV+DXZg80nGTx8fus+piqSEENUNmzm/2/POBFNxKuXLjX9s11lsHv0K4FtOi+ap
8Z4fshX9Mw79LElGH1hf3qbj61/weyOw9lZarRh1BFaWYTsmoNVcwYQH78PfNXY=
=2pYO
-----END PGP SIGNATURE-----
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to