[PC-BSD Commits] r21942 - pcbsd/current/src-qt4/pc-mounttray

svn at pcbsd.org svn at pcbsd.org
Thu Mar 21 16:39:28 PDT 2013


Author: kenmoore
Date: 2013-03-21 23:39:27 +0000 (Thu, 21 Mar 2013)
New Revision: 21942

Modified:
   pcbsd/current/src-qt4/pc-mounttray/menuItem.cpp
   pcbsd/current/src-qt4/pc-mounttray/menuItem.h
Log:
Also fix the mounttray size display. Need to use a process environment with a fixed 1K blocksize to make sure the calculations are correct.



Modified: pcbsd/current/src-qt4/pc-mounttray/menuItem.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/menuItem.cpp	2013-03-21 22:49:47 UTC (rev 21941)
+++ pcbsd/current/src-qt4/pc-mounttray/menuItem.cpp	2013-03-21 23:39:27 UTC (rev 21942)
@@ -288,10 +288,11 @@
   bool ok = FALSE;
   if(isMounted()){
     QString cmd = "df "+mountpoint;
-    QStringList output = Utils::runShellCommand(cmd);
+    QStringList output = systemCMD(cmd); //make sure we use the one with a 1K blocksize
     if(output.length() > 1){
       //parse the output (1K blocks) and save them
       QString line = output[1].replace("\t"," ");
+      qDebug() << "df output:" << output << cmd;
       maxSize = line.section(" ",1,1,QString::SectionSkipEmpty).simplified();
       currentSize = line.section(" ",2,2,QString::SectionSkipEmpty).simplified();
       ok=TRUE;
@@ -310,6 +311,9 @@
     currentSpace->setVisible(TRUE);
     //display the actual size available in the tooltip
     QString diskAvailable = getSizeDisplay( maxSize.toInt() - currentSize.toInt() );
+    qDebug() << "MaxSize:" << maxSize << maxSize.toInt();
+    qDebug() << "CurrentSize:" << currentSize << currentSize.toInt();
+    qDebug() << "Disk Available:" << diskAvailable;
     currentSpace->setToolTip( QString( tr("%1 of disk space available") ).arg(diskAvailable) );
   }else{
     currentSpace->setVisible(FALSE);
@@ -328,3 +332,24 @@
   }
 	
 }
+
+QStringList MenuItem::systemCMD(QString command){ 
+   QProcess p;
+   QString outstr;
+   //Make sure we use the system environment to properly read system variables, etc.
+   QProcessEnvironment penv = QProcessEnvironment::systemEnvironment();
+   penv.insert("BLOCKSIZE","K"); //make sure we use a 1KB block size
+   p.setProcessEnvironment(penv);
+   //Merge the output channels to retrieve all output possible
+   p.setProcessChannelMode(QProcess::MergedChannels);   
+   p.start(command);
+   while(p.state()==QProcess::Starting || p.state() == QProcess::Running){
+     p.waitForFinished(200);
+     QCoreApplication::processEvents();
+   }
+   QString tmp = p.readAllStandardOutput();
+   outstr.append(tmp);
+   if(outstr.endsWith("\n")){outstr.chop(1);} //remove the newline at the end 
+   QStringList out = outstr.split("\n");
+   return out;
+}

Modified: pcbsd/current/src-qt4/pc-mounttray/menuItem.h
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/menuItem.h	2013-03-21 22:49:47 UTC (rev 21941)
+++ pcbsd/current/src-qt4/pc-mounttray/menuItem.h	2013-03-21 23:39:27 UTC (rev 21942)
@@ -62,6 +62,7 @@
         void updateSizes();
         QString getSizeDisplay(int);
         bool checkSavedAutoMount();
+        QStringList systemCMD(QString);
   	
   private slots:
   	void slotMountClicked();



More information about the Commits mailing list