VirtualBox

Changeset 71402 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 20, 2018 1:43:07 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9049: Small cleanup for QIProcess.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/extensions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIProcess.cpp

    r69500 r71402  
    55
    66/*
    7  * Copyright (C) 2006-2017 Oracle Corporation
     7 * Copyright (C) 2006-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1919# include <precomp.h>
    2020#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
     21
    2122/* GUI includes: */
    2223# include "QIProcess.h"
     24
    2325#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    2426
     
    2628#ifdef VBOX_WS_X11
    2729# include <sys/wait.h>
    28 #endif /* VBOX_WS_X11 */
     30#endif
    2931
    3032
     33QIProcess::QIProcess(QObject *pParent /* = 0 */)
     34    : QProcess(pParent)
     35{
     36}
     37
    3138/* static */
    32 QByteArray QIProcess::singleShot(const QString &strProcessName, int iTimeout)
     39QByteArray QIProcess::singleShot(const QString &strProcessName, int iTimeout /* = 5000 */)
    3340{
    34     /* Why is it really needed is because of Qt4.3 bug with QProcess.
    35      * This bug is about QProcess sometimes (~70%) do not receive
    36      * notification about process was finished, so this makes
    37      * 'bool QProcess::waitForFinished (int)' block the GUI thread and
    38      * never dismissed with 'true' result even if process was really
    39      * started&finished. So we just waiting for some information
    40      * on process output and destroy the process with force. Due to
    41      * QProcess::~QProcess() has the same 'waitForFinished (int)' blocker
    42      * we have to change process state to QProcess::NotRunning. */
     41    // WORKAROUND:
     42    // Why is it really needed is because of Qt4.3 bug with QProcess.
     43    // This bug is about QProcess sometimes (~70%) do not receive
     44    // notification about process was finished, so this makes
     45    // 'bool QProcess::waitForFinished (int)' block the GUI thread and
     46    // never dismissed with 'true' result even if process was really
     47    // started&finished. So we just waiting for some information
     48    // on process output and destroy the process with force. Due to
     49    // QProcess::~QProcess() has the same 'waitForFinished (int)' blocker
     50    // we have to change process state to QProcess::NotRunning.
    4351
     52    /// @todo Do we still need this?
    4453    QByteArray result;
    4554    QIProcess process;
     
    5766}
    5867
    59 QIProcess::QIProcess(QObject *pParent /* = 0 */)
    60     : QProcess(pParent)
    61 {
    62 }
    63 
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIProcess.h

    r69500 r71402  
    55
    66/*
    7  * Copyright (C) 2006-2017 Oracle Corporation
     7 * Copyright (C) 2006-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef __QIProcess_h__
    19 #define __QIProcess_h__
     18#ifndef ___QIProcess_h___
     19#define ___QIProcess_h___
    2020
    2121/* Qt includes: */
    2222#include <QProcess>
    2323
    24 /* QProcess reimplementation for VBox GUI needs: */
     24/** QProcess extension for VBox GUI needs. */
    2525class QIProcess : public QProcess
    2626{
    2727    Q_OBJECT;
    2828
     29    /** Constructs our own file-dialog passing @a pParent to the base-class.
     30      * Doesn't mean to be used directly, cause this subclass is a bunch of statics. */
     31    QIProcess(QObject *pParent = 0);
     32
    2933public:
    3034
    31     /* Static single-shot method to execute some script: */
     35    /** Execute certain script specified by @a strProcessName
     36      * and wait up to specified @a iTimeout amount of time for responce. */
    3237    static QByteArray singleShot(const QString &strProcessName,
    33                                  int iTimeout = 5000 /* wait for data maximum 5 seconds */);
    34 
    35 protected:
    36 
    37     /* Constructor: */
    38     QIProcess(QObject *pParent = 0);
     38                                 int iTimeout = 5000);
    3939};
    4040
    41 #endif /* __QIProcess_h__ */
     41#endif /* !___QIProcess_h___ */
    4242
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette