[Patch] Gideon

Otto Bruggeman bruggie at home.nl
Sat Sep 29 22:41:21 UTC 2001


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi folks,

i made a patch after running into some very weird problems when i
installed gideon. Most of the time they were null pointer issues because
there is no check for null after a KLibLoader call. The reason i got null
pointers was a little stupidity on my part, i forgot to remove the
config.cache so it kept installing the parts in $KDEDIR/lib/kde2 instead
of $KDEDIR/lib/kde3. Even though it is my fault the error could have
occurred otherwise because of a broken part or a binary incompatible part,
instead of completely failing it is wiser to give a nice message to the
user so i implemented some of them (there must be lost more) and that is
what the patch does. Check for null and if so give a nice errormessage
instead of crashing. Hope this small bit helps to get gideon more stable
and usable.

Otto Bruggeman
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Made with pgp4pine 1.75-6

iD8DBQE7tk4cDc93sltYd+ERArbLAJ0YhIQUg6Dot2fVj7P7oZ+pDpI89ACZAYgS
eARIJYhyCmVl95j77122Cyg=
=kx7O
-----END PGP SIGNATURE-----

-------------- next part --------------
Index: src/core.cpp
===================================================================
RCS file: /home/kde/kdevelop/src/core.cpp,v
retrieving revision 1.43
diff -u -3 -p -r1.43 core.cpp
--- src/core.cpp	2001/09/26 19:53:10	1.43
+++ src/core.cpp	2001/09/29 22:30:24
@@ -225,6 +225,10 @@ void Core::initGlobalParts()
         return;
     service = *makeFrontendOffers.begin();
     part = PartLoader::loadService(service, "KDevMakeFrontend", api, this);
+    if (!part) {
+        KMessageBox::error(win, i18n("Error: could not load part! Is it corrupt, binary incompatible or installed in the wrong directory, like $KDEDIR/lib/kde(2) instead of $KDEDIR/lib/kde3 ?"));
+        return;
+    }
     initPart(api->makeFrontend = static_cast<KDevMakeFrontend*>(part));
 
     // App frontend
@@ -234,6 +238,10 @@ void Core::initGlobalParts()
         return;
     service = *appFrontendOffers.begin();
     part = PartLoader::loadService(service, "KDevAppFrontend", api, this);
+    if (!part) {
+        KMessageBox::error(win, i18n("Error: could not load part! Is it corrupt, binary incompatible or installed in the wrong directory, like $KDEDIR/lib/kde(2) instead of $KDEDIR/lib/kde3 ?"));
+        return;
+    }
     initPart(api->appFrontend = static_cast<KDevAppFrontend*>(part));
 
     // Global parts
@@ -248,6 +256,10 @@ void Core::initGlobalParts()
             continue;
         }
         part = PartLoader::loadService(*it, "KDevPart", api, this);
+        if (!part) {
+            KMessageBox::error(win, i18n("Error: could not load part! Is it corrupt, binary incompatible or installed in the wrong directory, like $KDEDIR/lib/kde(2) instead of $KDEDIR/lib/kde3 ?"));
+            return;
+        }
         initPart(part);
         globalParts.append(part);
     }
@@ -525,6 +537,10 @@ void Core::openProject()
     KService::Ptr projectService = KService::serviceByName(projectPlugin);
     if (projectService) {
         KDevPart *part = PartLoader::loadService(projectService, "KDevProject", api, this);
+        if (!part) {
+            KMessageBox::error(win, i18n("Error: could not load part! Is it corrupt, binary incompatible or installed in the wrong directory, like $KDEDIR/lib/kde(2) instead of $KDEDIR/lib/kde3 ?"));
+            return;
+        }
         initPart(api->project = static_cast<KDevProject*>(part));
     } else {
         KMessageBox::sorry(win, i18n("No project management plugin %1 found.").arg(projectPlugin));
@@ -538,6 +554,10 @@ void Core::openProject()
     if (!languageSupportOffers.isEmpty()) {
         KService *languageSupportService = *languageSupportOffers.begin();
         KDevPart *part = PartLoader::loadService(languageSupportService, "KDevLanguageSupport", api, this);
+        if (!part) {
+            KMessageBox::error(win, i18n("Error: could not load part! Is it corrupt, binary incompatible or installed in the wrong directory, like $KDEDIR/lib/kde(2) instead of $KDEDIR/lib/kde3 ?"));
+            return;
+        }
         initPart(api->languageSupport = static_cast<KDevLanguageSupport*>(part));
     } else
         KMessageBox::sorry(win, i18n("No language plugin for %1 found.").arg(language));
@@ -556,6 +576,10 @@ void Core::openProject()
       
       if (loadparts.contains((*it)->name())){ // load the part if in loadparts
 	KDevPart *part = PartLoader::loadService(*it, "KDevPart", api, this);
+        if (!part) {
+            KMessageBox::error(win, i18n("Error: could not load part! Is it corrupt, binary incompatible or installed in the wrong directory, like $KDEDIR/lib/kde(2) instead of $KDEDIR/lib/kde3 ?"));
+            return;
+        }
 	initPart(part);
 	localParts.append(part);
       }
@@ -580,6 +604,10 @@ void Core::openProject()
 	  if(keywordsMatch){
 	    loadparts << (*it)->name();
 	    KDevPart *part = PartLoader::loadService(*it, "KDevPart", api, this);
+            if (!part) {
+                KMessageBox::error(win, i18n("Error: could not load part! Is it corrupt, binary incompatible or installed in the wrong directory, like $KDEDIR/lib/kde(2) instead of $KDEDIR/lib/kde3 ?"));
+                return;
+            }
 	    initPart(part);
 	    localParts.append(part);
 	  }
Index: src/partloader.cpp
===================================================================
RCS file: /home/kde/kdevelop/src/partloader.cpp,v
retrieving revision 1.6
diff -u -3 -p -r1.6 partloader.cpp
--- src/partloader.cpp	2001/07/17 19:36:48	1.6
+++ src/partloader.cpp	2001/09/29 22:30:24
@@ -16,6 +16,8 @@
 
 #include <kconfig.h>
 #include <kapp.h>
+#include <kmessagebox.h>
+#include <klocale.h>
 
 
 #include "kdevfactory.h"
@@ -101,7 +103,11 @@ KDevPart *PartLoader::loadService(KServi
 
     kdDebug(9000) << "Loading service " << service->name() << endl;
     KLibFactory *factory = factoryForService(service);
-    if (!factory->inherits("KDevFactory")) {
+    if (!factory || !factory->inherits("KDevFactory")) {
+        if (!factory) {
+            KMessageBox::error(0, i18n("Error: could not load part! Is it corrupt, binary incompatible or installed in the wrong directory, like $KDEDIR/lib/kde(2) instead of $KDEDIR/lib/kde3 ?"));
+            return 0;
+        }
         kdDebug(9000) << "Does not have a KDevFactory" << endl;
         return 0;
     }  


More information about the KDevelop-devel mailing list