don't hoard empty friends/ignore-lists on the HDD
authorsheepluva
Tue, 18 Oct 2011 00:01:26 +0200
changeset 6145 e658c6f698dd
parent 6144 e8c302637b10
child 6146 c7c2dd71ced4
don't hoard empty friends/ignore-lists on the HDD
QTfrontend/ui/widget/chatwidget.cpp
--- a/QTfrontend/ui/widget/chatwidget.cpp	Mon Oct 17 22:48:11 2011 +0200
+++ b/QTfrontend/ui/widget/chatwidget.cpp	Tue Oct 18 00:01:26 2011 +0200
@@ -258,6 +258,21 @@
 void HWChatWidget::saveList(QStringList & list, const QString & file)
 {
     QFile txt(cfgdir->absolutePath() + "/" + file);
+
+    // list empty? => rather have no file for the list than an empty one
+    if (list.isEmpty())
+    {
+        if (txt.exists())
+        {
+            // try to remove file, if successful we're done here.
+            if (txt.remove())
+                return;
+        }
+        else
+            // there is no file
+            return;
+    }
+
     if(!txt.open(QIODevice::WriteOnly | QIODevice::Truncate))
         return;
     QTextStream stream(&txt);