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 Friday 09 July 2004 09:33, Oliver Kreuer wrote: > I appended two example scripts with input files. > Script "table_fault.pl" reproduces the memory fault whereas > "table_ok.pl" contains a work around. The work around is not very > pleasant so I'm still interested why this memory fault occurs. > Due to bug #924345 the work around has to use takeItem insted of removeRow. Here's my attempt at fixing this. I think the problem is that when a perl instance is garbage collected and the DESTROY method is called, the perlqt runtime will only delete the C++ instance if it doesn't have a parent. In this case the Qt::TableItem has a parent and the C++ instance wasn't deleted. However, perlqt still think it owns the instance - I think that part is wrong. So I've changed it so that perlqt no longer thinks it owns the C++ item under those circumstances. I think this needs more thought, but please try the attached patch. I've also translated your example to qtruby, and confirmed that doesn't have a similar problem. -- Richard _______________________________________________ Kde-perl mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-perl
perlqtcrashfix_0.1.patch
(text/x-diff, 357 B)
--- Qt.xs.save 2004-07-09 04:29:16.000000000 +0100
+++ Qt.xs 2004-07-09 16:39:02.000000000 +0100
@@ -999,6 +999,7 @@
SvREFCNT_dec(sv_this);
sv_this = old_this;
}
+ o->allocated = false;
if( ret && (do_debug & qtdb_gc) )
fprintf(stderr, "Increasing refcount in DESTROY for %s=%p (still has a parent)\n", package, o->ptr);
} else {