VirtualBox

Changeset 103491 in vbox


Ignore:
Timestamp:
Feb 21, 2024 12:36:24 PM (9 months ago)
Author:
vboxsync
Message:

VBoxDbg: Fixed console output performance troubles caused by 'Courier [Monospace]' on Windows, changing the default font to the system's default fixed font and dropping the '[Monospace]' from the family. Also an disabled experiment switching to QPlainTextEdit. bugref:10604

Location:
trunk/src/VBox/Debugger
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/VBoxDbgConsole.cpp

    r101107 r103491  
    3434#include "VBoxDbgGui.h"
    3535
     36#include <QAction>
     37#include <QApplication>
     38#include <QContextMenuEvent>
     39#include <QFont>
     40#include <QFontDatabase>
     41#include <QHBoxLayout>
    3642#include <QLabel>
    37 #include <QApplication>
    38 #include <QFont>
    3943#include <QLineEdit>
    40 #include <QHBoxLayout>
    41 #include <QAction>
    42 #include <QContextMenuEvent>
    4344#include <QMenu>
    4445#include <QScrollBar>
     
    7475VBoxDbgConsoleOutput::VBoxDbgConsoleOutput(QWidget *pParent/* = NULL*/, IVirtualBox *a_pVirtualBox /* = NULL */,
    7576                                           const char *pszName/* = NULL*/)
    76     : QTextEdit(pParent), m_uCurLine(0), m_uCurPos(0), m_hGUIThread(RTThreadNativeSelf()), m_pVirtualBox(a_pVirtualBox)
     77#ifdef VBOXDBG_WITH_CONSOLE_OUTPUT_AS_QPLAINTEXT
     78    : QPlainTextEdit(pParent)
     79#else
     80    : QTextEdit(pParent)
     81#endif
     82    , m_uCurLine(0)
     83    , m_uCurPos(0)
     84    , m_hGUIThread(RTThreadNativeSelf())
     85    , m_pVirtualBox(a_pVirtualBox)
    7786{
    7887    setReadOnly(true);
     
    8190    setPlainText("");
    8291    setTextInteractionFlags(Qt::TextBrowserInteraction);
     92    setTabChangesFocus(true);
     93#ifndef VBOXDBG_WITH_CONSOLE_OUTPUT_AS_QPLAINTEXT
    8394    setAutoFormatting(QTextEdit::AutoAll);
    84     setTabChangesFocus(true);
    8595    setAcceptRichText(false);
     96#endif
     97#if 0 /* @bugref{10604}: this doesn't really help with the performance issue. */
     98    setWordWrapMode(QTextOption::NoWrap);
     99# ifndef VBOXDBG_WITH_CONSOLE_OUTPUT_AS_QPLAINTEXT
     100    setLineWrapMode(QPlainTextEdit::NoWrap);
     101# endif
     102#endif
    86103
    87104    /*
     
    109126     * Create actions for font menu items.
    110127     */
     128    m_pDefaultFontAction = new QAction(tr("Default Fixed Font"), this);
     129    m_pDefaultFontAction->setCheckable(true);
     130    m_pDefaultFontAction->setData((int)kFontType_SystemDefault);
     131    connect(m_pDefaultFontAction, SIGNAL(triggered()), this, SLOT(sltSelectFontType()));
     132
    111133    m_pCourierFontAction = new QAction(tr("Courier"), this);
    112134    m_pCourierFontAction->setCheckable(true);
    113     m_pCourierFontAction->setShortcut(QString("Ctrl+D"));
    114135    m_pCourierFontAction->setData((int)kFontType_Courier);
    115136    connect(m_pCourierFontAction, SIGNAL(triggered()), this, SLOT(sltSelectFontType()));
     
    117138    m_pMonospaceFontAction = new QAction(tr("Monospace"), this);
    118139    m_pMonospaceFontAction->setCheckable(true);
    119     m_pMonospaceFontAction->setShortcut(QString("Ctrl+M"));
    120140    m_pMonospaceFontAction->setData((int)kFontType_Monospace);
    121141    connect(m_pMonospaceFontAction, SIGNAL(triggered()), this, SLOT(sltSelectFontType()));
     
    123143    /* Create action group for grouping of exclusive font menu items. */
    124144    QActionGroup *pActionFontGroup = new QActionGroup(this);
     145    pActionFontGroup->addAction(m_pDefaultFontAction);
    125146    pActionFontGroup->addAction(m_pCourierFontAction);
    126147    pActionFontGroup->addAction(m_pMonospaceFontAction);
     
    148169     */
    149170    /* color scheme: */
     171    setColorScheme(kGreenOnBlack, false /*fSaveIt*/);
    150172    com::Bstr bstrColor;
    151173    HRESULT hrc = m_pVirtualBox ? m_pVirtualBox->GetExtraData(com::Bstr("DbgConsole/ColorScheme").raw(), bstrColor.asOutParam()) : E_FAIL;
    152     if (  SUCCEEDED(hrc)
    153         && bstrColor.compareUtf8("blackonwhite", com::Bstr::CaseInsensitive) == 0)
    154         setColorScheme(kBlackOnWhite, false /*fSaveIt*/);
    155     else
    156         setColorScheme(kGreenOnBlack, false /*fSaveIt*/);
     174    if (SUCCEEDED(hrc))
     175    {
     176        if (bstrColor.compareUtf8("blackonwhite", com::Bstr::CaseInsensitive) == 0)
     177            setColorScheme(kBlackOnWhite, false /*fSaveIt*/);
     178    }
    157179
    158180    /* font: */
     181    setFontType(kFontType_SystemDefault, false /*fSaveIt*/);
    159182    com::Bstr bstrFont;
    160183    hrc = m_pVirtualBox ? m_pVirtualBox->GetExtraData(com::Bstr("DbgConsole/Font").raw(), bstrFont.asOutParam()) : E_FAIL;
    161     if (  SUCCEEDED(hrc)
    162         && bstrFont.compareUtf8("monospace", com::Bstr::CaseInsensitive) == 0)
    163         setFontType(kFontType_Monospace, false /*fSaveIt*/);
    164     else
    165         setFontType(kFontType_Courier, false /*fSaveIt*/);
     184    if (SUCCEEDED(hrc))
     185    {
     186        if (bstrFont.compareUtf8("monospace", com::Bstr::CaseInsensitive) == 0)
     187            setFontType(kFontType_Monospace, false /*fSaveIt*/);
     188        else if (bstrFont.compareUtf8("courier", com::Bstr::CaseInsensitive) == 0)
     189            setFontType(kFontType_Courier, false /*fSaveIt*/);
     190    }
    166191
    167192    /* font size: */
     
    206231
    207232    QMenu *pFontMenu = pMenu->addMenu(tr("&Font Family"));
     233    pFontMenu->addAction(m_pDefaultFontAction);
    208234    pFontMenu->addAction(m_pCourierFontAction);
    209235    pFontMenu->addAction(m_pMonospaceFontAction);
     
    259285    switch (enmFontType)
    260286    {
     287        case kFontType_SystemDefault:
     288            Font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
     289            pszSetting = "Default";
     290            pAction = m_pDefaultFontAction;
     291            break;
     292
    261293        case kFontType_Courier:
     294        {
    262295#ifdef Q_WS_MAC
    263296            Font = QFont("Monaco", Font.pointSize(), QFont::Normal, FALSE);
    264297            Font.setStyleStrategy(QFont::NoAntialias);
    265298#else
     299            Font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
    266300            Font.setStyleHint(QFont::TypeWriter);
    267             Font.setFamily("Courier [Monotype]");
     301            Font.setStyleStrategy(QFont::PreferAntialias);
     302            QStringList Families;
     303# ifdef Q_WS_MAC
     304            Families << "Monaco";
     305# endif
     306            /*Families << "Courier New [Monotype]"; - this causes peformance trouble (@bugref{10604}) */
     307            Families << "Courier New";
     308            /*Families << "Courier [Monotype]"; - this causes peformance trouble (@bugref{10604}) */
     309            Families << "Courier";
     310            Font.setFamilies(Families);
    268311#endif
    269312            pszSetting = "Courier";
    270313            pAction = m_pCourierFontAction;
    271314            break;
     315        }
    272316
    273317        case kFontType_Monospace:
    274             Font.setStyleHint(QFont::TypeWriter);
     318            Font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
     319            Font.setStyleHint(QFont::Monospace);
    275320            Font.setStyleStrategy(QFont::PreferAntialias);
    276321            Font.setFamily("Monospace [Monotype]");
  • trunk/src/VBox/Debugger/VBoxDbgConsole.h

    r98103 r103491  
    3232#endif
    3333
     34//#define VBOXDBG_WITH_CONSOLE_OUTPUT_AS_QPLAINTEXT
     35
    3436#include "VBoxDbgBase.h"
    3537
    3638#include <QTextEdit>
     39#ifdef VBOXDBG_WITH_CONSOLE_OUTPUT_AS_QPLAINTEXT
     40# include <QPlainTextEdit>
     41#endif
    3742#include <QComboBox>
    3843#include <QTimer>
     
    5358
    5459
    55 class VBoxDbgConsoleOutput : public QTextEdit
     60class VBoxDbgConsoleOutput
     61#ifdef VBOXDBG_WITH_CONSOLE_OUTPUT_AS_QPLAINTEXT
     62    : public QPlainTextEdit
     63#else
     64    : public QTextEdit
     65#endif
    5666{
    5767    Q_OBJECT
     
    8999    QAction *m_pGreenOnBlackAction;
    90100
     101    /** The action to switch to system default fixed font. */
     102    QAction *m_pDefaultFontAction;
     103    /** The action to switch to Monospace font. */
     104    QAction *m_pMonospaceFontAction;
    91105    /** The action to switch to Courier font. */
    92106    QAction *m_pCourierFontAction;
    93     /** The action to switch to Monospace font. */
    94     QAction *m_pMonospaceFontAction;
    95107
    96108protected:
    97109    typedef enum  { kGreenOnBlack, kBlackOnWhite } VBoxDbgConsoleColor;
    98     typedef enum  { kFontType_Monospace, kFontType_Courier } VBoxDbgConsoleFontType;
     110    typedef enum  { kFontType_SystemDefault, kFontType_Monospace, kFontType_Courier } VBoxDbgConsoleFontType;
    99111
    100112    /**
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