[Kde-bindings] Qyoto and QTreeView/QAbstractItemModel: "C# instance has been wrongly GC'd for virtual call"

Steven Boswell II ulatekh at yahoo.com
Fri Nov 18 20:06:34 UTC 2011


I'm using Qyoto and MonoDevelop under Linux to write applications in C# with Qt GUIs.  I ported TreeItem and TreeModel from the simpletreemodel example to C#, and attached a TreeModel to a QTreeView using its SetModel() method.  But I kept getting low-level crashes in Mono.  Sometimes, I would get a message: "C# instance has been wrongly GC'd for virtual ... call".

I lucked out finding a workaround; it turns out the data-model was getting garbage-collected.  I just saved a reference to it in my main class, and the problem went away.

It seems to me that anything passed to QTreeView.SetModel() should be accounted for within Mono's memory-management system, and not get garbage-collected behind its back.

I found a post on kde-bindings from June 2009 (see http://lists.kde.org/?l=kde-bindings&m=124587984005541 to read it) where someone had the same problem, but no one answered his question.

Hope this helps, though it's my understanding that Qyoto's author is no longer developing it.  That's a shame; Qt and C# seem like a powerful combo for cross-platform application development.


Steven Boswell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20111118/a67d2b91/attachment.html>


More information about the Kde-bindings mailing list