[PC-BSD Commits] r6298 - pcbsd/branches/7.1.1/PBIThumbnailCreator
svn at pcbsd.org
svn at pcbsd.org
Wed Feb 24 10:17:23 PST 2010
Author: kris
Date: 2010-02-24 10:17:23 -0800 (Wed, 24 Feb 2010)
New Revision: 6298
Modified:
pcbsd/branches/7.1.1/PBIThumbnailCreator/pbicreator.cpp
Log:
Backport the fix for PBIThumbnail creator on 8.0
Modified: pcbsd/branches/7.1.1/PBIThumbnailCreator/pbicreator.cpp
===================================================================
--- pcbsd/branches/7.1.1/PBIThumbnailCreator/pbicreator.cpp 2010-02-24 18:12:00 UTC (rev 6297)
+++ pcbsd/branches/7.1.1/PBIThumbnailCreator/pbicreator.cpp 2010-02-24 18:17:23 UTC (rev 6298)
@@ -25,6 +25,7 @@
#include <QImage>
#include <QTextStream>
#include <QFile>
+#include <QDebug>
#include <kdebug.h>
#include "pbicreator.h"
@@ -43,11 +44,16 @@
QTextStream stream(&file);
stream.setCodec("ISO 8859-1");
+ //stream.setCodec("UTF-8");
+ stream.setAutoDetectUnicode(false);
bool inIcon = false;
qint64 startPos = 0;
qint64 finishPos = 0;
+ qint64 curFilePos = 0;
QString line;
+ qDebug() << "Looking for icon in PBI: " << path;
+
while (!stream.atEnd())
{
while (inIcon)
@@ -56,6 +62,8 @@
if (line == "__PBI_ARCHIVE__")
{
+ finishPos = curFilePos;
+
file.seek(startPos);
QByteArray ba;
qint64 size = finishPos - startPos;
@@ -63,19 +71,28 @@
ba = file.read(size);
file.close();
img.loadFromData(ba);
+ qDebug() << "Loaded PBI icon - Success!";
return true;
}
- finishPos = stream.pos();
+ curFilePos += line.length() + 1;
+
+ if ( stream.atEnd() ) {
+ qDebug() << "Loaded PBI icon - Failed!";
+ return false;
+ }
+
}
line = stream.readLine();
+ curFilePos += line.length() + 1;
- if (line == "__PBI_ICON__")
- {
+ if (line == "__PBI_ICON__") {
inIcon = true;
- startPos = stream.pos();
+ startPos = curFilePos;
+ } else if (line == "__PBI_ICON__") {
+ return false; //If we got here, there isn't a custom icon. Bail out ASAP.
}
- else if (line == "__PBI_ICON__") return false; //If we got here, there isn't a custom icon. Bail out ASAP.
+
}
file.close();
return false;
More information about the Commits
mailing list