File r890871.diff of Package kdepim4

Subject: kontact: fix crash on opening configure dialog
From: wstephenson@suse.de
Bug: kde#174707
Patch-upstream: 890871
--- libkpgp/kpgp.cpp	(revision 890870)
+++ libkpgp/kpgp.cpp	(revision 890871)
@@ -68,10 +68,6 @@ Module::Module()
     mSecretKeysCached(false),
     passphrase(0), passphrase_buffer_len(0), havePassPhrase(false)
 {
-  if (!kpgpObject) {
-    kDebug( 5326 ) <<"creating new pgp object";
-  }
-  kpgpObject=kpgpod.setObject(Module::kpgpObject, this);
   pgp = 0;
 
   config = new KConfig("kpgprc");
@@ -1018,7 +1014,7 @@ Module::getKpgp()
 {
   if (!kpgpObject)
   {
-      kError(5326) <<"there is no instance of kpgp available";
+    kpgpObject = kpgpod.setObject(Module::kpgpObject, new Module());
   }
   return kpgpObject;
 }
--- libkpgp/kpgp.h	(revision 890870)
+++ libkpgp/kpgp.h	(revision 890871)
@@ -80,9 +80,13 @@ private:
     // the class running pgp
     Base *pgp;
 
+  /**
+   * Singleton pattern: use getKpgp()
+   */
+  Module();
+
 public:
-    Module();
-    virtual ~Module();
+  virtual ~Module();
 
   /** the following virtual function form the interface to the
       application using Kpgp
--- kmail/messagecomposer.h	(revision 890870)
+++ kmail/messagecomposer.h	(revision 890871)
@@ -41,7 +41,6 @@
 
 #include <mimelib/mediatyp.h>
 #include "kleo/cryptobackend.h"
-#include <libkpgp/kpgp.h>
 
 #include <vector>
 
--- kmail/messagecomposer.cpp	(revision 890870)
+++ kmail/messagecomposer.cpp	(revision 890871)
@@ -70,7 +70,6 @@
 #include <kmime/kmime_util.h>
 #include <kmime/kmime_codecs.h>
 
-#include <libkpgp/kpgpblock.h>
 #include <kconfiggroup.h>
 #include <kmessagebox.h>
 #include <klocale.h>
--- kmail/kmkernel.cpp	(revision 890870)
+++ kmail/kmkernel.cpp	(revision 890871)
@@ -56,7 +56,6 @@ using KMail::TemplateParser;
 #include <kapplication.h>
 #include <ksystemtrayicon.h>
 #include <kconfiggroup.h>
-#include <libkpgp/kpgp.h>
 #include <kdebug.h>
 #include <kio/jobuidelegate.h>
 #include <kio/netaccess.h>
@@ -137,7 +136,6 @@ KMKernel::KMKernel (QObject *parent, con
 
   mXmlGuiInstance = KComponentData();
 
-  new Kpgp::Module();
 
   netCodec = QTextCodec::codecForName( KGlobal::locale()->encoding() );
 
--- knode/knmainwidget.h	(revision 890870)
+++ knode/knmainwidget.h	(revision 890871)
@@ -214,7 +214,6 @@ protected:
   KNFilterManager   *f_ilManager;
   KNScoringManager  *s_coreManager;
   KNMemoryManager   *m_emManager;
-  Kpgp::Module      *p_gp;
 
 protected slots:
   //listview slots
--- knode/articlewidget.cpp	(revision 890870)
+++ knode/articlewidget.cpp	(revision 890871)
@@ -776,7 +776,7 @@ QString ArticleWidget::displaySigHeader(
     signClass = "signWarn";
   } else {
     // determine the validity of the key
-    Kpgp::Module *pgp = knGlobals.pgp;
+    Kpgp::Module *pgp = Kpgp::Module::getKpgp();
     Kpgp::Validity keyTrust;
     if( !signerKey.isEmpty() )
       keyTrust = pgp->keyTrust( signerKey );
--- knode/knglobals.h	(revision 890870)
+++ knode/knglobals.h	(revision 890871)
@@ -37,9 +37,6 @@ class KNMainWidget;
 class KNScoringManager;
 class KNMemoryManager;
 class KXMLGUIClient;
-namespace Kpgp {
-   class Module;
-}
 namespace KNode {
   class ArticleWidget;
   class Scheduler;
@@ -68,7 +65,6 @@ class KNODE_EXPORT KNGlobals
     KNode::ArticleWidget  *artWidget;
     /** Returns the article factory. */
     KNArticleFactory      *artFactory;
-    Kpgp::Module          *pgp;
     KConfig               *config();
     /** Returns the current instance. */
     const KComponentData &componentData() const;
--- knode/knconfigwidgets.cpp	(revision 890870)
+++ knode/knconfigwidgets.cpp	(revision 890871)
@@ -33,7 +33,6 @@
 #include <kscoringeditor.h>
 #include <sonnet/configwidget.h>
 #include <kcombobox.h>
-#include <libkpgp/kpgp.h>
 #include <libkpgp/kpgpui.h>
 #include <kurlcompletion.h>
 #include <kiconloader.h>
--- knode/kncomposer.cpp	(revision 890870)
+++ knode/kncomposer.cpp	(revision 890871)
@@ -47,7 +47,6 @@ using KPIM::RecentAddresses;
 #include <klineedit.h>
 #include <kcombobox.h>
 #include <ktemporaryfile.h>
-#include <libkpgp/kpgp.h>
 #include <libkpgp/kpgpblock.h>
 #include <kpimutils/spellingfilter.h>
 #include <kcompletionbox.h>
--- knode/knmainwidget.cpp	(revision 890870)
+++ knode/knmainwidget.cpp	(revision 890871)
@@ -74,7 +74,6 @@ using MailTransport::TransportManager;
 #include "kncleanup.h"
 #include "utilities.h"
 #include "knscoring.h"
-#include <libkpgp/kpgp.h>
 #include "knmemorymanager.h"
 #include "scheduler.h"
 #include "settings.h"
@@ -209,10 +208,6 @@ KNMainWidget::KNMainWidget( KXMLGUIClien
   // Memory Manager
   m_emManager = knGlobals.memoryManager();
 
-  // create a global pgp instance
-  p_gp = new Kpgp::Module();
-  knGlobals.pgp = p_gp;
-
   QDBusConnection::sessionBus().registerObject( "/", this, QDBusConnection::ExportScriptableSlots );
   //-------------------------------- </CORE> -----------------------------------
 
@@ -277,8 +272,6 @@ KNMainWidget::~KNMainWidget()
   delete m_emManager;
   kDebug(5003) <<"KNMainWidget::~KNMainWidget() : Memory Manager deleted";
 
-  delete p_gp;
-  kDebug(5003) <<"KNMainWidget::~KNMainWidget() : PGP deleted";
 }
 
 void KNMainWidget::initStatusBar()
Index: libkpgp/kpgp.cpp
===================================================================
Index: libkpgp/kpgp.h
===================================================================
Index: kmail/messagecomposer.h
===================================================================
Index: kmail/messagecomposer.cpp
===================================================================
Index: kmail/kmkernel.cpp
===================================================================
Index: knode/knmainwidget.h
===================================================================
Index: knode/articlewidget.cpp
===================================================================
Index: knode/knglobals.h
===================================================================
Index: knode/knconfigwidgets.cpp
===================================================================
Index: knode/kncomposer.cpp
===================================================================
Index: knode/knmainwidget.cpp
===================================================================
openSUSE Build Service is sponsored by