VirtualBox

Changeset 237 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 23, 2007 1:14:04 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
17763
Message:

FE/Qt: Implemented preliminary support for IConsole runtime error notifications in the VM console window.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h

    r1 r237  
    150150        EnumerateMediaEventType = QEvent::User + 100,
    151151        ActivateMenuEventType = QEvent::User + 101,
     152        RuntimeErrorEventType = QEvent::User + 102,
    152153    };
    153154};
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h

    r86 r237  
    192192                                     const QString &hostKey);
    193193
     194    void showRuntimeError (const CConsole &console, bool fatal,
     195                           const QString &errorID,
     196                           const QString &errorMsg);
     197
    194198    static QString highlight (const QString &str);
    195199    static QString formatErrorInfo (const COMErrorInfo &info,
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r177 r237  
    123123        if (data) delete[] data;
    124124    }
    125     bool isVisible() { return vis; }
    126     bool hasAlpha() { return alph; }
    127     uint xHot() { return xh; }
    128     uint yHot() { return yh; }
    129     uint width() { return w; }
    130     uint height() { return h; }
    131     const uchar *shapeData() { return data; }
     125    bool isVisible() const { return vis; }
     126    bool hasAlpha() const { return alph; }
     127    uint xHot() const { return xh; }
     128    uint yHot() const { return yh; }
     129    uint width() const { return w; }
     130    uint height() const { return h; }
     131    const uchar *shapeData() const { return data; }
    132132private:
    133133    bool vis, alph;
     
    144144        can_abs (supportsAbsolute),
    145145        needs_host_cursor (needsHostCursor) {}
    146     bool supportsAbsolute() { return can_abs; }
    147     bool needsHostCursor() { return needs_host_cursor; }
     146    bool supportsAbsolute() const { return can_abs; }
     147    bool needsHostCursor() const { return needs_host_cursor; }
    148148private:
    149149    bool can_abs;
     
    158158        QEvent ((QEvent::Type) VBoxDefs::MachineStateChangeEventType),
    159159        s (state) {}
    160     CEnums::MachineState machineState() { return s; }
     160    CEnums::MachineState machineState() const { return s; }
    161161private:
    162162    CEnums::MachineState s;
     
    170170        QEvent ((QEvent::Type) VBoxDefs::ActivateMenuEventType),
    171171        md (menuData), i (index) {}
    172     QMenuData *menuData() { return md; }
    173     uint index() { return i; }
     172    QMenuData *menuData() const { return md; }
     173    uint index() const { return i; }
    174174private:
    175175    QMenuData *md;
    176176    uint i;
     177};
     178
     179/** VM Runtime error event */
     180class RuntimeErrorEvent : public QEvent
     181{
     182public:
     183    RuntimeErrorEvent (bool aFatal, const QString &aErrorID,
     184                       const QString &aMessage) :
     185        QEvent ((QEvent::Type) VBoxDefs::RuntimeErrorEventType),
     186        mFatal (aFatal), mErrorID (aErrorID), mMessage (aMessage) {}
     187    bool fatal() const { return mFatal; }
     188    QString errorID() const { return mErrorID; }
     189    QString message() const { return mMessage; }
     190private:
     191    bool mFatal;
     192    QString mErrorID;
     193    QString mMessage;
    177194};
    178195
     
    264281    {
    265282        /** @todo */
    266         Q_UNUSED( fNumLock );
    267         Q_UNUSED( fScrollLock );
    268         Q_UNUSED( fCapsLock );
     283        Q_UNUSED (fNumLock);
     284        Q_UNUSED (fScrollLock);
     285        Q_UNUSED (fCapsLock);
    269286        return S_OK;
    270287    }
    271288
    272     STDMETHOD(OnRuntimeError)(BOOL /*fatal*/, IN_BSTRPARAM /*id*/, IN_BSTRPARAM /*message*/)
    273     {
     289    STDMETHOD(OnRuntimeError)(BOOL fatal, IN_BSTRPARAM id, IN_BSTRPARAM message)
     290    {
     291        QApplication::postEvent (
     292            view, new RuntimeErrorEvent (!!fatal, QString::fromUcs2 (id),
     293                                         QString::fromUcs2 (message)));
    274294        return S_OK;
    275295    }
     
    286306
    287307#if !defined (Q_WS_WIN)
    288 NS_DECL_CLASSINFO( VBoxConsoleCallback )
    289 NS_IMPL_THREADSAFE_ISUPPORTS1_CI( VBoxConsoleCallback, IConsoleCallback )
     308NS_DECL_CLASSINFO (VBoxConsoleCallback)
     309NS_IMPL_THREADSAFE_ISUPPORTS1_CI (VBoxConsoleCallback, IConsoleCallback)
    290310#endif
    291311
     
    774794                    mainwnd->statusBar()->clear();
    775795
     796                return true;
     797            }
     798
     799            case VBoxDefs::RuntimeErrorEventType:
     800            {
     801                RuntimeErrorEvent *ee = (RuntimeErrorEvent *) e;
     802                vboxProblem().showRuntimeError (cconsole, ee->fatal(),
     803                                                ee->errorID(), ee->message());
    776804                return true;
    777805            }
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r141 r237  
    12651265}
    12661266
    1267 // static
     1267void VBoxProblemReporter::showRuntimeError (const CConsole &aConsole, bool fatal,
     1268                                            const QString &errorID,
     1269                                            const QString &errorMsg)
     1270{
     1271    /// @todo (r=dmik) it's just a preliminary box. We need to:
     1272    //  - for fatal errors and non-fatal with-retry errors, listen for a
     1273    //    VM state signal to automatically close the message if the VM
     1274    //    (externally) leaves the Paused state while it is shown.
     1275    //  - make warning messages modeless
     1276    //  - add common buttons like Retry/Save/PowerOff/whatever
     1277
     1278    CConsole console = aConsole;
     1279    CEnums::MachineState state = console.GetState();
     1280    Type type;
     1281    QString severity;
     1282
     1283    if (fatal)
     1284    {
     1285        /* the machine must be paused on fatal errors */
     1286        Assert (state == CEnums::Paused);
     1287        if (state != CEnums::Paused)
     1288            console.Pause();
     1289        type = Critical;
     1290        severity = tr ("Fatal Error", "runtime error info");
     1291    }
     1292    else if (state == CEnums::Paused)
     1293    {
     1294        type = Error;
     1295        severity = tr ("Non-Fatal Error", "runtime error info");
     1296    }
     1297    else
     1298    {
     1299        type = Warning;
     1300        severity = tr ("Warning", "runtime error info");
     1301    }
     1302   
     1303    QString formatted;
     1304
     1305    if (!errorMsg.isEmpty())
     1306        formatted += QString ("<table bgcolor=#FFFFFF border=0 cellspacing=0 "
     1307                              "cellpadding=0 width=100%>"
     1308                              "<tr><td><p>%1.</p></td></tr>"
     1309                              "</table><p></p>")
     1310                              .arg (highlight (errorMsg));
     1311
     1312    if (!errorID.isEmpty())
     1313        formatted += QString ("<table bgcolor=#EEEEEE border=0 cellspacing=0 "
     1314                              "cellpadding=0 width=100%>"
     1315                              "<tr><td>%1</td><td>%2</td></tr>"
     1316                              "<tr><td>%3</td><td>%4</td></tr>"
     1317                              "</table>")
     1318                              .arg (tr ("Error ID: ", "runtime error info"),
     1319                                    errorID)
     1320                              .arg (tr ("Error Severity: ", "runtime error info"),
     1321                                    severity);
     1322   
     1323    if (!formatted.isEmpty())
     1324        formatted = "<qt>" + formatted + "</qt>";
     1325 
     1326    int rc = 0;
     1327
     1328    if (type == Critical)
     1329    {
     1330        rc = message (&vboxGlobal().consoleWnd(), type,
     1331            tr ("<p>A fatal error has occured during virtual machine execution! "
     1332                "The virtual machine will be powered off. It is suggested to "
     1333                "use the clipboard to copy the following error message for "
     1334                "further examination:</p>"),
     1335            formatted);
     1336       
     1337        /* always power down after a fatal error */
     1338        console.PowerDown();
     1339    }
     1340    else if (type == Error)
     1341    {
     1342        rc = message (&vboxGlobal().consoleWnd(), type,
     1343            tr ("<p>An error has occured during virtual machine execution! "
     1344                "The error details are shown below. You can try to correct "
     1345                "the described error and resume the virtual machine "
     1346                "execution.</p>"),
     1347            formatted);
     1348    }
     1349    else
     1350    {
     1351        rc = message (&vboxGlobal().consoleWnd(), type,
     1352            tr ("<p>The virtual machine execution may run into an error "
     1353                "condition as described below. "
     1354                "You may ignore this message, but it is suggested to perform "
     1355                "an appropriate action to make sure the described error will "
     1356                "not happen.</p>"),
     1357            formatted);
     1358    }
     1359
     1360    NOREF(rc);
     1361}
     1362
     1363/* static */
    12681364QString VBoxProblemReporter::highlight (const QString &str)
    12691365{
    12701366    QString text = str;
    1271     // mark strings in single quotes with color
     1367    /* mark strings in single quotes with color */
    12721368    QRegExp rx = QRegExp ("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))");
    12731369    rx.setMinimal (true);
    12741370    text.replace (rx, "\\1'<font color=#0000CC>\\2</font>'");
    1275     // mark UUIDs with color
     1371    /* mark UUIDs with color */
    12761372    text.replace (QRegExp (
    12771373        "((?:^|\\s)[(]?)"
     
    12791375        "(?=[:.-!);]?(?:\\s|$))"),
    12801376        "\\1<font color=#008000>\\2</font>");
    1281     // split to paragraphs at \n chars
     1377    /* split to paragraphs at \n chars */
    12821378    text.replace ('\n', "</p><p>");
    12831379    return text;
    12841380}
    12851381
    1286 // static
     1382/* static */
    12871383QString VBoxProblemReporter::formatErrorInfo (const COMErrorInfo &info,
    12881384                                              HRESULT wrapperRC)
     
    13771473#endif
    13781474    }
    1379     formatted += "</table></font></qt>";
     1475    formatted += "</table></qt>";
    13801476
    13811477    return formatted;
Note: See TracChangeset for help on using the changeset viewer.

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