VirtualBox

Changeset 90393 in vbox for trunk/src


Ignore:
Timestamp:
Jul 29, 2021 8:30:46 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145979
Message:

FE/Qt: bugref:10067: A bit of cleanup for various UINotificationObjects; Mostly error handling.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r90389 r90393  
    4747QString UINotificationProgressMediumCreate::details() const
    4848{
    49     return UINotificationProgress::tr("<b>Location:</b> %1<br><b>Size:</b> %2")
    50                                      .arg(m_comTarget.GetLocation()).arg(m_uSize);
     49    return UINotificationProgress::tr("<b>Location:</b> %1<br><b>Size:</b> %2").arg(m_strLocation).arg(m_uSize);
    5150}
    5251
    5352CProgress UINotificationProgressMediumCreate::createProgress(COMResult &comResult)
    5453{
     54    /* Acquire location: */
     55    m_strLocation = m_comTarget.GetLocation();
     56    if (!m_comTarget.isOk())
     57    {
     58        /* Store COM result: */
     59        comResult = m_comTarget;
     60        /* Return progress-wrapper: */
     61        return CProgress();
     62    }
     63
    5564    /* Initialize progress-wrapper: */
    5665    CProgress comProgress = m_comTarget.CreateBaseStorage(m_uSize, m_variants);
     
    9099QString UINotificationProgressMediumCopy::details() const
    91100{
    92     return UINotificationProgress::tr("<b>From:</b> %1<br><b>To:</b> %2")
    93                                      .arg(m_comSource.GetLocation(), m_comTarget.GetLocation());
     101    return UINotificationProgress::tr("<b>From:</b> %1<br><b>To:</b> %2").arg(m_strSourceLocation, m_strTargetLocation);
    94102}
    95103
    96104CProgress UINotificationProgressMediumCopy::createProgress(COMResult &comResult)
    97105{
     106    /* Acquire locations: */
     107    m_strSourceLocation = m_comSource.GetLocation();
     108    if (!m_comSource.isOk())
     109    {
     110        /* Store COM result: */
     111        comResult = m_comSource;
     112        /* Return progress-wrapper: */
     113        return CProgress();
     114    }
     115    m_strTargetLocation = m_comTarget.GetLocation();
     116    if (!m_comTarget.isOk())
     117    {
     118        /* Store COM result: */
     119        comResult = m_comTarget;
     120        /* Return progress-wrapper: */
     121        return CProgress();
     122    }
     123
    98124    /* Initialize progress-wrapper: */
    99125    CProgress comProgress = m_comSource.CloneTo(m_comTarget, m_variants, CMedium());
     
    169195QString UINotificationProgressMachineCopy::details() const
    170196{
    171     return UINotificationProgress::tr("<b>From:</b> %1<br><b>To:</b> %2")
    172                                      .arg(m_comSource.GetName(), m_comTarget.GetName());
     197    return UINotificationProgress::tr("<b>From:</b> %1<br><b>To:</b> %2").arg(m_strSourceName, m_strTargetName);
    173198}
    174199
    175200CProgress UINotificationProgressMachineCopy::createProgress(COMResult &comResult)
    176201{
     202    /* Acquire names: */
     203    m_strSourceName = m_comSource.GetName();
     204    if (!m_comSource.isOk())
     205    {
     206        /* Store COM result: */
     207        comResult = m_comSource;
     208        /* Return progress-wrapper: */
     209        return CProgress();
     210    }
     211    m_strTargetName = m_comTarget.GetName();
     212    if (!m_comTarget.isOk())
     213    {
     214        /* Store COM result: */
     215        comResult = m_comTarget;
     216        /* Return progress-wrapper: */
     217        return CProgress();
     218    }
     219
    177220    /* Initialize progress-wrapper: */
    178221    CProgress comProgress = m_comSource.CloneTo(m_comTarget, m_enmCloneMode, m_options);
     
    212255QString UINotificationProgressMachineMove::details() const
    213256{
    214     return UINotificationProgress::tr("<b>From:</b> %1<br><b>To:</b> %2")
    215                                      .arg(m_strSource, m_strDestination);
     257    return UINotificationProgress::tr("<b>From:</b> %1<br><b>To:</b> %2").arg(m_strSource, m_strDestination);
    216258}
    217259
     
    220262    /* Open a session thru which we will modify the machine: */
    221263    m_comSession = uiCommon().openSession(m_uId, KLockType_Write);
     264    if (m_comSession.isNull())
     265        return CProgress();
    222266
    223267    /* Get session machine: */
     
    226270    {
    227271        comResult = m_comSession;
     272        m_comSession.UnlockMachine();
    228273        return CProgress();
    229274    }
     
    234279    {
    235280        comResult = comMachine;
     281        m_comSession.UnlockMachine();
    236282        return CProgress();
    237283    }
     
    273319QString UINotificationProgressMachineMediaRemove::details() const
    274320{
    275     return UINotificationProgress::tr("<b>Machine Name:</b> %1").arg(m_comMachine.GetName());
     321    return UINotificationProgress::tr("<b>Machine Name:</b> %1").arg(m_strName);
    276322}
    277323
    278324CProgress UINotificationProgressMachineMediaRemove::createProgress(COMResult &comResult)
    279325{
     326    /* Acquire names: */
     327    m_strName = m_comMachine.GetName();
     328    if (!m_comMachine.isOk())
     329    {
     330        /* Store COM result: */
     331        comResult = m_comMachine;
     332        /* Return progress-wrapper: */
     333        return CProgress();
     334    }
     335
    280336    /* Initialize progress-wrapper: */
    281337    CProgress comProgress = m_comMachine.DeleteConfig(m_media);
     
    314370{
    315371    return UINotificationProgress::tr("<b>Provider:</b> %1<br><b>Profile:</b> %2<br><b>Instance Name:</b> %3")
    316                                      .arg(m_strProviderShortName, m_strProfileName, m_strInstanceName);
     372                                      .arg(m_strProviderShortName, m_strProfileName, m_strInstanceName);
    317373}
    318374
     
    349405    , m_strProfileName(strProfileName)
    350406{
     407    connect(this, &UINotificationProgress::sigProgressFinished,
     408            this, &UINotificationProgressCloudMachineCreate::sltHandleProgressFinished);
     409}
     410
     411QString UINotificationProgressCloudMachineCreate::name() const
     412{
     413    return UINotificationProgress::tr("Creating cloud VM ...");
     414}
     415
     416QString UINotificationProgressCloudMachineCreate::details() const
     417{
     418    return UINotificationProgress::tr("<b>Provider:</b> %1<br><b>Profile:</b> %2<br><b>Name:</b> %3")
     419                                      .arg(m_strProviderShortName, m_strProfileName, m_strName);
     420}
     421
     422CProgress UINotificationProgressCloudMachineCreate::createProgress(COMResult &comResult)
     423{
    351424    /* Parse cloud VM name: */
    352425    QVector<KVirtualSystemDescriptionType> types;
     
    357430        m_strName = origValues.first();
    358431
    359     /* Listen for last progress signal: */
    360     connect(this, &UINotificationProgress::sigProgressFinished,
    361             this, &UINotificationProgressCloudMachineCreate::sltHandleProgressFinished);
    362 }
    363 
    364 QString UINotificationProgressCloudMachineCreate::name() const
    365 {
    366     return UINotificationProgress::tr("Creating cloud VM ...");
    367 }
    368 
    369 QString UINotificationProgressCloudMachineCreate::details() const
    370 {
    371     return UINotificationProgress::tr("<b>Provider:</b> %1<br><b>Profile:</b> %2<br><b>Name:</b> %3")
    372                                       .arg(m_strProviderShortName, m_strProfileName, m_strName);
    373 }
    374 
    375 CProgress UINotificationProgressCloudMachineCreate::createProgress(COMResult &comResult)
    376 {
    377432    /* Initialize progress-wrapper: */
    378433    CProgress comProgress = m_comClient.CreateCloudMachine(m_comVSD, m_comMachine);
     
    403458    , m_strProfileName(strProfileName)
    404459{
    405     /* Acquire cloud VM name: */
    406     m_strName = m_comMachine.GetName();
    407 
    408     /* Listen for last progress signal: */
    409460    connect(this, &UINotificationProgress::sigProgressFinished,
    410461            this, &UINotificationProgressCloudMachineRemove::sltHandleProgressFinished);
     
    425476CProgress UINotificationProgressCloudMachineRemove::createProgress(COMResult &comResult)
    426477{
     478    /* Acquire cloud VM name: */
     479    m_strName = m_comMachine.GetName();
     480    if (!m_comMachine.isOk())
     481    {
     482        /* Store COM result: */
     483        comResult = m_comMachine;
     484        /* Return progress-wrapper: */
     485        return CProgress();
     486    }
     487
    427488    /* Initialize progress-wrapper: */
    428489    CProgress comProgress = m_fFullRemoval
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r90389 r90393  
    7878    /** Holds the medium being the target. */
    7979    CMedium                  m_comTarget;
     80    /** Holds the target location. */
     81    QString                  m_strLocation;
    8082    /** Holds the target medium size. */
    8183    qulonglong               m_uSize;
     
    124126    /** Holds the medium being the target. */
    125127    CMedium                  m_comTarget;
     128    /** Holds the source location. */
     129    QString                  m_strSourceLocation;
     130    /** Holds the target location. */
     131    QString                  m_strTargetLocation;
    126132    /** Holds the target medium options. */
    127133    QVector<KMediumVariant>  m_variants;
     
    204210    /** Holds the machine being the target. */
    205211    CMachine                m_comTarget;
     212    /** Holds the source name. */
     213    QString                 m_strSourceName;
     214    /** Holds the target name. */
     215    QString                 m_strTargetName;
    206216    /** Holds the machine cloning mode. */
    207217    KCloneMode              m_enmCloneMode;
     
    279289    /** Holds the machine being removed. */
    280290    CMachine       m_comMachine;
     291    /** Holds the machine name. */
     292    QString        m_strName;
    281293    /** Holds the machine media being removed. */
    282294    CMediumVector  m_media;
     
    389401    /** Holds the the virtual system description. */
    390402    CVirtualSystemDescription  m_comVSD;
    391     /** Holds the name acquired from VSD. */
     403    /** Holds the cloud machine name. */
    392404    QString                    m_strName;
    393405    /** Holds the short provider name. */
     
    440452    /** Holds the cloud machine being removed. */
    441453    CCloudMachine  m_comMachine;
    442     /** Holds the name acquired from cloud machine. */
     454    /** Holds the cloud machine name. */
    443455    QString        m_strName;
    444456    /** Holds whether cloud machine should be removed fully. */
     
    476488    /** Holds the cloud machine for which console connection being created. */
    477489    CCloudMachine  m_comMachine;
    478     /** Holds the name acquired from cloud machine. */
     490    /** Holds the cloud machine name. */
    479491    QString        m_strName;
    480492    /** Holds the public key used for console connection being created. */
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