[Kde-bindings] kdebindings/qtruby [POSSIBLY UNSAFE]
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Thu Oct 14 16:22:14 UTC 2004
CVS commit by rdale:
* If the smokeruby_mark() function was called for an instance of a QObject, it should
mark all the instances below it in the QObject tree, as not needing garbage collection.
However, if a node in the tree didn't have a mapping onto a ruby instance the marking
process stopped there, even though the grandchildren and their descendants might
have a valid mapping onto ruby instances.
* The solution is to always traverse the entire tree. Fixes problem reported by Han Holl.
CCMAIL: kde-bindings at kde.org
M +11 -0 ChangeLog 1.132
M +25 -19 rubylib/qtruby/handlers.cpp 1.75 [POSSIBLY UNSAFE: printf]
--- kdebindings/qtruby/rubylib/qtruby/handlers.cpp #1.74:1.75
@@ -70,4 +70,28 @@ set_kde_resolve_classname(const char * (
void
+mark_qobject_children(QObject * qobject)
+{
+ VALUE obj;
+
+ const QObjectList *l = qobject->children();
+ if (l == 0) {
+ return;
+ }
+ QObjectListIt it( *l ); // iterate over the children
+ QObject *child;
+
+ while ( (child = it.current()) != 0 ) {
+ ++it;
+ obj = getPointerObject(child);
+ if (obj != Qnil) {
+ if(do_debug & qtdb_gc) printf("Marking (%s*)%p -> %p\n", child->className(), child, (void*)obj);
+ rb_gc_mark(obj);
+ }
+
+ mark_qobject_children(child);
+ }
+}
+
+void
smokeruby_mark(void * p)
{
@@ -127,23 +151,5 @@ smokeruby_mark(void * p)
if (isDerivedFromByName(o->smoke, className, "QObject")) {
QObject * qobject = (QObject *) o->smoke->cast(o->ptr, o->classId, o->smoke->idClass("QObject"));
- const QObjectList *l = qobject->children();
- if (l == 0) {
- return;
- }
- QObjectListIt it( *l ); // iterate over the children
- QObject *child;
-
- while ( (child = it.current()) != 0 ) {
- ++it;
- obj = getPointerObject(child);
- if (obj != Qnil) {
- if(do_debug & qtdb_gc) printf("Marking (%s*)%p -> %p\n", child->className(), child, (void*)obj);
- rb_gc_mark(obj);
- if (child->children()) {
- smokeruby_object * c = value_obj_info(obj);
- smokeruby_mark(c);
- }
- }
- }
+ mark_qobject_children(qobject);
return;
}
--- kdebindings/qtruby/ChangeLog #1.131:1.132
@@ -1,2 +1,13 @@
+2004-10-14 Richard Dale <Richard_Dale at tipitina.demon.co.uk>
+
+ * If the smokeruby_mark() function was called for an instance of a QObject, it should
+ mark all the instances below it in the QObject tree, as not needing garbage collection.
+ However, if a node in the tree didn't have a mapping onto a ruby instance the marking
+ process stopped there, even though the grandchildren and their descendants might
+ have a valid mapping onto ruby instances.
+ * The solution is to always traverse the entire tree. Fixes problem reported by Han Holl.
+
+ CCMAIL: kde-bindings at kde.org
+
2004-10-13 Richard Dale <Richard_Dale at tipitina.demon.co.uk>
More information about the Kde-bindings
mailing list