[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebindings/qtruby
From:       Richard Dale <Richard_Dale () tipitina ! demon ! co ! uk>
Date:       2006-08-18 9:27:13
Message-ID: 1155893233.610118.23754.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 574152 by rdale:

* Some more leak fixing and minimising use of the heap



 M  +4 -0      ChangeLog  
 M  +14 -13    rubylib/qtruby/Qt.cpp  


--- trunk/KDE/kdebindings/qtruby/ChangeLog #574151:574152
@@ -1,3 +1,7 @@
+2006-08-18  Richard Dale  <rdale@foton.es>
+
+	* Some more leak fixing and minimising use of the heap
+
 2006-08-17  Richard Dale  <rdale@foton.es>
 
 	* Used the excellent MallocDebug tool on Mac OS X to track down and fix
--- trunk/KDE/kdebindings/qtruby/rubylib/qtruby/Qt.cpp #574151:574152
@@ -1462,11 +1462,15 @@
     VALUE klass = rb_funcall(self, rb_intern("class"), 0);
 
 	// Look for 'thing?' methods, and try to match isThing() or hasThing() in the Smoke \
                runtime
-	QByteArray * pred = new QByteArray(rb_id2name(SYM2ID(argv[0])));
+static QByteArray * pred = 0;
+	if (pred == 0) {
+		pred = new QByteArray();
+	}
+	
+	*pred = methodName;
 	if (pred->endsWith("?")) {
 		smokeruby_object *o = value_obj_info(self);
 		if(!o || !o->ptr) {
-			delete pred;
 			return rb_call_super(argc, argv);
 		}
 		
@@ -1530,7 +1534,12 @@
 							&& isDerivedFrom(o->smoke, o->classId, o->smoke->idClass("QObject")) )
 					{
 						QObject * qobject = (QObject *) o->smoke->cast(o->ptr, o->classId, \
                o->smoke->idClass("QObject"));
-						QByteArray * prop = new QByteArray(rb_id2name(SYM2ID(argv[0])));
+static QByteArray * prop = 0;
+						if (prop == 0) {
+							prop = new QByteArray();
+						}
+						
+						*prop = rb_id2name(SYM2ID(argv[0]));
 						const QMetaObject * meta = qobject->metaObject();
 						if (argc == 1) {
 							if (prop->endsWith("?")) {
@@ -1543,24 +1552,17 @@
 
 							if (meta->indexOfProperty(*prop) != -1) {
 								VALUE qvariant = rb_funcall(self, rb_intern("property"), 1, \
                rb_str_new2(*prop));
-								delete pred;
-								delete prop;
 								return rb_funcall(qvariant, rb_intern("to_ruby"), 0);
 							}
 						} else if (argc == 2 && prop->endsWith("=")) {
 							prop->replace("=", "");
 							if (meta->indexOfProperty(*prop) != -1) {
 								VALUE qvariant = rb_funcall(self, rb_intern("qVariantFromValue"), 1, \
                argv[1]);
-								delete pred;
-								VALUE str = rb_str_new2(*prop);
-								delete prop;
-								return rb_funcall(self, rb_intern("setProperty"), 2, str, qvariant);
+								return rb_funcall(self, rb_intern("setProperty"), 2, rb_str_new2(*prop), \
qvariant);  }
 						}
-						delete prop;
 					}
 					
-					delete pred;
 					return rb_call_super(argc, argv);
 				}
 			}
@@ -1573,7 +1575,6 @@
     c.next();
     VALUE result = *(c.var());
 	free(temp_stack);
-	delete pred;
     return result;
 }
 
@@ -2660,7 +2661,7 @@
 static QRegExp * scope_op = 0;
 	if (scope_op == 0) {
 		scope_op = new QRegExp("^([^:]+)::([^:]+)$");
-	 }
+	}
 
 	if (packageName.startsWith("KDE::ConfigSkeleton::ItemEnum::")) {
 		klass = rb_define_class_under(kconfigskeleton_itemenum_class, \
package+strlen("KDE::ConfigSkeleton::EnumItem::"), base_class);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic