[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE_3_2_BRANCH: kdebase/kcontrol/filetypes
From:       Waldo Bastian <bastian () kde ! org>
Date:       2004-02-29 23:24:22
Message-ID: 20040229232422.40CD19959 () office ! kde ! org
[Download RAW message or body]

CVS commit by waba: 

Don't crash if services suddenly disappear. This can happen when
the user uninstalls the application -> this causes kbuildsycoca
to run and the application to disappear from ksycoca. (BR76252)


  M +12 -14    kservicelistwidget.cpp   1.23.2.1
  M +2 -1      kservicelistwidget.h   1.5.2.1
  M +1 -1      kserviceselectdlg.cpp   1.8.2.1
  M +2 -1      typeslistitem.cpp   1.42.2.1


--- kdebase/kcontrol/filetypes/kservicelistwidget.cpp  #1.23:1.23.2.1
@@ -38,11 +38,7 @@
 #include <kstandarddirs.h>
 
-KServiceListItem::KServiceListItem( const QString &_desktopPath, int kind )
-    : QListBoxText(), desktopPath(_desktopPath)
+KServiceListItem::KServiceListItem( KService *pService, int kind )
+    : QListBoxText(), desktopPath(pService->desktopEntryPath())
 {
-    KService::Ptr pService = KService::serviceByDesktopPath( _desktopPath );
-
-    Q_ASSERT(pService);
-
     if ( kind == KServiceListWidget::SERVICELIST_APPLICATIONS )
         setText( pService->name() );
@@ -52,5 +48,5 @@ KServiceListItem::KServiceListItem( cons
     bool isApplication = pService->type() == "Application";
     if (!isApplication)
-      localPath = locateLocal("services", _desktopPath);
+      localPath = locateLocal("services", desktopPath);
     else
       localPath = pService->locateLocal();
@@ -178,5 +174,8 @@ void KServiceListWidget::setTypeItem( Ty
             it != services.end(); it++ )
       {
-        servicesLB->insertItem( new KServiceListItem(*it, m_kind) );
+        KService::Ptr pService = KService::serviceByDesktopPath( *it );
+
+        if (pService)
+          servicesLB->insertItem( new KServiceListItem(pService, m_kind) );
       }
       servicesLB->setEnabled(true);
@@ -275,7 +274,5 @@ void KServiceListWidget::addService()
   }
 
-  QString desktopPath = service->desktopEntryPath();
-
-  servicesLB->insertItem( new KServiceListItem(desktopPath, m_kind), 0 );
+  servicesLB->insertItem( new KServiceListItem(service, m_kind), 0 );
   servicesLB->setCurrentItem(0);
 
@@ -304,4 +301,6 @@ void KServiceListWidget::editService()
       KService::Ptr pService = KService::serviceByDesktopPath(
           ((KServiceListItem*)selItem)->desktopPath );
+      if (!pService)
+        return;
 
       QString path = pService->desktopEntryPath();
@@ -332,6 +331,5 @@ void KServiceListWidget::editService()
       // ...and add it in the same place as the old one:
       if ( addIt ) {
-        QString desktopPath = service->desktopEntryPath();
-        servicesLB->insertItem( new KServiceListItem(desktopPath, m_kind), selected \
); +        servicesLB->insertItem( new KServiceListItem(service, m_kind), selected \
);  }
 

--- kdebase/kcontrol/filetypes/kservicelistwidget.h  #1.5:1.5.2.1
@@ -27,9 +27,10 @@ class TypesListItem;
 class QLineEdit;
 class QPushButton;
+class KService;
 
 class KServiceListItem : public QListBoxText
 {
 public:
-    KServiceListItem(  const QString &desktopPath, int kind );
+    KServiceListItem(  KService *pService, int kind );
     bool isImmutable();
     QString desktopPath;

--- kdebase/kcontrol/filetypes/kserviceselectdlg.cpp  #1.8:1.8.2.1
@@ -45,5 +45,5 @@ KServiceSelectDlg::KServiceSelectDlg( co
       if ( (*it)->hasServiceType( "KParts/ReadOnlyPart" ) )
       {
-          m_listbox->insertItem( new KServiceListItem( (*it)->desktopEntryPath(), \
KServiceListWidget::SERVICELIST_SERVICES ) ); +          m_listbox->insertItem( new \
KServiceListItem( (*it), KServiceListWidget::SERVICELIST_SERVICES ) );  }
 

--- kdebase/kcontrol/filetypes/typeslistitem.cpp  #1.42:1.42.2.1
@@ -391,4 +391,5 @@ KMimeType::Ptr TypesListItem::findImplic
 {
     KService::Ptr s = KService::serviceByDesktopPath(desktop);
+    if (!s) return 0; // Hey, where did that one go?
 
     if( s_changedServices == NULL )
@@ -414,5 +415,5 @@ void TypesListItem::saveServices( KConfi
 
     KService::Ptr pService = KService::serviceByDesktopPath(*it);
-    Q_ASSERT(pService);
+    if (!pService) continue; // Where did that one go?
 
     // Find a group header. The headers are just dummy names as far as


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic