/[gentoo-x86]/kde-base/qtruby/files/qtruby-3.5.4-more.patch
Gentoo

Contents of /kde-base/qtruby/files/qtruby-3.5.4-more.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download) (as text)
Mon Feb 5 12:26:36 2007 UTC (13 years, 7 months ago) by flameeyes
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/x-diff
FILE REMOVED
Remove unneeded patches.
(Portage version: 2.1.2-r7)

1 Index: ChangeLog
2 ===================================================================
3 --- qtruby/ChangeLog (revision 565692)
4 +++ qtruby/ChangeLog (revision 578513)
5 @@ -1,3 +1,13 @@
6 +2006-08-29 Richard Dale <rdale@foton.es>
7 +
8 + * Backported some memory leak fixes from Qt4 QtRuby
9 +
10 +2006-08-10 Richard Dale <rdale@foton.es>
11 +
12 + * The Ruby VALUE to 'uchar *' marshaller wasn't working correctly if the
13 + Ruby string contained nulls. Fixed by Dirk Mueller (thanks) and also
14 + applied for 'char *' types.
15 +
16 2006-07-12 Richard Dale <rdale@foton.es>
17
18 * The Ruby String to 'char *' and String to 'unsigned char *' were using
19 Index: rubylib/qtruby/handlers.cpp
20 ===================================================================
21 --- qtruby/rubylib/qtruby/handlers.cpp (revision 565692)
22 +++ qtruby/rubylib/qtruby/handlers.cpp (revision 578513)
23 @@ -422,6 +422,7 @@
24 Smoke::Index ccMeth = o->smoke->findMethod(o->classId, ccId);
25
26 if(!ccMeth) {
27 + delete[] ccArg;
28 return 0;
29 }
30 Smoke::Index method = o->smoke->methodMaps[ccMeth].method;
31 @@ -747,17 +748,21 @@
32
33 static void marshall_charP(Marshall *m) {
34 switch(m->action()) {
35 - case Marshall::FromVALUE:
36 - {
37 - VALUE rv = *(m->var());
38 - if(rv == Qnil) {
39 - m->item().s_voidp = 0;
40 - break;
41 - }
42 -
43 - m->item().s_voidp = strdup(StringValuePtr(rv));
44 - }
45 - break;
46 + case Marshall::FromVALUE:
47 + {
48 + VALUE rv = *(m->var());
49 + if (rv == Qnil) {
50 + m->item().s_voidp = 0;
51 + break;
52 + }
53 +
54 + int len = RSTRING(rv)->len;
55 + char* mem = (char*) malloc(len+1);
56 + memcpy(mem, StringValuePtr(rv), len);
57 + mem[len] ='\0';
58 + m->item().s_voidp = mem;
59 + }
60 + break;
61 case Marshall::ToVALUE:
62 {
63 char *p = (char*)m->item().s_voidp;
64 @@ -777,14 +782,18 @@
65
66 void marshall_ucharP(Marshall *m) {
67 switch(m->action()) {
68 - case Marshall::FromVALUE:
69 - {
70 - VALUE rv = *(m->var());
71 - if(rv == Qnil) {
72 - m->item().s_voidp = 0;
73 - break;
74 - }
75 - m->item().s_voidp = strdup(StringValuePtr(rv));
76 + case Marshall::FromVALUE:
77 + {
78 + VALUE rv = *(m->var());
79 + if (rv == Qnil) {
80 + m->item().s_voidp = 0;
81 + break;
82 + }
83 + int len = RSTRING(rv)->len;
84 + char* mem = (char*) malloc(len+1);
85 + memcpy(mem, StringValuePtr(rv), len);
86 + mem[len] ='\0';
87 + m->item().s_voidp = mem;
88 }
89 break;
90 case Marshall::ToVALUE:
91 @@ -1836,8 +1845,8 @@
92 }
93 }
94
95 -#define DEF_VALUELIST_MARSHALLER(ListIdent,ItemList,Item,Itr) namespace { char ListIdent##STR[] = #Item; }; \
96 - Marshall::HandlerFn marshall_##ListIdent = marshall_ValueItemList<Item,ItemList,Itr,ListIdent##STR>;
97 +#define DEF_VALUELIST_MARSHALLER(ListIdent,ItemList,Item,Itr) namespace dummy { char ListIdent##STR[] = #Item; }; \
98 + Marshall::HandlerFn marshall_##ListIdent = marshall_ValueItemList<Item,ItemList,Itr,dummy::ListIdent##STR>;
99
100 DEF_VALUELIST_MARSHALLER( QVariantList, QValueList<QVariant>, QVariant, QValueList<QVariant>::Iterator )
101 DEF_VALUELIST_MARSHALLER( QPixmapList, QValueList<QPixmap>, QPixmap, QValueList<QPixmap>::Iterator )
102 Index: rubylib/qtruby/Qt.cpp
103 ===================================================================
104 --- qtruby/rubylib/qtruby/Qt.cpp (revision 565692)
105 +++ qtruby/rubylib/qtruby/Qt.cpp (revision 578513)
106 @@ -1351,28 +1351,32 @@
107 return obj;
108 }
109
110 -static QCString
111 +static QCString *
112 find_cached_selector(int argc, VALUE * argv, VALUE klass, char * methodName)
113 {
114 // Look in the cache
115 - QCString mcid(rb_class2name(klass));
116 - mcid += ';';
117 - mcid += methodName;
118 +static QCString * mcid = 0;
119 + if (mcid == 0) {
120 + mcid = new QCString();
121 + }
122 + *mcid = rb_class2name(klass);
123 + *mcid += ';';
124 + *mcid += methodName;
125 for(int i=3; i<argc ; i++)
126 {
127 - mcid += ';';
128 - mcid += get_VALUEtype(argv[i]);
129 + *mcid += ';';
130 + *mcid += get_VALUEtype(argv[i]);
131 }
132
133 - Smoke::Index *rcid = methcache.find((const char *)mcid);
134 + Smoke::Index *rcid = methcache.find((const char *)*mcid);
135 #ifdef DEBUG
136 - if (do_debug & qtdb_calls) qWarning("method_missing mcid: %s", (const char *) mcid);
137 + if (do_debug & qtdb_calls) qWarning("method_missing mcid: %s", (const char *) *mcid);
138 #endif
139
140 if (rcid) {
141 // Got a hit
142 #ifdef DEBUG
143 - if (do_debug & qtdb_calls) qWarning("method_missing cache hit, mcid: %s", (const char *) mcid);
144 + if (do_debug & qtdb_calls) qWarning("method_missing cache hit, mcid: %s", (const char *) *mcid);
145 #endif
146 _current_method = *rcid;
147 } else {
148 @@ -1389,27 +1393,32 @@
149 VALUE klass = rb_funcall(self, rb_intern("class"), 0);
150
151 // Look for 'thing?' methods, and try to match isThing() or hasThing() in the Smoke runtime
152 - QString pred(rb_id2name(SYM2ID(argv[0])));
153 - if (pred.endsWith("?")) {
154 +static QString * pred = 0;
155 + if (pred == 0) {
156 + pred = new QString();
157 + }
158 +
159 + *pred = methodName;
160 + if (pred->endsWith("?")) {
161 smokeruby_object *o = value_obj_info(self);
162 if(!o || !o->ptr) {
163 rb_call_super(argc, argv);
164 }
165
166 // Drop the trailing '?'
167 - pred.replace(pred.length() - 1, 1, "");
168 + pred->replace(pred->length() - 1, 1, "");
169
170 - pred.replace(0, 1, pred.at(0).upper());
171 - pred.replace(0, 0, QString("is"));
172 - Smoke::Index meth = o->smoke->findMethod(o->smoke->classes[o->classId].className, pred.latin1());
173 + pred->replace(0, 1, pred->at(0).upper());
174 + pred->replace(0, 0, QString("is"));
175 + Smoke::Index meth = o->smoke->findMethod(o->smoke->classes[o->classId].className, pred->latin1());
176
177 if (meth == 0) {
178 - pred.replace(0, 2, QString("has"));
179 - meth = o->smoke->findMethod(o->smoke->classes[o->classId].className, pred.latin1());
180 + pred->replace(0, 2, QString("has"));
181 + meth = o->smoke->findMethod(o->smoke->classes[o->classId].className, pred->latin1());
182 }
183
184 if (meth > 0) {
185 - methodName = (char *) pred.latin1();
186 + methodName = (char *) pred->latin1();
187 }
188 }
189
190 @@ -1423,18 +1432,26 @@
191 }
192
193 {
194 - QCString mcid = find_cached_selector(argc+3, temp_stack, klass, methodName);
195 + QCString * mcid = find_cached_selector(argc+3, temp_stack, klass, methodName);
196
197 if (_current_method == -1) {
198 // Find the C++ method to call. Do that from Ruby for now
199
200 VALUE retval = rb_funcall2(qt_internal_module, rb_intern("do_method_missing"), argc+3, temp_stack);
201 if (_current_method == -1) {
202 - QRegExp rx("^[-+%/|]$");
203 - QString op(rb_id2name(SYM2ID(argv[0])));
204 - if (rx.search(op) != -1) {
205 + char * op = rb_id2name(SYM2ID(argv[0]));
206 + if ( qstrcmp(op, "-") == 0
207 + || qstrcmp(op, "+") == 0
208 + || qstrcmp(op, "/") == 0
209 + || qstrcmp(op, "%") == 0
210 + || qstrcmp(op, "|") == 0 )
211 + {
212 // Look for operator methods of the form 'operator+=', 'operator-=' and so on..
213 - temp_stack[1] = rb_str_new2(op.append("=").latin1());
214 + char op1[3];
215 + op1[0] = op[0];
216 + op1[1] = '=';
217 + op1[2] = '\0';
218 + temp_stack[1] = rb_str_new2(op1);
219 retval = rb_funcall2(qt_internal_module, rb_intern("do_method_missing"), argc+3, temp_stack);
220 }
221
222 @@ -1448,26 +1465,31 @@
223 && isDerivedFrom(o->smoke, o->classId, o->smoke->idClass("QObject")) )
224 {
225 QObject * qobject = (QObject *) o->smoke->cast(o->ptr, o->classId, o->smoke->idClass("QObject"));
226 - QString prop(rb_id2name(SYM2ID(argv[0])));
227 +static QString * prop = 0;
228 + if (prop == 0) {
229 + prop = new QString();
230 + }
231 +
232 + *prop = rb_id2name(SYM2ID(argv[0]));
233 QMetaObject * meta = qobject->metaObject();
234 if (argc == 1) {
235 - if (prop.endsWith("?")) {
236 - prop.replace(0, 1, pred.at(0).upper());
237 - prop.replace(0, 0, QString("is"));
238 - if (meta->findProperty(prop.latin1(), true) == -1) {
239 - prop.replace(0, 2, QString("has"));
240 + if (prop->endsWith("?")) {
241 + prop->replace(0, 1, pred->at(0).upper());
242 + prop->replace(0, 0, QString("is"));
243 + if (meta->findProperty(prop->latin1(), true) == -1) {
244 + prop->replace(0, 2, QString("has"));
245 }
246 }
247
248 - if (meta->findProperty(prop.latin1(), true) != -1) {
249 - VALUE qvariant = rb_funcall(self, rb_intern("property"), 1, rb_str_new2(prop.latin1()));
250 + if (meta->findProperty(prop->latin1(), true) != -1) {
251 + VALUE qvariant = rb_funcall(self, rb_intern("property"), 1, rb_str_new2(prop->latin1()));
252 return rb_funcall(qvariant, rb_intern("to_ruby"), 0);
253 }
254 - } else if (argc == 2 && prop.endsWith("=")) {
255 - prop.replace("=", "");
256 - if (meta->findProperty(prop.latin1(), true) != -1) {
257 + } else if (argc == 2 && prop->endsWith("=")) {
258 + prop->replace("=", "");
259 + if (meta->findProperty(prop->latin1(), true) != -1) {
260 VALUE qvariant = rb_funcall(qvariant_class, rb_intern("new"), 1, argv[1]);
261 - return rb_funcall(self, rb_intern("setProperty"), 2, rb_str_new2(prop.latin1()), qvariant);
262 + return rb_funcall(self, rb_intern("setProperty"), 2, rb_str_new2(prop->latin1()), qvariant);
263 }
264 }
265 }
266 @@ -1476,7 +1498,7 @@
267 }
268 }
269 // Success. Cache result.
270 - methcache.insert((const char *)mcid, new Smoke::Index(_current_method));
271 + methcache.insert((const char *)*mcid, new Smoke::Index(_current_method));
272 }
273 }
274
275 @@ -1503,21 +1525,25 @@
276 }
277
278 {
279 - QCString mcid = find_cached_selector(argc+3, temp_stack, klass, methodName);
280 + QCString * mcid = find_cached_selector(argc+3, temp_stack, klass, methodName);
281
282 if (_current_method == -1) {
283 VALUE retval = rb_funcall2(qt_internal_module, rb_intern("do_method_missing"), argc+3, temp_stack);
284 Q_UNUSED(retval);
285 if (_current_method != -1) {
286 // Success. Cache result.
287 - methcache.insert((const char *)mcid, new Smoke::Index(_current_method));
288 + methcache.insert((const char *)*mcid, new Smoke::Index(_current_method));
289 }
290 }
291 }
292
293 if (_current_method == -1) {
294 - QRegExp rx("[a-zA-Z]+");
295 - if (rx.search(methodName) == -1) {
296 +static QRegExp * rx = 0;
297 + if (rx == 0) {
298 + rx = new QRegExp("[a-zA-Z]+");
299 + }
300 +
301 + if (rx->search(methodName) == -1) {
302 // If an operator method hasn't been found as an instance method,
303 // then look for a class method - after 'op(self,a)' try 'self.op(a)'
304 VALUE * method_stack = (VALUE *) calloc(argc - 1, sizeof(VALUE));
305 @@ -1584,10 +1610,10 @@
306 if (TYPE(self) == T_DATA) {
307 // If a ruby block was passed then run that now
308 if (rb_block_given_p()) {
309 - rb_funcall(qt_internal_module, rb_intern("run_initializer_block"), 2, self, rb_block_proc());
310 + rb_funcall(qt_internal_module, rb_intern("run_initializer_block"), 2, self, rb_block_proc());
311 }
312
313 - return self;
314 + return self;
315 }
316
317 VALUE klass = rb_funcall(self, rb_intern("class"), 0);
318 @@ -1599,19 +1625,19 @@
319 temp_stack[2] = klass;
320 temp_stack[3] = self;
321 for (int count = 0; count < argc; count++) {
322 - temp_stack[count+4] = argv[count];
323 + temp_stack[count+4] = argv[count];
324 }
325
326 {
327 // Put this in a C block so that the mcid will be de-allocated at the end of the block,
328 // rather than on f'n exit, to avoid the longjmp problem described below
329 - QCString mcid = find_cached_selector(argc+4, temp_stack, klass, rb_class2name(klass));
330 + QCString * mcid = find_cached_selector(argc+4, temp_stack, klass, rb_class2name(klass));
331
332 if (_current_method == -1) {
333 retval = rb_funcall2(qt_internal_module, rb_intern("do_method_missing"), argc+4, temp_stack);
334 if (_current_method != -1) {
335 // Success. Cache result.
336 - methcache.insert((const char *)mcid, new Smoke::Index(_current_method));
337 + methcache.insert((const char *)*mcid, new Smoke::Index(_current_method));
338 }
339 }
340 }
341 @@ -1652,7 +1678,7 @@
342 VALUE * temp_stack = (VALUE *) calloc(argc + 1, sizeof(VALUE));
343 temp_stack[0] = rb_obj_alloc(klass);
344 for (int count = 0; count < argc; count++) {
345 - temp_stack[count+1] = argv[count];
346 + temp_stack[count+1] = argv[count];
347 }
348
349 VALUE result = rb_funcall2(qt_internal_module, rb_intern("try_initialize"), argc+1, temp_stack);
350 @@ -1668,16 +1694,16 @@
351 VALUE result = Qnil;
352
353 if (argc == 1 && TYPE(argv[0]) == T_ARRAY) {
354 - // Convert '(ARGV)' to '(NUM, [$0]+ARGV)'
355 - VALUE * local_argv = (VALUE *) calloc(argc + 1, sizeof(VALUE));
356 - VALUE temp = rb_ary_dup(argv[0]);
357 - rb_ary_unshift(temp, rb_gv_get("$0"));
358 - local_argv[0] = INT2NUM(RARRAY(temp)->len);
359 - local_argv[1] = temp;
360 - result = new_qt(2, local_argv, klass);
361 - free(local_argv);
362 + // Convert '(ARGV)' to '(NUM, [$0]+ARGV)'
363 + VALUE * local_argv = (VALUE *) calloc(argc + 1, sizeof(VALUE));
364 + VALUE temp = rb_ary_dup(argv[0]);
365 + rb_ary_unshift(temp, rb_gv_get("$0"));
366 + local_argv[0] = INT2NUM(RARRAY(temp)->len);
367 + local_argv[1] = temp;
368 + result = new_qt(2, local_argv, klass);
369 + free(local_argv);
370 } else {
371 - result = new_qt(argc, argv, klass);
372 + result = new_qt(argc, argv, klass);
373 }
374
375 rb_gv_set("$qApp", result);
376 @@ -1735,9 +1761,9 @@
377 if(index < 0) return Qnil;
378
379 if (isSignal) {
380 - member = rb_funcall(qt_internal_module, rb_intern("signalAt"), 2, self, INT2NUM(index));
381 + member = rb_funcall(qt_internal_module, rb_intern("signalAt"), 2, self, INT2NUM(index));
382 } else {
383 - member = rb_funcall(qt_internal_module, rb_intern("slotAt"), 2, self, INT2NUM(index));
384 + member = rb_funcall(qt_internal_module, rb_intern("slotAt"), 2, self, INT2NUM(index));
385 }
386
387 VALUE mocArgs = rb_funcall(qt_internal_module, rb_intern("getMocArguments"), 1, member);
388 @@ -1815,7 +1841,12 @@
389 }
390
391 QString name(slotname);
392 - name.replace(QRegExp("\\(.*"), "");
393 +static QRegExp * rx = 0;
394 + if (rx == 0) {
395 + rx = new QRegExp("\\(.*");
396 + }
397 + name.replace(*rx, "");
398 +
399 InvokeSlot slot(self, rb_intern(name.latin1()), mocArgs, _o);
400 slot.next();
401
402 @@ -2568,7 +2599,10 @@
403 {
404 VALUE klass = Qnil;
405 QString packageName(package);
406 - QRegExp scope_op("^([^:]+)::([^:]+)$");
407 +static QRegExp * scope_op = 0;
408 + if (scope_op == 0) {
409 + scope_op = new QRegExp("^([^:]+)::([^:]+)$");
410 + }
411
412 if (packageName.startsWith("KDE::ConfigSkeleton::ItemEnum::")) {
413 klass = rb_define_class_under(kconfigskeleton_itemenum_class, package+strlen("KDE::ConfigSkeleton::EnumItem::"), base_class);
414 @@ -2606,7 +2640,7 @@
415 } else if (packageName.startsWith("Kontact::")) {
416 klass = rb_define_class_under(kontact_module, package+strlen("Kontact::"), base_class);
417 rb_define_singleton_method(klass, "new", (VALUE (*) (...)) _new_kde, -1);
418 - } else if (packageName.startsWith("Ko") && scope_op.search(packageName) == -1) {
419 + } else if (packageName.startsWith("Ko") && scope_op->search(packageName) == -1) {
420 klass = rb_define_class_under(koffice_module, package+strlen("Ko"), base_class);
421 rb_define_singleton_method(klass, "new", (VALUE (*) (...)) _new_kde, -1);
422 } else if (packageName.startsWith("Kate::")) {
423 @@ -2618,11 +2652,11 @@
424 } else if (packageName.startsWith("KTextEditor::")) {
425 klass = rb_define_class_under(ktexteditor_module, package+strlen("KTextEditor::"), base_class);
426 rb_define_singleton_method(klass, "new", (VALUE (*) (...)) _new_kde, -1);
427 - } else if (scope_op.search(packageName) != -1) {
428 + } else if (scope_op->search(packageName) != -1) {
429 // If an unrecognised classname of the form 'XXXXXX::YYYYYY' is found,
430 // then create a module XXXXXX to put the class YYYYYY under
431 - VALUE module = rb_define_module(scope_op.cap(1).latin1());
432 - klass = rb_define_class_under(module, scope_op.cap(2).latin1(), base_class);
433 + VALUE module = rb_define_module(scope_op->cap(1).latin1());
434 + klass = rb_define_class_under(module, scope_op->cap(2).latin1(), base_class);
435 } else if ( packageName.startsWith("K")
436 && packageName.mid(1, 1).contains(QRegExp("[A-Z]")) == 1 )
437 {
438 @@ -2792,6 +2826,7 @@
439
440 methcache.setAutoDelete(true);
441 classcache.setAutoDelete(true);
442 + classname.setAutoDelete(true);
443
444 if (qt_module == Qnil) {
445 qt_module = rb_define_module("Qt");

  ViewVC Help
Powered by ViewVC 1.1.20