VirtualBox

Changeset 89713 in vbox


Ignore:
Timestamp:
Jun 15, 2021 3:30:02 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9215: Details pane: Get rid of non-thread-safe stuff; Qt detects it and asserts in debug build.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/details
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElements.cpp

    r89102 r89713  
    3535
    3636/* COM includes: */
    37 #include "COMEnums.h"
    3837#include "CAudioAdapter.h"
    39 #include "CCloudMachine.h"
    40 #include "CMachine.h"
    4138#include "CMedium.h"
    4239#include "CMediumAttachment.h"
     
    5552UIDetailsUpdateTask::UIDetailsUpdateTask(const CMachine &comMachine)
    5653    : UITask(UITask::Type_DetailsPopulation)
    57 {
    58     /* Store machine as property: */
    59     setProperty("machine", QVariant::fromValue(comMachine));
     54    , m_comMachine(comMachine)
     55{
    6056}
    6157
    6258UIDetailsUpdateTask::UIDetailsUpdateTask(const CCloudMachine &comCloudMachine)
    6359    : UITask(UITask::Type_DetailsPopulation)
    64 {
    65     /* Store cloud machine as property: */
    66     setProperty("cloudMachine", QVariant::fromValue(comCloudMachine));
     60    , m_comCloudMachine(comCloudMachine)
     61{
     62}
     63
     64CMachine UIDetailsUpdateTask::machine() const
     65{
     66    /* Acquire copy under a proper lock: */
     67    m_machineMutex.lock();
     68    const CMachine comMachine = m_comMachine;
     69    m_machineMutex.unlock();
     70    return comMachine;
     71}
     72
     73CCloudMachine UIDetailsUpdateTask::cloudMachine() const
     74{
     75    /* Acquire copy under a proper lock: */
     76    m_machineMutex.lock();
     77    const CCloudMachine comCloudMachine = m_comCloudMachine;
     78    m_machineMutex.unlock();
     79    return comCloudMachine;
     80}
     81
     82UITextTable UIDetailsUpdateTask::table() const
     83{
     84    /* Acquire copy under a proper lock: */
     85    m_tableMutex.lock();
     86    const UITextTable guiTable = m_guiTable;
     87    m_tableMutex.unlock();
     88    return guiTable;
     89}
     90
     91void UIDetailsUpdateTask::setTable(const UITextTable &guiTable)
     92{
     93    /* Assign under a proper lock: */
     94    m_tableMutex.lock();
     95    m_guiTable = guiTable;
     96    m_tableMutex.unlock();
    6797}
    6898
     
    111141
    112142    /* Assign new text if changed: */
    113     const UITextTable newText = pTask->property("table").value<UITextTable>();
     143    const UITextTable newText = qobject_cast<UIDetailsUpdateTask*>(pTask)->table();
    114144    if (text() != newText)
    115145        setText(newText);
     
    234264{
    235265    /* Acquire corresponding machine: */
    236     CMachine comMachine = property("machine").value<CMachine>();
    237     if (comMachine.isNull())
    238         return;
    239 
    240     /* Generate details table: */
    241     UITextTable table = UIDetailsGenerator::generateMachineInformationGeneral(comMachine, m_fOptions);
    242     setProperty("table", QVariant::fromValue(table));
     266    CMachine comMachine = machine();
     267    if (comMachine.isNull())
     268        return;
     269
     270    /* Generate details table: */
     271    setTable(UIDetailsGenerator::generateMachineInformationGeneral(comMachine, m_fOptions));
    243272}
    244273
     
    246275{
    247276    /* Acquire corresponding machine: */
    248     CCloudMachine comCloudMachine = property("cloudMachine").value<CCloudMachine>();
     277    CCloudMachine comCloudMachine = cloudMachine();
    249278    if (comCloudMachine.isNull())
    250279        return;
    251280
    252281    /* Generate details table: */
    253     UITextTable table = UIDetailsGenerator::generateMachineInformationGeneral(comCloudMachine, m_fOptions);
    254     setProperty("table", QVariant::fromValue(table));
     282    setTable(UIDetailsGenerator::generateMachineInformationGeneral(comCloudMachine, m_fOptions));
    255283}
    256284
     
    266294{
    267295    /* Acquire corresponding machine: */
    268     CMachine comMachine = property("machine").value<CMachine>();
    269     if (comMachine.isNull())
    270         return;
    271 
    272     /* Generate details table: */
    273     UITextTable table = UIDetailsGenerator::generateMachineInformationSystem(comMachine, m_fOptions);
    274     setProperty("table", QVariant::fromValue(table));
     296    CMachine comMachine = machine();
     297    if (comMachine.isNull())
     298        return;
     299
     300    /* Generate details table: */
     301    setTable(UIDetailsGenerator::generateMachineInformationSystem(comMachine, m_fOptions));
    275302}
    276303
     
    284311{
    285312    /* Acquire corresponding machine: */
    286     CMachine comMachine = property("machine").value<CMachine>();
    287     if (comMachine.isNull())
    288         return;
    289 
    290     /* Generate details table: */
    291     UITextTable table = UIDetailsGenerator::generateMachineInformationDisplay(comMachine, m_fOptions);
    292     setProperty("table", QVariant::fromValue(table));
     313    CMachine comMachine = machine();
     314    if (comMachine.isNull())
     315        return;
     316
     317    /* Generate details table: */
     318    setTable(UIDetailsGenerator::generateMachineInformationDisplay(comMachine, m_fOptions));
    293319}
    294320
     
    302328{
    303329    /* Acquire corresponding machine: */
    304     CMachine comMachine = property("machine").value<CMachine>();
    305     if (comMachine.isNull())
    306         return;
    307 
    308     /* Generate details table: */
    309     UITextTable table = UIDetailsGenerator::generateMachineInformationStorage(comMachine, m_fOptions);
    310     setProperty("table", QVariant::fromValue(table));
     330    CMachine comMachine = machine();
     331    if (comMachine.isNull())
     332        return;
     333
     334    /* Generate details table: */
     335    setTable(UIDetailsGenerator::generateMachineInformationStorage(comMachine, m_fOptions));
    311336}
    312337
     
    320345{
    321346    /* Acquire corresponding machine: */
    322     CMachine comMachine = property("machine").value<CMachine>();
    323     if (comMachine.isNull())
    324         return;
    325 
    326     /* Generate details table: */
    327     UITextTable table = UIDetailsGenerator::generateMachineInformationAudio(comMachine, m_fOptions);
    328     setProperty("table", QVariant::fromValue(table));
     347    CMachine comMachine = machine();
     348    if (comMachine.isNull())
     349        return;
     350
     351    /* Generate details table: */
     352    setTable(UIDetailsGenerator::generateMachineInformationAudio(comMachine, m_fOptions));
    329353}
    330354
     
    337361{
    338362    /* Acquire corresponding machine: */
    339     CMachine comMachine = property("machine").value<CMachine>();
    340     if (comMachine.isNull())
    341         return;
    342 
    343     /* Generate details table: */
    344     UITextTable table = UIDetailsGenerator::generateMachineInformationNetwork(comMachine, m_fOptions);
    345     setProperty("table", QVariant::fromValue(table));
     363    CMachine comMachine = machine();
     364    if (comMachine.isNull())
     365        return;
     366
     367    /* Generate details table: */
     368    setTable(UIDetailsGenerator::generateMachineInformationNetwork(comMachine, m_fOptions));
    346369}
    347370
     
    354377{
    355378    /* Acquire corresponding machine: */
    356     CMachine comMachine = property("machine").value<CMachine>();
    357     if (comMachine.isNull())
    358         return;
    359 
    360     /* Generate details table: */
    361     UITextTable table = UIDetailsGenerator::generateMachineInformationSerial(comMachine, m_fOptions);
    362     setProperty("table", QVariant::fromValue(table));
     379    CMachine comMachine = machine();
     380    if (comMachine.isNull())
     381        return;
     382
     383    /* Generate details table: */
     384    setTable(UIDetailsGenerator::generateMachineInformationSerial(comMachine, m_fOptions));
    363385}
    364386
     
    371393{
    372394    /* Acquire corresponding machine: */
    373     CMachine comMachine = property("machine").value<CMachine>();
    374     if (comMachine.isNull())
    375         return;
    376 
    377     /* Generate details table: */
    378     UITextTable table = UIDetailsGenerator::generateMachineInformationUSB(comMachine, m_fOptions);
    379     setProperty("table", QVariant::fromValue(table));
     395    CMachine comMachine = machine();
     396    if (comMachine.isNull())
     397        return;
     398
     399    /* Generate details table: */
     400    setTable(UIDetailsGenerator::generateMachineInformationUSB(comMachine, m_fOptions));
    380401}
    381402
     
    389410{
    390411    /* Acquire corresponding machine: */
    391     CMachine comMachine = property("machine").value<CMachine>();
    392     if (comMachine.isNull())
    393         return;
    394 
    395     /* Generate details table: */
    396     UITextTable table = UIDetailsGenerator::generateMachineInformationSharedFolders(comMachine, m_fOptions);
    397     setProperty("table", QVariant::fromValue(table));
     412    CMachine comMachine = machine();
     413    if (comMachine.isNull())
     414        return;
     415
     416    /* Generate details table: */
     417    setTable(UIDetailsGenerator::generateMachineInformationSharedFolders(comMachine, m_fOptions));
    398418}
    399419
     
    407427{
    408428    /* Acquire corresponding machine: */
    409     CMachine comMachine = property("machine").value<CMachine>();
    410     if (comMachine.isNull())
    411         return;
    412 
    413     /* Generate details table: */
    414     UITextTable table = UIDetailsGenerator::generateMachineInformationUI(comMachine, m_fOptions);
    415     setProperty("table", QVariant::fromValue(table));
     429    CMachine comMachine = machine();
     430    if (comMachine.isNull())
     431        return;
     432
     433    /* Generate details table: */
     434    setTable(UIDetailsGenerator::generateMachineInformationUI(comMachine, m_fOptions));
    416435}
    417436
     
    425444{
    426445    /* Acquire corresponding machine: */
    427     CMachine comMachine = property("machine").value<CMachine>();
    428     if (comMachine.isNull())
    429         return;
    430 
    431     /* Generate details table: */
    432     UITextTable table = UIDetailsGenerator::generateMachineInformationDescription(comMachine, m_fOptions);
    433     setProperty("table", QVariant::fromValue(table));
     446    CMachine comMachine = machine();
     447    if (comMachine.isNull())
     448        return;
     449
     450    /* Generate details table: */
     451    setTable(UIDetailsGenerator::generateMachineInformationDescription(comMachine, m_fOptions));
    434452}
    435453
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElements.h

    r89101 r89713  
    2626#include "UITask.h"
    2727
     28/* COM includes: */
     29#include "COMEnums.h"
     30#include "CCloudMachine.h"
     31#include "CMachine.h"
     32
    2833/* Forward declarations: */
    2934class UIMachinePreview;
     
    4247    /** Constructs update task taking @a comCloudMachine as data. */
    4348    UIDetailsUpdateTask(const CCloudMachine &comCloudMachine);
     49
     50    /** Returns the machine. */
     51    CMachine machine() const;
     52    /** Returns the cloud machine. */
     53    CCloudMachine cloudMachine() const;
     54
     55    /** Returns the table. */
     56    UITextTable table() const;
     57    /** Defines the @a guiTable. */
     58    void setTable(const UITextTable &guiTable);
     59
     60private:
     61
     62    /** Holds the mutex to access m_comMachine and m_comCloudMachine members. */
     63    mutable QMutex  m_machineMutex;
     64    /** Holds the machine being processed. */
     65    CMachine        m_comMachine;
     66    /** Holds the cloud machine being processed. */
     67    CCloudMachine   m_comCloudMachine;
     68
     69    /** Holds the mutex to access m_guiTable member. */
     70    mutable QMutex  m_tableMutex;
     71    /** Holds the machine being filled. */
     72    UITextTable     m_guiTable;
    4473};
    4574
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