[Kde-bindings] KDE/kdebindings/csharp/kimono
Arno Rehn
kde at arnorehn.de
Sun Jul 6 00:56:16 UTC 2008
SVN commit 828489 by arnorehn:
* mono_jit_cleanup() is now called from a function that is registered
via atexit(). This seems to be the only way to do that, since calling
it from the destructor of KimonoPluginFactory makes mono crash.
CCMAIL: kde-bindings at kde.org
M +6 -0 ChangeLog
M +22 -23 src/kimonopluginfactory.cpp
--- trunk/KDE/kdebindings/csharp/kimono/ChangeLog #828488:828489
@@ -1,3 +1,9 @@
+2008-07-06 Arno Rehn <arno at arnorehn.de>
+
+ * mono_jit_cleanup() is now called from a function that is registered
+ via atexit(). This seems to be the only way to do that, since calling
+ it from the destructor of KimonoPluginFactory makes mono crash.
+
2008-07-01 Arno Rehn <arno at arnorehn.de>
* Added KMonoPluginFactory. Behaves similar to KRubyPluginFactory:
--- trunk/KDE/kdebindings/csharp/kimono/src/kimonopluginfactory.cpp #828488:828489
@@ -37,6 +37,9 @@
#include <mono/metadata/assembly.h>
#include <mono/metadata/debug-helpers.h>
+#include <stdlib.h>
+#include <stdio.h>
+
class QWidget;
class KimonoPluginFactory : public KPluginFactory
@@ -51,9 +54,7 @@
const QString &keyword);
private:
- void InitQyotoRuntime();
-
- MonoDomain* domain;
+ void initQyotoRuntime();
QHash<QString, MonoAssembly*> assemblies;
QHash<MonoAssembly*, MonoImage*> images;
@@ -68,33 +69,28 @@
};
K_EXPORT_PLUGIN(KimonoPluginFactory)
+// Make this one global to be accessible from atexitfn().
+MonoDomain* domain = 0;
+
+// This seems to be the only way, since calling mono_jit_cleanup()
+// from the destructor of KimonoPluginFactory makes mono crash.
+void atexitfn()
+{
+// printf("(kimonopluginfactory.cpp:%d) calling mono_jit_cleanup(%p)\n", __LINE__, domain);
+ mono_jit_cleanup(domain);
+}
+
KimonoPluginFactory::KimonoPluginFactory()
- : domain(0), qyotoAssembly(0), qyotoImage(0), qyotoInitialized(false)
+ : qyotoAssembly(0), qyotoImage(0), qyotoInitialized(false)
{
}
KimonoPluginFactory::~KimonoPluginFactory()
{
- foreach(guint32 handle, handles)
- mono_gchandle_free(handle);
-
- if (qyotoImage)
- mono_image_close(qyotoImage);
- if (qyotoAssembly)
- mono_assembly_close(qyotoAssembly);
-
- foreach(MonoImage* img, images)
- mono_image_close(img);
- foreach(MonoAssembly* a, assemblies)
- mono_assembly_close(a);
-
- // FIXME: this should actually work
- /*if (domain)
- mono_jit_cleanup(domain);*/
}
void
-KimonoPluginFactory::InitQyotoRuntime()
+KimonoPluginFactory::initQyotoRuntime()
{
if (qyotoInitialized)
return;
@@ -128,8 +124,11 @@
}
// initialize the JIT
- if (!domain)
+ if (!domain) {
domain = mono_jit_init((const char*) path.toLatin1());
+// printf("(kimonopluginfactory.cpp:%d) new domain (ptr: %p)\n", __LINE__, domain);
+ atexit(atexitfn);
+ }
MonoAssembly* assembly;
if (assemblies.contains(path)) {
@@ -179,7 +178,7 @@
objects << object;
// initialize the Qyoto runtime
- InitQyotoRuntime();
+ initQyotoRuntime();
// wrap the parent QObject
smokeqyoto_object* po = alloc_smokeqyoto_object(false, qt_Smoke, qt_Smoke->idClass("QObject").index, parent);
More information about the Kde-bindings
mailing list