[Kde-bindings] branches/KDE/4.4/kdebindings/csharp/qyoto/src
Arno Rehn
kde at arnorehn.de
Mon Feb 15 17:11:37 UTC 2010
SVN commit 1090622 by arnorehn:
backport from trunk:
Create global references for visible top-level widgets,
so they aren't garbage collected while being shown. This
should create a more natural behaviour. Fixes a bug reported
by Linuxoid Oz. Thanks!
CCMAIL: kde-bindings at kde.org
CCMAIL: linuxoidoz at yahoo.com.au
M +17 -1 qyoto.cpp
--- branches/KDE/4.4/kdebindings/csharp/qyoto/src/qyoto.cpp #1090621:1090622
@@ -89,7 +89,8 @@
{
// don't do anything if the application has already terminated
if (application_terminated) return false;
- QEvent *event = (QEvent *) data[1];
+ QObject *receiver = reinterpret_cast<QObject*>(data[0]);
+ QEvent *event = reinterpret_cast<QEvent*>(data[1]);
// If a child has been given a parent then make a global ref to it, to prevent
// garbage collection. If a parent has been removed, then remove to global ref
@@ -110,6 +111,21 @@
(*FreeGCHandle)(childObj);
}
+ } else if (event->type() == QEvent::Show || event->type() == QEvent::Hide) {
+ if (!receiver->isWidgetType() || receiver->parent() != 0)
+ return false;
+
+ void *obj = (*GetInstance)(receiver, true);
+ if (!obj)
+ return false;
+
+ if (event->type() == QEvent::Show) {
+ (*AddGlobalRef)(obj, receiver); // Keep top-level widgets alive as long as they're visible.
+ } else {
+ (*RemoveGlobalRef)(obj, receiver); // Make them eligible for collection as soon as they're hidden (and if there are no more references to them, obviously).
+ }
+
+ (*FreeGCHandle)(obj);
}
return false;
More information about the Kde-bindings
mailing list