diff -r e359d82f0652 -r 9ee82e091af7 src/squirrel_helper.hpp --- a/src/squirrel_helper.hpp Thu Jul 12 14:55:28 2007 +0000 +++ b/src/squirrel_helper.hpp Thu Jul 12 15:04:26 2007 +0000 @@ -446,6 +446,7 @@ sq_getinstanceup(vm, 1, &real_instance, 0); /* Get the real function pointer */ sq_getuserdata(vm, nparam, &ptr, 0); + if (real_instance == NULL) return sq_throwerror(vm, _SC("couldn't detect real instance of class for non-static call")); /* Delegate it to a template that can handle this specific function */ return HelperT::SQCall((Tcls *)real_instance, *(Tmethod *)ptr, vm); @@ -487,13 +488,13 @@ * params. It creates the instance in C++, and it sets all the needed * settings in SQ to register the instance. */ - template + template inline SQInteger DefSQConstructorCallback(HSQUIRRELVM vm) { /* Create the real instance */ Tcls *instance = HelperT::SQConstruct((Tcls *)NULL, (Tmethod)NULL, vm); - sq_setinstanceup(vm, -1, instance); - sq_setreleasehook(vm, -1, DefSQDestructorCallback); + sq_setinstanceup(vm, -Tnparam, instance); + sq_setreleasehook(vm, -Tnparam, DefSQDestructorCallback); return 0; }