[Kde-bindings] KDE/kdebindings/php/phpqt/src [BROKEN EMAIL]
Thomas Moenicke
tm at php-qt.org
Sat Jul 19 19:09:38 UTC 2008
SVN commit 834966 by moenicke:
* free() the php variable that still hangs around, when shutting down the smokephp_object mapping
CCMAIL: kde-bindings at kde.org
M +34 -24 php_qt.cpp
--- trunk/KDE/kdebindings/php/phpqt/src/php_qt.cpp #834965:834966
@@ -165,6 +165,11 @@
RETURN_STRING("", 1);
}
+/*
+ * zend engine creates a dummy zval with the correct object handle, we'll take that one
+ * when destroying the smokephp_object, we take also care for the corresponding zval* and delete it
+ */
+
ZEND_METHOD(php_qt_generic_class, __destruct)
{
Q_UNUSED(return_value_ptr);
@@ -172,27 +177,32 @@
Q_UNUSED(ht);
Q_UNUSED(return_value);
- pDebug( PHPQt::Destruct ) << "__destruct" << getThis();
- if( getThis()->type == IS_OBJECT ) {
- if( PHPQt::SmokePHPObjectExists( getThis() ) ) {
- smokephp_object *o = PHPQt::getSmokePHPObjectFromZval(getThis());
- pDebug( PHPQt::Destruct ) << "removing" << getThis()->value.obj.handle << o->className();
- //! its not a reference
- if(!PHPQt::unmapSmokePHPObject(getThis()))
- {
- pError() << "tried to unmap unregistered zval";
- }
-/* if( o->allocated() )
- {
- Smoke::Index nameId = o->smoke()->idMethodName("delete");
- Smoke::Index method = o->smoke()->findMethod( o->classId(), nameId );
- Smoke::Method &m = o->smoke()->methods[ o->smoke()->methodMaps[method].method ];
- const Smoke::ClassFn fn = o->smoke()->classes[ m.classId ].classFn;
- Smoke::StackItem stack[1];
- (*fn)( m.method, o->mPtr(), stack );
- }*/
- delete o;
- }
+ pDebug( PHPQt::Destruct ) << "__destruct handle" << getThis()->value.obj.handle;
+ if( getThis()->type == IS_OBJECT )
+ {
+ if( PHPQt::SmokePHPObjectExists( getThis() ) )
+ {
+ smokephp_object *o = PHPQt::getSmokePHPObjectFromZval( getThis() );
+ pDebug( PHPQt::Destruct ) << "removing" << getThis()->value.obj.handle << o->className();
+ //! its not a reference
+ if(!PHPQt::unmapSmokePHPObject(getThis()))
+ pError() << "tried to unmap unregistered php object";
+
+ /* if( o->allocated() )
+ {
+ Smoke::Index nameId = o->smoke()->idMethodName("delete");
+ Smoke::Index method = o->smoke()->findMethod( o->classId(), nameId );
+ Smoke::Method &m = o->smoke()->methods[ o->smoke()->methodMaps[method].method ];
+ const Smoke::ClassFn fn = o->smoke()->classes[ m.classId ].classFn;
+ Smoke::StackItem stack[1];
+ (*fn)( m.method, o->mPtr(), stack );
+ }*/
+ if(!PHPQt::unmapSmokePHPObject(o))
+ pError() << "tried to unmap unregistered smoke object";
+
+ efree( (void*) o->zval_ptr() );
+ delete o;
+ }
} // is object
}
@@ -217,9 +227,9 @@
// get arguments
const int argc = ZEND_NUM_ARGS();
- zval ***args = (zval ***) safe_emalloc(argc, sizeof(zval), 0);
+ zval ***args = (zval ***) safe_emalloc(argc, sizeof(zval**), 0);
if(zend_get_parameters_array_ex(argc, args) == FAILURE) {
- efree(args); WRONG_PARAM_COUNT;
+ efree(args); WRONG_PARAM_COUNT;
}
Context::setMethodName( ce->name );
@@ -238,7 +248,7 @@
// Metaobject
// TODO only if derived
if( smokephp_isQObject( PQ::smoke()->idClass(ce->name).index ) )
- PHPQt::createMetaObject(o, getThis());
+ PHPQt::createMetaObject(o, getThis());
// cleanup
efree(args);
More information about the Kde-bindings
mailing list