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

List:       kde-commits
Subject:    kdebase/kcontrol/filetypes
From:       Luboš Luňák <l.lunak () kde ! org>
Date:       2003-06-23 9:55:30
[Download RAW message or body]

CVS commit by lunakl: 

If KView is associated with both image/png and image/jpeg, and
this association from both types is removed, KView's types
are modified twice. Therefore, when modifying app/service, it needs
to be first checked if it wasn't changed already, or all but the last
change will be lost.


  M +1 -0      filetypesview.cpp   1.64
  M +18 -1     typeslistitem.cpp   1.33
  M +2 -0      typeslistitem.h   1.14


--- kdebase/kcontrol/filetypes/filetypesview.cpp  #1.63:1.64
@@ -144,4 +144,5 @@ void FileTypesView::readFileTypes()
     m_majorMap.clear();
     m_itemList.clear();
+    TypesListItem::reset();
 
     TypesListItem *groupItem;

--- kdebase/kcontrol/filetypes/typeslistitem.cpp  #1.32:1.33
@@ -4,7 +4,11 @@
 #include <kstandarddirs.h>
 #include <kdesktopfile.h>
+#include <kstaticdeleter.h>
 
 #include "typeslistitem.h"
 
+QMap< QString, QStringList >* TypesListItem::s_changedServices;
+static KStaticDeleter< QMap< QString, QStringList > > deleter;
+
 TypesListItem::TypesListItem(QListView *parent, const QString & major)
   : QListViewItem(parent), metaType(true), m_bNewItem(false)
@@ -279,5 +283,8 @@ void TypesListItem::sync()
         // create a new .desktop file without this mimetype
 
-        QStringList serviceTypeList = pService->serviceTypes();
+        if( s_changedServices == NULL )
+            deleter.setObject( s_changedServices, new QMap< QString, QStringList > );
+        QStringList serviceTypeList = s_changedServices->contains( pService->desktopEntryPath())
+            ? (*s_changedServices)[ pService->desktopEntryPath() ] : pService->serviceTypes();
 
         if ( serviceTypeList.contains( name() ) ) {
@@ -299,4 +306,8 @@ void TypesListItem::sync()
           desktop->writeEntry("MimeType", serviceTypeList, ';');
 
+        // if two or more types have been modified, and they use the same service,
+        // accumulate the changes
+          (*s_changedServices)[ pService->desktopEntryPath() ] = serviceTypeList;
+
           desktop->sync();
           delete desktop;
@@ -406,3 +417,9 @@ void TypesListItem::refresh()
     kdDebug() << "TypesListItem refresh " << name() << endl;
     m_mimetype = KMimeType::mimeType( name() );
+}
+
+void TypesListItem::reset()
+{
+    if( s_changedServices )
+        s_changedServices->clear();
 }

--- kdebase/kcontrol/filetypes/typeslistitem.h  #1.13:1.14
@@ -60,4 +60,5 @@ public:
 
   static bool defaultEmbeddingSetting(  const QString& major );
+  static void reset();
 
 private:
@@ -77,4 +78,5 @@ private:
   QStringList m_appServices;
   QStringList m_embedServices;
+  static QMap< QString, QStringList >* s_changedServices;
 };
 


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

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