[Kde-bindings] KDE/kdebindings/csharp/ktexteditor

Richard Dale Richard_Dale at tipitina.demon.co.uk
Wed Jul 30 12:21:34 UTC 2008


SVN commit 839615 by rdale:

* When the KApplication for the kwrite example was created, it was assigned
  to a local variable 'a' in the Main() method. However, mono 1.2.4 garbage
  collected it before the Main() method was exited. It a static variable in
  the KWrite class is used, the problem goes away.

CCMAIL: kde-bindings at kde.org


 M  +7 -0      ChangeLog  
 M  +8 -6      examples/kwrite/kwritemain.cs  


--- trunk/KDE/kdebindings/csharp/ktexteditor/ChangeLog #839614:839615
@@ -1,3 +1,10 @@
+2008-07-30  Richard Dale  <richard.j.dale at gmail.com>
+
+* When the KApplication for the kwrite example was created, it was assigned
+  to a local variable 'a' in the Main() method. However, mono 1.2.4 garbage
+  collected it before the Main() method was exited. It a static variable in
+  the KWrite class is used, the problem goes away.
+
 2008-07-26  Arno Rehn  <arno at arnorehn.de>
 
 * Use qobject_cast in the KWrite example.
--- trunk/KDE/kdebindings/csharp/ktexteditor/examples/kwrite/kwritemain.cs #839614:839615
@@ -407,7 +407,7 @@
     private void ReadProperties(KSharedConfig config) {
         ReadConfig(config);
 
-        KTextEditor.SessionConfigInterface iface = qobject_cast<KTextEditor.SessionConfigInterface >(m_view);
+        KTextEditor.SessionConfigInterface iface = qobject_cast<KTextEditor.SessionConfigInterface>(m_view);
         if (iface != null)
             iface.ReadSessionConfig(new KConfigGroup(config, "General Options"));
     }
@@ -418,7 +418,7 @@
         KConfigGroup group = new KConfigGroup(config, "");
         group.WriteEntry("DocumentNumber", docList.IndexOf(m_view.Document()) + 1);
 
-        KTextEditor.SessionConfigInterface iface = qobject_cast<KTextEditor.SessionConfigInterface >(m_view);
+        KTextEditor.SessionConfigInterface iface = qobject_cast<KTextEditor.SessionConfigInterface>(m_view);
         if (iface != null) {
             KConfigGroup cg = new KConfigGroup( config, "General Options" );
             iface.WriteSessionConfig(cg);
@@ -434,7 +434,7 @@
             KConfigGroup cg = new KConfigGroup(config, buf);
             KTextEditor.Document doc = docList[z - 1];
 
-            KTextEditor.SessionConfigInterface iface = qobject_cast<KTextEditor.SessionConfigInterface >(doc);
+            KTextEditor.SessionConfigInterface iface = qobject_cast<KTextEditor.SessionConfigInterface>(doc);
             if (iface != null)
                 iface.WriteSessionConfig(cg);
             z++;
@@ -482,7 +482,7 @@
             KConfigGroup cg = new KConfigGroup(config, buf);
             doc = editor.CreateDocument(null);
 
-            KTextEditor.SessionConfigInterface iface = qobject_cast<KTextEditor.SessionConfigInterface >(doc);
+            KTextEditor.SessionConfigInterface iface = qobject_cast<KTextEditor.SessionConfigInterface>(doc);
             if (iface != null)
                 iface.ReadSessionConfig(cg);
             docList.Add(doc);
@@ -580,6 +580,8 @@
         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"),
@@ -634,12 +636,12 @@
         options.Add("+[URL]", KDE.Ki18n("Document to open"));
         KCmdLineArgs.AddCmdLineOptions(options);
 
-        KApplication a = new KApplication();
+        kapp = new KApplication();
 
         KGlobal.Locale().InsertCatalog("katepart4");
         KCmdLineArgs args = KCmdLineArgs.ParsedArgs();
 
-        if (a.IsSessionRestored()) {
+        if (kapp.IsSessionRestored()) {
             KWrite.Restore();
         } else {
             bool nav = false;



More information about the Kde-bindings mailing list