Quoting bulia byak <buliabyak@...400...>:
https://sourceforge.net/tracker/index.php?func=detail&aid=1303842&gr...
I also suspect this bug has the same nature:
https://sourceforge.net/tracker/index.php?func=detail&aid=1291009&gr...
You're correct.
This is because, for garbage-collected objects, destructors (finalizers) are not called deterministically because memory is not freed deterministically. Time-critical code should be moved out of destructors.
If I remember correctly, SPDesktop's destructor is currently responsible for withdrawing its canvas items as a side-effect of being freed. There should instead be a method for the widget to tell the desktop to do this explicitly before discarding it.
In general switching classes to the garbage collector must involve switching from C++-like to Java-like cleanup idioms. C++ programmers moving to Java often get bitten by this issue in the same way, and the solution is the same.
-mental