[PC-BSD Commits] r6287 - pcbsd/trunk/PBIThumbnailCreator

svn at pcbsd.org svn at pcbsd.org
Tue Feb 23 12:34:47 PST 2010


Author: kris
Date: 2010-02-23 12:34:47 -0800 (Tue, 23 Feb 2010)
New Revision: 6287

Modified:
   pcbsd/trunk/PBIThumbnailCreator/pbicreator.cpp
Log:

Fixed a bug causing kdeinit4 processes to go out of control when previewing a PBI icon:

Had to re-write code with a work-around, QTextStream pos() doesn't work reliably anymore in 4.6, just sits there
re-reading some of the same data over and over :(



Modified: pcbsd/trunk/PBIThumbnailCreator/pbicreator.cpp
===================================================================
--- pcbsd/trunk/PBIThumbnailCreator/pbicreator.cpp	2010-02-23 10:00:32 UTC (rev 6286)
+++ pcbsd/trunk/PBIThumbnailCreator/pbicreator.cpp	2010-02-23 20:34:47 UTC (rev 6287)
@@ -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