Re: Memory fault when inserting QTableItem into QTable
Richard Dale <[email protected]>
| Newsgroups | gmane.comp.kde.devel.perl |
|---|---|
| Organization | Lost HIghway |
| Message-ID | <[email protected]> |
On Monday 30 August 2004 14:19, Oliver Kreuer wrote: > Hello, > > first of all I have to apologize that I couldn't spend time until now to > test the patches provided by Richard. > > I've tried patch perlqtdispose_0.2.patch (see thread "Freeing memory > used by QTableItem) and it works fine in my testscripts. I didn't try > patch perlqtdispose_0.3.patch because Richard wrote that he's going off > the idea a bit. > > So for me this patch (0.2) solves my problem. As far as I understood the > ongoing conversation after Richards 0.2er patch this patch isn't as > "stable" as one could wish. I've had a look at the 0.2 patch, and its got some 'random' stuff in there that isn't to do with adding the dispose() method, so I would be careful about using it. Here is a cleaned up version without any of the unwanted 'zombie' changes or anything else. > Therefore I wonder if there will be a "final" solution to this problem > in a next or newer version of Perl/Qt? That's up to Germain to decide if its a good idea or not. -- Richard _______________________________________________ Kde-perl mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-perl
perlqtdispose_0.4.patch
(text/x-diff, 1.6 KB)
diff -Naur -X /home/duke/bin/patcher.exclude PerlQt/Qt.pm temp/Qt.pm
--- PerlQt/Qt.pm 2003-09-09 03:57:11.000000000 +0100
+++ temp/Qt.pm 2004-07-12 06:11:09.000000000 +0100
@@ -1108,4 +1108,17 @@
return 1
}
+sub Qt::base::dispose
+{
+ package Qt::_internal;
+ Qt::_internal::dispose(this());
+ return;
+}
+
+sub Qt::base::isDisposed
+{
+ package Qt::_internal;
+ return Qt::_internal::isDisposed(this());
+}
+
1;
diff -Naur -X /home/duke/bin/patcher.exclude PerlQt/Qt.xs temp/Qt.xs
--- PerlQt/Qt.xs 2003-09-09 09:41:25.000000000 +0100
+++ temp/Qt.xs 2004-07-12 06:11:09.000000000 +0100
@@ -1743,6 +1743,44 @@
delete qobj;
void
+dispose(obj)
+ SV *obj
+ CODE:
+ smokeperl_object *o = sv_obj_info(obj);
+ if(!o || !o->ptr) {
+ XSRETURN_EMPTY;
+ } else {
+ const char *className = o->smoke->classes[o->classId].className;
+ char *methodName = new char[strlen(className) + 2];
+ methodName[0] = '~';
+ strcpy(methodName + 1, className);
+ Smoke::Index nameId = o->smoke->idMethodName(methodName);
+ Smoke::Index meth = o->smoke->findMethod(o->classId, nameId);
+ if(meth > 0) {
+ Smoke::Method &m = o->smoke->methods[o->smoke->methodMaps[meth].method];
+ Smoke::ClassFn fn = o->smoke->classes[m.classId].classFn;
+ Smoke::StackItem i[1];
+ (*fn)(m.method, o->ptr, i);
+ }
+ delete[] methodName;
+ o->allocated = false;
+ o->zombie = true;
+ }
+
+bool
+isDisposed(obj)
+ SV *obj
+ CODE:
+ smokeperl_object *o = sv_obj_info(obj);
+ if(!o || o->zombie) {
+ RETVAL = 0;
+ } else {
+ RETVAL = 1;
+ }
+ OUTPUT:
+ RETVAL
+
+void
mapObject(obj)
SV *obj
CODE: