- Timestamp:
- Aug 13, 2008 1:08:27 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxGlobal.h
r10728 r11387 35 35 #include <QMenu> 36 36 #include <QStyle> 37 #include <QProcess> 37 38 38 39 class QAction; … … 160 161 161 162 const QString mLangId; 163 }; 164 165 class Process : public QProcess 166 { 167 Q_OBJECT; 168 169 public: 170 171 static QByteArray singleShot (const QString &aProcessName, 172 int aTimeout = 5000 173 /* wait for data maximum 5 seconds */) 174 { 175 /* Why is it really needed is because of Qt4.3 bug with QProcess. 176 * This bug is about QProcess sometimes (~70%) do not receive 177 * notification about process was finished, so this makes 178 * 'bool QProcess::waitForFinished (int)' block the GUI thread and 179 * never dismissed with 'true' result even if process was really 180 * started&finished. So we just waiting for some information 181 * on process output and destroy the process with force. Due to 182 * QProcess::~QProcess() has the same 'waitForFinished (int)' blocker 183 * we have to change process state to QProcess::NotRunning. */ 184 185 QByteArray result; 186 Process process; 187 process.start (aProcessName); 188 bool firstShotReady = process.waitForReadyRead (aTimeout); 189 if (firstShotReady) 190 result = process.readAllStandardOutput(); 191 process.setProcessState (QProcess::NotRunning); 192 return result; 193 } 194 195 protected: 196 197 Process (QWidget *aParent = 0) : QProcess (aParent) {} 162 198 }; 163 199
Note:
See TracChangeset
for help on using the changeset viewer.