[Kde-pim] [PATCH] Addressbook conduit crashing kpilot on second synchronization

Oleg Sidorkin osidorkin at gmail.com
Sat Aug 11 11:32:28 BST 2007


Hi!
There is a problem in KPilot's abbrowser conduit, that leads to crash of
kpilotDaemon during second synchronization
(kdepim-users thread is here:
http://lists.kde.org/?t=118125302600001&r=1&w=2). I faced the same problem
after
updating KDE from 3.5.6 to 3.5.7.

Abbrowser-conduid uses singleton (StdAddressbook) when it is configured to
use standart addressbook,
and deletes it in destructor soit tries to access already deleted class
during second run and crashes.

The attached patch seems to fix the problem in Kpilot 4.9.1.


-- 
Oleg S. Sidorkin
-------------- next part --------------
diff -u -r -p kdepim-3.5.7/kpilot/conduits/abbrowserconduit/abbrowser-conduit.cc kdepim-3.5.7-patched/kpilot/conduits/abbrowserconduit/abbrowser-conduit.cc
--- kdepim-3.5.7/kpilot/conduits/abbrowserconduit/abbrowser-conduit.cc	2007-05-14 11:54:52.000000000 +0400
+++ kdepim-3.5.7-patched/kpilot/conduits/abbrowserconduit/abbrowser-conduit.cc	2007-08-08 03:06:24.000000000 +0400
@@ -106,7 +106,7 @@ inline int faxTypeOnPC()
 using namespace KABC;
 
 AddressBook *AbbrowserConduit::aBook=0L;
-
+bool shouldDelete=false;
 
 /*********************************************************************
                         C O N S T R U C T O R
@@ -142,9 +142,7 @@ AbbrowserConduit::~AbbrowserConduit()
 		fTicket=0L;
 	}
 
-	DEBUGKPILOT << fname << ": Deleting addressbook" << endl;
-	KPILOT_DELETE(aBook);
-
+	_cleanupAddreessBookPointer();
 	// unused function warnings.
 	compile_time_check();
 }
@@ -285,6 +283,7 @@ bool AbbrowserConduit::_loadAddressBook(
 		case AbbrowserSettings::eAbookResource:
 			DEBUGKPILOT<<"Loading standard addressbook"<<endl;
 			aBook = StdAddressBook::self( true );
+			shouldDelete=false;
 			break;
 		case AbbrowserSettings::eAbookFile:
 		{ // initialize the abook with the given file
@@ -318,6 +317,7 @@ bool AbbrowserConduit::_loadAddressBook(
 				stopTickle();
 				return false;
 			}
+			shouldDelete=true;
 			break;
 		}
 		default: break;
@@ -331,7 +331,7 @@ bool AbbrowserConduit::_loadAddressBook(
 		emit logError(i18n("Unable to initialize and load the addressbook for the sync.") );
 		addSyncLogEntry(i18n("Unable to initialize and load the addressbook for the sync.") );
 		WARNINGKPILOT << "Unable to initialize the addressbook for the sync." << endl;
-		KPILOT_DELETE(aBook);
+		_cleanupAddreessBookPointer();
 		stopTickle();
 		return false;
 	}
@@ -343,7 +343,7 @@ bool AbbrowserConduit::_loadAddressBook(
 		WARNINGKPILOT << "Unable to lock addressbook for writing " << endl;
 		emit logError(i18n("Unable to lock addressbook for writing.  Can't sync!"));
 		addSyncLogEntry(i18n("Unable to lock addressbook for writing.  Can't sync!"));
-		KPILOT_DELETE(aBook);
+		_cleanupAddreessBookPointer();
 		stopTickle();
 		return false;
 	}
@@ -442,7 +442,18 @@ void AbbrowserConduit::_setAppInfo()
 }
 
 
-
+void AbbrowserConduit::_cleanupAddreessBookPointer()
+{
+        if (shouldDelete)
+        {
+                KPILOT_DELETE(aBook);
+                shouldDelete=false;
+        }
+        else
+        {
+                aBook=0L;
+	}												         
+}
 
 
 
diff -u -r -p kdepim-3.5.7/kpilot/conduits/abbrowserconduit/abbrowser-conduit.h kdepim-3.5.7-patched/kpilot/conduits/abbrowserconduit/abbrowser-conduit.h
--- kdepim-3.5.7/kpilot/conduits/abbrowserconduit/abbrowser-conduit.h	2007-05-14 11:54:52.000000000 +0400
+++ kdepim-3.5.7-patched/kpilot/conduits/abbrowserconduit/abbrowser-conduit.h	2007-08-08 03:01:28.000000000 +0400
@@ -110,7 +110,7 @@ private:
 	void _getAppInfo();
 	void _setAppInfo();
 
-
+	void _cleanupAddreessBookPointer();
 
 
 
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list