[Kde-bindings] KDE/kdebindings

Arno Rehn kde at arnorehn.de
Wed Jul 30 23:20:04 UTC 2008


SVN commit 839853 by arnorehn:

* Fix a bug where the wrong classid was assigned to $classNode->{ClassIndex}.                                   
* Assign a new KApplication instance to the qApp global variable.
  This should fix the KWrite example complaining about a missing QApplication
  because it won't be collected too early this way.
* KWrite example:
  Implement the IDisposable interface and do the cleanup there. The
  finalizer of KWrite is called too late by the GC - the underlying
  C++ instance has already been destroyed by then.

CCMAIL: kde-bindings at kde.org



 M  +4 -0      csharp/kimono/ChangeLog  
 M  +3 -0      csharp/kimono/kde/KApplication.cs  
 M  +7 -0      csharp/ktexteditor/ChangeLog  
 M  +17 -8     csharp/ktexteditor/examples/kwrite/kwritemain.cs  
 M  +6 -1      kalyptus/ChangeLog  
 M  +3 -0      kalyptus/kalyptusCxxToKimono.pm  
 M  +1 -1      kalyptus/kalyptusCxxToSmoke.pm  


--- trunk/KDE/kdebindings/csharp/kimono/ChangeLog #839852:839853
@@ -1,3 +1,7 @@
+2008-07-31  Arno Rehn  <arno at arnorehn.de>
+
+	* Assign a new KApplication instance to the qApp global variable.
+
 2008-07-07  Arno Rehn  <arno at arnorehn.de>
 
 	* KimonoPluginFactory: If a class isn't found in the assembly, look
--- trunk/KDE/kdebindings/csharp/kimono/kde/KApplication.cs #839852:839853
@@ -63,10 +63,12 @@
         public KApplication(bool GUIenabled) : this((Type) null) {
             CreateProxy();
             interceptor.Invoke("KApplication$", "KApplication(bool)", typeof(void), typeof(bool), GUIenabled);
+            qApp = this;
         }
         public KApplication() : this((Type) null) {
             CreateProxy();
             interceptor.Invoke("KApplication", "KApplication()", typeof(void));
+            qApp = this;
         }
         /// <remarks>
         ///  Returns the application session config object.
@@ -238,6 +240,7 @@
         public KApplication(bool GUIenabled, KComponentData cData) : this((Type) null) {
             CreateProxy();
             interceptor.Invoke("KApplication$#", "KApplication(bool, const KComponentData&)", typeof(void), typeof(bool), GUIenabled, typeof(KComponentData), cData);
+            qApp = this;
         }
         ~KApplication() {
             interceptor.Invoke("~KApplication", "~KApplication()", typeof(void));
--- trunk/KDE/kdebindings/csharp/ktexteditor/ChangeLog #839852:839853
@@ -1,3 +1,10 @@
+2008-07-31  Arno Rehn  <arno at arnorehn.de>
+
+* KWrite example:
+  Implement the IDisposable interface and do the cleanup there. The
+  finalizer of KWrite is called too late by the GC - the underlying
+  C++ instance has already been destroyed by then.
+
 2008-07-30  Richard Dale  <richard.j.dale at gmail.com>
 
 * When the KApplication for the kwrite example was created, it was assigned
--- trunk/KDE/kdebindings/csharp/ktexteditor/examples/kwrite/kwritemain.cs #839852:839853
@@ -24,7 +24,7 @@
 using Qyoto;
 using Kimono;
 
-public class KWrite : KParts.MainWindow {
+public class KWrite : KParts.MainWindow, IDisposable {
     private KTextEditor.View m_view = null;
 
     private KRecentFilesAction m_recentFiles = null;
@@ -114,17 +114,25 @@
         Show();
     }
 
-    ~KWrite() {
+    private bool isDisposed = false;
+
+    public new void Dispose() {
+        if (isDisposed) return;
+        isDisposed = true;
         winList.Remove(this);
 
         if (m_view.Document().Views().Count == 1) {
             docList.Remove(m_view.Document());
-            // m_view.Document().Dispose();
+            m_view.Document().Dispose();
         }
 
         KGlobal.Config().Sync();
     }
 
+    ~KWrite() {
+        Dispose();
+    }
+
     private void SetupActions() {
         ActionCollection().AddAction(KStandardAction.StandardAction.Close, "file_close", this, SLOT("SlotFlush()"))
             .WhatsThis = KDE.I18n("Use this to close the current document");
@@ -217,11 +225,14 @@
 
     // is closing the window wanted by user?
     protected override bool QueryClose() {
-        if (m_view.Document().Views().Count > 1)
+        if (m_view.Document().Views().Count > 1) {
+            Dispose();
             return true;
+        }
 
         if (m_view.Document().QueryClose()) {
-            // WriteConfig();
+            WriteConfig();
+            Dispose();
             return true;
         }
 
@@ -580,8 +591,6 @@
         m_modeLabel.Text = document.Mode();
     }
 
-    private static KApplication kapp = null;
-
     public static int Main(String[] argv) {
         KAboutData aboutData = new KAboutData(  "kwrite-sharp", "Simple Text Editor",
                                                 KDE.Ki18n("KWrite"),
@@ -636,7 +645,7 @@
         options.Add("+[URL]", KDE.Ki18n("Document to open"));
         KCmdLineArgs.AddCmdLineOptions(options);
 
-        kapp = new KApplication();
+        KApplication kapp = new KApplication();
 
         KGlobal.Locale().InsertCatalog("katepart4");
         KCmdLineArgs args = KCmdLineArgs.ParsedArgs();
--- trunk/KDE/kdebindings/kalyptus/ChangeLog #839852:839853
@@ -1,5 +1,10 @@
-2008-07-27  Arno Rehn  <arno at arnorehnde.>
+2008-07-31  Arno Rehn  <arno at arnorehn.de>
 
+	* Fix a bug where the wrong classid was assigned to $classNode->{ClassIndex}.
+	* Assign a new KApplication instance to the qApp global variable.
+
+2008-07-27  Arno Rehn  <arno at arnorehn.de>
+
 	* Add some more pass-by-reference types to the C# module.
 	* Convert char* to Pointer<sbyte> instead of string.
 
--- trunk/KDE/kdebindings/kalyptus/kalyptusCxxToKimono.pm #839852:839853
@@ -2380,6 +2380,9 @@
 				$methodCode .= "        public $csharpClassName($csharpparams) : this((Type) null) {\n";
 				$methodCode .= "            CreateProxy();\n";
 				$methodCode .= smokeInvocation("interceptor", \@csharpArgTypeList, "void", $mungedMethod, $signature, $addImport);
+				if ($name eq 'KApplication') {
+					$methodCode .= "            qApp = this;\n";
+				}
 				$methodCode .= "        }\n";
 			}
 		} elsif ( $mainClassNode->{Pure} && $isPure ) {
--- trunk/KDE/kdebindings/kalyptus/kalyptusCxxToSmoke.pm #839852:839853
@@ -2141,7 +2141,7 @@
 	push @classlist, $className;
 	push @moduleclasslist, $className unless (defined($excludeClasses{$className}) && !defined($externClasses{$className}));
 	$enumclasslist{$className}++ if keys %{$classNode->{enumerations}};
-	$classNode->{ClassIndex} = $#classlist;
+	$classNode->{ClassIndex} = $#moduleclasslist;
 	addIncludeForClass( $classNode, \%allIncludes, undef ) unless (defined($excludeClasses{$className}) && !defined($externClasses{$className}));
     } );
 



More information about the Kde-bindings mailing list