[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-bugs-dist
Subject: [Bug 56733] Crash on starting juk
From: Scott Wheeler <wheeler () kde ! org>
Date: 2003-07-18 7:29:58
[Download RAW message or body]
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
http://bugs.kde.org/show_bug.cgi?id=56733
wheeler@kde.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
------- Additional Comments From wheeler@kde.org 2003-07-18 09:29 -------
Subject: kdemultimedia/juk
CVS commit by wheeler:
Checksum the cache on write and compare to that value on read. With this
I'm closing the "crash on startup" bug since this should fix things.
CCMAIL:56733-done@bugs.kde.org
M +39 -6 cache.cpp 1.13
--- kdemultimedia/juk/cache.cpp #1.12:1.13
@@ -17,7 +17,11 @@
#include <kstandarddirs.h>
+#include <kmessagebox.h>
+#include <kconfig.h>
+#include <klocale.h>
#include <kdebug.h>
#include <qdir.h>
+#include <qbuffer.h>
#include "cache.h"
@@ -49,5 +53,6 @@ void Cache::save()
return;
- QDataStream s(&f);
+ QByteArray data;
+ QDataStream s(data, IO_WriteOnly);
for(QDictIterator<Tag>it(*this); it.current(); ++it) {
@@ -56,7 +61,19 @@ void Cache::save()
}
+ f.writeBlock(data);
f.close();
- QDir dir(dirName);
- dir.rename("cache.new", "cache");
+
+ QDir(dirName).rename("cache.new", "cache");
+
+ // Store the checksum so that later we can make sure that things are ok.
+
+ int checksum = qChecksum(data.data(), data.size());
+
+ KConfig *config = KGlobal::config();
+ {
+ KConfigGroupSaver saver(config, "Cache");
+ config->writeEntry("Checksum", checksum);
+ }
+ config->sync();
}
@@ -84,5 +101,23 @@ void Cache::load()
return;
- QDataStream s(&f);
+ QByteArray data = f.readAll();
+ f.close();
+
+ // Compare the checksum of the data to the one stored in the config file to
+ // make sure that our cache isn't corrupt.
+
+ int checksum;
+ KConfig *config = KGlobal::config();
+ {
+ KConfigGroupSaver saver(config, "Cache");
+ checksum = config->readNumEntry("Checksum", -1);
+ }
+ if(checksum >= 0 && checksum != qChecksum(data.data(), data.size())) {
+ KMessageBox::sorry(0, i18n("The music data cache has been corrupted. JuK "
+ "needs to rescan it now. This may take some time."));
+ return;
+ }
+
+ QDataStream s(data, IO_ReadOnly);
while(!s.atEnd()) {
@@ -100,5 +135,3 @@ void Cache::load()
// CollectionListItem constructor.
}
-
- f.close();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic