VirtualBox

Changeset 92328 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 10, 2021 3:29:30 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: Continuing with r148038; Deallocating QItemEditorFactory instances in various places to fix small leakages.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIShortcutConfigurationEditor.cpp

    r88441 r92328  
    310310      * @param  strObjectName  Brings the object name this table has, required for fast referencing. */
    311311    UIShortcutConfigurationTable(QWidget *pParent, UIShortcutConfigurationModel *pModel, const QString &strObjectName);
     312    /** Destructs table. */
     313    virtual ~UIShortcutConfigurationTable() /* override */;
    312314
    313315protected:
     
    327329    /** Prepares all. */
    328330    void prepare();
     331    /** Cleanups all. */
     332    void cleanup();
     333
     334    /** Holds the item editor factory instance. */
     335    QItemEditorFactory *m_pItemEditorFactory;
    329336};
    330337
     
    699706                                                           const QString &strObjectName)
    700707    : QITableView(pParent)
     708    , m_pItemEditorFactory(0)
    701709{
    702710    /* Set object name: */
     
    707715    /* Prepare all: */
    708716    prepare();
     717}
     718
     719UIShortcutConfigurationTable::~UIShortcutConfigurationTable()
     720{
     721    /* Cleanup all: */
     722    cleanup();
    709723}
    710724
     
    761775
    762776        /* Create new item editor factory: */
    763         QItemEditorFactory *pNewItemEditorFactory = new QItemEditorFactory;
    764         if (pNewItemEditorFactory)
     777        m_pItemEditorFactory = new QItemEditorFactory;
     778        if (m_pItemEditorFactory)
    765779        {
    766780            /* Register UIHotKeyEditor as the UIHotKey editor: */
    767781            int iHotKeyTypeId = qRegisterMetaType<UIHotKey>();
    768782            QStandardItemEditorCreator<UIHotKeyEditor> *pHotKeyItemEditorCreator = new QStandardItemEditorCreator<UIHotKeyEditor>();
    769             pNewItemEditorFactory->registerEditor((QVariant::Type)iHotKeyTypeId, pHotKeyItemEditorCreator);
     783            m_pItemEditorFactory->registerEditor((QVariant::Type)iHotKeyTypeId, pHotKeyItemEditorCreator);
    770784
    771785            /* Register UIHostComboEditor as the UIHostComboWrapper editor: */
    772786            int iHostComboTypeId = qRegisterMetaType<UIHostComboWrapper>();
    773787            QStandardItemEditorCreator<UIHostComboEditor> *pHostComboItemEditorCreator = new QStandardItemEditorCreator<UIHostComboEditor>();
    774             pNewItemEditorFactory->registerEditor((QVariant::Type)iHostComboTypeId, pHostComboItemEditorCreator);
     788            m_pItemEditorFactory->registerEditor((QVariant::Type)iHostComboTypeId, pHostComboItemEditorCreator);
    775789
    776790            /* Assign configured item editor factory to item delegate: */
    777             pStyledItemDelegate->setItemEditorFactory(pNewItemEditorFactory);
    778         }
    779     }
     791            pStyledItemDelegate->setItemEditorFactory(m_pItemEditorFactory);
     792        }
     793    }
     794}
     795
     796void UIShortcutConfigurationTable::cleanup()
     797{
     798    /* Cleanup item editor factory: */
     799    delete m_pItemEditorFactory;
     800    m_pItemEditorFactory = 0;
    780801}
    781802
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIAddDiskEncryptionPasswordDialog.cpp

    r91029 r92328  
    163163      * @param  encryptedMedia  Brings the lists of medium ids (values) encrypted with passwords with ids (keys). */
    164164    UIEncryptionDataTable(const EncryptedMediumMap &encryptedMedia);
     165    /** Destructs table. */
     166    virtual ~UIEncryptionDataTable() /* override */;
    165167
    166168    /** Returns the shallow copy of the encryption password map
     
    175177    /** Prepares all. */
    176178    void prepare();
     179    /** Cleanups all. */
     180    void cleanup();
    177181
    178182    /** Holds the encrypted medium map reference. */
     
    181185    /** Holds the encryption-data model instance. */
    182186    UIEncryptionDataModel *m_pModelEncryptionData;
     187
     188    /** Holds the item editor factory instance. */
     189    QItemEditorFactory *m_pItemEditorFactory;
    183190};
    184191
     
    376383    : m_encryptedMedia(encryptedMedia)
    377384    , m_pModelEncryptionData(0)
    378 {
    379     /* Prepare: */
     385    , m_pItemEditorFactory(0)
     386{
    380387    prepare();
     388}
     389
     390UIEncryptionDataTable::~UIEncryptionDataTable()
     391{
     392    cleanup();
    381393}
    382394
     
    414426    if (pStyledItemDelegate)
    415427    {
    416         /* Create item editor factory: */
    417         QItemEditorFactory *pNewItemEditorFactory = new QItemEditorFactory;
    418         if (pNewItemEditorFactory)
    419         {
    420             /* Create item editor creator: */
     428        /* Create new item editor factory: */
     429        m_pItemEditorFactory = new QItemEditorFactory;
     430        if (m_pItemEditorFactory)
     431        {
     432            /* Register UIPasswordEditor as the QString editor: */
    421433            QStandardItemEditorCreator<UIPasswordEditor> *pQStringItemEditorCreator = new QStandardItemEditorCreator<UIPasswordEditor>();
    422434            if (pQStringItemEditorCreator)
    423             {
    424                 /* Register UIPasswordEditor as the QString editor: */
    425                 pNewItemEditorFactory->registerEditor(QVariant::String, pQStringItemEditorCreator);
    426             }
     435            m_pItemEditorFactory->registerEditor(QVariant::String, pQStringItemEditorCreator);
    427436
    428437            /* Assign configured item editor factory to table delegate: */
    429             pStyledItemDelegate->setItemEditorFactory(pNewItemEditorFactory);
     438            pStyledItemDelegate->setItemEditorFactory(m_pItemEditorFactory);
    430439        }
    431440
     
    454463    horizontalHeader()->setSectionResizeMode(UIEncryptionDataTableSection_Id, QHeaderView::Interactive);
    455464    horizontalHeader()->setSectionResizeMode(UIEncryptionDataTableSection_Password, QHeaderView::Stretch);
     465}
     466
     467void UIEncryptionDataTable::cleanup()
     468{
     469    /* Cleanup item editor factory: */
     470    delete m_pItemEditorFactory;
     471    m_pItemEditorFactory = 0;
    456472}
    457473
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFormEditorWidget.cpp

    r92151 r92328  
    13841384    , m_pTableView(0)
    13851385    , m_pTableModel(0)
     1386    , m_pItemEditorFactory(0)
    13861387{
    13871388    prepare();
     1389}
     1390
     1391UIFormEditorWidget::~UIFormEditorWidget()
     1392{
     1393    cleanup();
    13881394}
    13891395
     
    14941500
    14951501                    /* Create new item editor factory: */
    1496                     QItemEditorFactory *pNewItemEditorFactory = new QItemEditorFactory;
    1497                     if (pNewItemEditorFactory)
     1502                    m_pItemEditorFactory = new QItemEditorFactory;
     1503                    if (m_pItemEditorFactory)
    14981504                    {
    14991505                        /* Register TextEditor as the TextData editor: */
    15001506                        int iTextId = qRegisterMetaType<TextData>();
    15011507                        QStandardItemEditorCreator<TextEditor> *pTextEditorItemCreator = new QStandardItemEditorCreator<TextEditor>();
    1502                         pNewItemEditorFactory->registerEditor((QVariant::Type)iTextId, pTextEditorItemCreator);
     1508                        m_pItemEditorFactory->registerEditor((QVariant::Type)iTextId, pTextEditorItemCreator);
    15031509
    15041510                        /* Register ChoiceEditor as the ChoiceData editor: */
    15051511                        int iChoiceId = qRegisterMetaType<ChoiceData>();
    15061512                        QStandardItemEditorCreator<ChoiceEditor> *pChoiceEditorItemCreator = new QStandardItemEditorCreator<ChoiceEditor>();
    1507                         pNewItemEditorFactory->registerEditor((QVariant::Type)iChoiceId, pChoiceEditorItemCreator);
     1513                        m_pItemEditorFactory->registerEditor((QVariant::Type)iChoiceId, pChoiceEditorItemCreator);
    15081514
    15091515                        /* Register RangedIntegerEditor as the RangedIntegerData editor: */
    15101516                        int iRangedIntegerId = qRegisterMetaType<RangedIntegerData>();
    15111517                        QStandardItemEditorCreator<RangedIntegerEditor> *pRangedIntegerEditorItemCreator = new QStandardItemEditorCreator<RangedIntegerEditor>();
    1512                         pNewItemEditorFactory->registerEditor((QVariant::Type)iRangedIntegerId, pRangedIntegerEditorItemCreator);
     1518                        m_pItemEditorFactory->registerEditor((QVariant::Type)iRangedIntegerId, pRangedIntegerEditorItemCreator);
    15131519
    15141520                        /* Set newly created item editor factory for table delegate: */
    1515                         pStyledItemDelegate->setItemEditorFactory(pNewItemEditorFactory);
     1521                        pStyledItemDelegate->setItemEditorFactory(m_pItemEditorFactory);
    15161522                    }
    15171523                }
     
    15221528        }
    15231529    }
     1530}
     1531
     1532void UIFormEditorWidget::cleanup()
     1533{
     1534    delete m_pItemEditorFactory;
     1535    m_pItemEditorFactory = 0;
    15241536}
    15251537
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFormEditorWidget.h

    r92165 r92328  
    3232/* Forward declarations: */
    3333class QHeaderView;
     34class QItemEditorFactory;
    3435class UIFormEditorModel;
    3536class UIFormEditorView;
     
    4849      * @param  pNotificationCenter  Brings the notification-center this widget should report to. */
    4950    UIFormEditorWidget(QWidget *pParent = 0, UINotificationCenter *pNotificationCenter = 0);
     51    /** Destructs Form Editor widget. */
     52    virtual ~UIFormEditorWidget() /* override */;
    5053
    5154    /** Returns the notification-center reference. */
     
    8083    /** Prepares all. */
    8184    void prepare();
     85    /** Cleanups all. */
     86    void cleanup();
    8287
    8388    /** Adjusts table column sizes. */
     
    9196    /** Holds the table-model instance. */
    9297    UIFormEditorModel *m_pTableModel;
     98
     99    /** Holds the item editor factory instance. */
     100    QItemEditorFactory *m_pItemEditorFactory;
    93101};
    94102
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPortForwardingTable.cpp

    r92207 r92328  
    792792    , m_pTableView(0)
    793793    , m_pToolBar(0)
    794     , m_pNewItemEditorFactory(0)
     794    , m_pItemEditorFactory(0)
    795795    , m_pTableModel(0)
    796796    , m_pActionAdd(0)
     
    798798    , m_pActionRemove(0)
    799799{
    800     /* Prepare: */
    801800    prepare();
    802801}
     
    804803UIPortForwardingTable::~UIPortForwardingTable()
    805804{
    806     delete m_pNewItemEditorFactory;
     805    cleanup();
    807806}
    808807
     
    11241123        {
    11251124            /* Create new item editor factory: */
    1126             m_pNewItemEditorFactory = new QItemEditorFactory;
    1127             if (m_pNewItemEditorFactory)
     1125            m_pItemEditorFactory = new QItemEditorFactory;
     1126            if (m_pItemEditorFactory)
    11281127            {
    11291128                /* Register NameEditor as the NameData editor: */
    11301129                int iNameId = qRegisterMetaType<NameData>();
    11311130                QStandardItemEditorCreator<NameEditor> *pNameEditorItemCreator = new QStandardItemEditorCreator<NameEditor>();
    1132                 m_pNewItemEditorFactory->registerEditor((QVariant::Type)iNameId, pNameEditorItemCreator);
     1131                m_pItemEditorFactory->registerEditor((QVariant::Type)iNameId, pNameEditorItemCreator);
    11331132
    11341133                /* Register ProtocolEditor as the KNATProtocol editor: */
    11351134                int iProtocolId = qRegisterMetaType<KNATProtocol>();
    11361135                QStandardItemEditorCreator<ProtocolEditor> *pProtocolEditorItemCreator = new QStandardItemEditorCreator<ProtocolEditor>();
    1137                 m_pNewItemEditorFactory->registerEditor((QVariant::Type)iProtocolId, pProtocolEditorItemCreator);
     1136                m_pItemEditorFactory->registerEditor((QVariant::Type)iProtocolId, pProtocolEditorItemCreator);
    11381137
    11391138                /* Register IPv4Editor/IPv6Editor as the IpData editor: */
     
    11421141                {
    11431142                    QStandardItemEditorCreator<IPv4Editor> *pIPv4EditorItemCreator = new QStandardItemEditorCreator<IPv4Editor>();
    1144                     m_pNewItemEditorFactory->registerEditor((QVariant::Type)iIpId, pIPv4EditorItemCreator);
     1143                    m_pItemEditorFactory->registerEditor((QVariant::Type)iIpId, pIPv4EditorItemCreator);
    11451144                }
    11461145                else
    11471146                {
    11481147                    QStandardItemEditorCreator<IPv6Editor> *pIPv6EditorItemCreator = new QStandardItemEditorCreator<IPv6Editor>();
    1149                     m_pNewItemEditorFactory->registerEditor((QVariant::Type)iIpId, pIPv6EditorItemCreator);
     1148                    m_pItemEditorFactory->registerEditor((QVariant::Type)iIpId, pIPv6EditorItemCreator);
    11501149                }
    11511150
     
    11531152                int iPortId = qRegisterMetaType<PortData>();
    11541153                QStandardItemEditorCreator<PortEditor> *pPortEditorItemCreator = new QStandardItemEditorCreator<PortEditor>();
    1155                 m_pNewItemEditorFactory->registerEditor((QVariant::Type)iPortId, pPortEditorItemCreator);
     1154                m_pItemEditorFactory->registerEditor((QVariant::Type)iPortId, pPortEditorItemCreator);
    11561155
    11571156                /* Set newly created item editor factory for table delegate: */
    1158                 pStyledItemDelegate->setItemEditorFactory(m_pNewItemEditorFactory);
     1157                pStyledItemDelegate->setItemEditorFactory(m_pItemEditorFactory);
    11591158            }
    11601159        }
     
    12121211}
    12131212
     1213void UIPortForwardingTable::cleanup()
     1214{
     1215    delete m_pItemEditorFactory;
     1216    m_pItemEditorFactory = 0;
     1217}
     1218
    12141219
    12151220#include "UIPortForwardingTable.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPortForwardingTable.h

    r92207 r92328  
    211211      * @param  fAllowEmptyGuestIPs  Brings whether this table allows empty guest IPs. */
    212212    UIPortForwardingTable(const UIPortForwardingDataList &rules, bool fIPv6, bool fAllowEmptyGuestIPs);
    213     ~UIPortForwardingTable();
     213    /** Destructs Port Forwarding table. */
     214    virtual ~UIPortForwardingTable() /* override */;
    214215    /** Returns the list of port forwarding rules. */
    215216    UIPortForwardingDataList rules() const;
     
    273274    /** Prepares toolbar. */
    274275    void prepareToolbar();
     276    /** Cleanups all. */
     277    void cleanup();
    275278
    276279    /** Holds the list of port forwarding rules. */
     
    294297    QIToolBar   *m_pToolBar;
    295298    /** Holds the item editor factory instance. */
    296     QItemEditorFactory *m_pNewItemEditorFactory;
     299    QItemEditorFactory *m_pItemEditorFactory;
    297300
    298301    /** Holds the table-model instance. */
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