Clone hook patch
[email protected] (Elizabeth M Smith)
| Newsgroups | php.gtk.dev |
|---|---|
| Message-ID | <[email protected]> |
This patch will throw a fatal error when someone decides to clone any gobject based gtk item I know andrei talked about throwing an e_warning - but if it causes a segfault I really think an e_error is more in order If I don't get any "this is broken" or other comments I'll commit this Thanks, Elizabeth Smith
phpg_gobject.c.patch
(text/plain, 1.3 KB)
Index: phpg_gobject.c
===================================================================
RCS file: /repository/php-gtk/main/phpg_gobject.c,v
retrieving revision 1.68
diff -u -r1.68 phpg_gobject.c
--- phpg_gobject.c 29 Feb 2008 19:05:53 -0000 1.68
+++ phpg_gobject.c 10 Mar 2008 14:46:45 -0000
@@ -105,6 +105,15 @@
}
/* }}} */
+/* {{{ static phpg_clone_gobject */
+static void phpg_clone_gobject(void *object, void **object_clone TSRMLS_DC)
+{
+ /* Throw fatal error on attempted clone for all gobject based classes - this puts the engine in an unstable state */
+ php_error(E_ERROR, "Gobject %s cannot be cloned", get_active_class_name(NULL TSRMLS_CC));
+ return;
+}
+/* }}} */
+
/* {{{ static phpg_unref_by_handle */
static void phpg_unref_by_handle(void *data)
{
@@ -152,7 +161,7 @@
object->is_owned = FALSE;
zov.handlers = &phpg_gobject_handlers;
- zov.handle = zend_objects_store_put(object, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) phpg_free_gobject_storage, NULL TSRMLS_CC);
+ zov.handle = zend_objects_store_put(object, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) phpg_free_gobject_storage, phpg_clone_gobject TSRMLS_CC);
return zov;
}