changeset:   19462:e403ac6f4c7d
branch:      gui-release
tag:         popen
tag:         qbase
tag:         qtip
tag:         tip
user:        Torsten <ttl@justmail.de>
date:        Sat Jan 03 09:51:47 2015 +0100
summary:     fix unzipping compressed info files when running the gui (bug #38305)

diff -r 17e6c770e6ac -r e403ac6f4c7d libgui/src/qtinfo/parser.cc
--- a/libgui/src/qtinfo/parser.cc	Fri Jan 02 18:47:29 2015 +0100
+++ b/libgui/src/qtinfo/parser.cc	Sat Jan 03 09:51:47 2015 +0100
@@ -96,13 +96,19 @@
   QIODevice *iodevice = 0;
   if ( _compressors_map.contains(file_info.suffix ()))
     {
-      QProcess gzip;
-      gzip.start (_compressors_map.value (file_info.suffix ()).arg (file_info.absoluteFilePath ()));
-
-      if (!gzip.waitForFinished ())
+      QString command = _compressors_map.value (file_info.suffix ()).
+                        arg (file_info.absoluteFilePath ());
+      FILE *fpipe;
+      if (! (fpipe =
+             static_cast <FILE *>(popen (command.toStdString ().data (), "r"))))
         return 0;
 
-      QByteArray result = gzip.readAll ();
+      QByteArray result;
+      char buffer[1024];
+      while (fgets (buffer, sizeof buffer, fpipe))
+        result.append (buffer);
+
+      pclose(fpipe);
 
       QBuffer *io = new QBuffer (this);
       io->setData (result);

