VirtualBox

Changeset 80926 in vbox for trunk


Ignore:
Timestamp:
Sep 20, 2019 1:24:33 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8472: Merge startMediumEnumeration & enumerateAdditionalMedia into one consolidated mechanism which can enumerate all media at once or selected media only.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r80894 r80926  
    25372537}
    25382538
    2539 void UICommon::startMediumEnumeration(const CMediumVector &comMedia /* = CMediumVector() */)
     2539void UICommon::enumerateMedia(const CMediumVector &comMedia /* = CMediumVector() */)
    25402540{
    25412541    /* Make sure UICommon is already valid: */
     
    25512551    if (!m_pMediumEnumerator)
    25522552        return;
    2553     /* Make sure enumeration is not already started: */
    2554     if (m_pMediumEnumerator->isMediumEnumerationInProgress())
    2555         return;
    25562553
    25572554    /* Redirect request to medium-enumerator under proper lock: */
     
    25592556    {
    25602557        if (m_pMediumEnumerator)
    2561             m_pMediumEnumerator->startMediumEnumeration(comMedia);
    2562         m_meCleanupProtectionToken.unlock();
    2563     }
    2564 }
    2565 
    2566 void UICommon::enumerateAdditionalMedia(const CMediumVector &comMedia)
    2567 {
    2568     /* Make sure UICommon is already valid: */
    2569     AssertReturnVoid(m_fValid);
    2570     /* Ignore the request during UICommon cleanup: */
    2571     if (s_fCleaningUp)
    2572         return;
    2573     /* Ignore the request during startup snapshot restoring: */
    2574     if (shouldRestoreCurrentSnapshot())
    2575         return;
    2576 
    2577     /* Make sure medium-enumerator is already created: */
    2578     if (!m_pMediumEnumerator)
    2579         return;
    2580 
    2581     /* Redirect request to medium-enumerator under proper lock: */
    2582     if (m_meCleanupProtectionToken.tryLockForRead())
    2583     {
    2584         if (m_pMediumEnumerator)
    2585             m_pMediumEnumerator->enumerateAdditionalMedia(comMedia);
     2558            m_pMediumEnumerator->enumerateMedia(comMedia);
    25862559        m_meCleanupProtectionToken.unlock();
    25872560    }
     
    33483321    {
    33493322        /* UI medium may be new and not among our media, request enumeration: */
    3350         enumerateAdditionalMedia(CMediumVector() << comMedium);
     3323        enumerateMedia(CMediumVector() << comMedium);
    33513324
    33523325        /* Search for corresponding UI medium again: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r80894 r80926  
    482482    /** @name COM: Virtual Media stuff.
    483483     * @{ */
    484         /** Starts medium-enumeration. */
    485         void startMediumEnumeration(const CMediumVector &comMedia = CMediumVector());
    486         /** Enumerates additional media. */
    487         void enumerateAdditionalMedia(const CMediumVector &comMedia);
     484        /** Enumerates passed @a comMedia. */
     485        void enumerateMedia(const CMediumVector &comMedia = CMediumVector());
    488486        /** Calls refresh for each medium which has been already enumerated. */
    489487        void refreshMedia();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r79365 r80926  
    12721272    /* Cache medium data early if necessary: */
    12731273    if (uiCommon().agressiveCaching())
    1274         uiCommon().startMediumEnumeration();
     1274        uiCommon().enumerateMedia();
    12751275
    12761276    /* Prepare: */
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumEnumerator.cpp

    r80899 r80926  
    158158}
    159159
    160 void UIMediumEnumerator::startMediumEnumeration(const CMediumVector &comMedia /* = CMediumVector() */)
    161 {
    162     /* Make sure we are not already in progress: */
    163     AssertReturnVoid(!m_fMediumEnumerationInProgress);
    164 
     160void UIMediumEnumerator::enumerateMedia(const CMediumVector &comMedia /* = CMediumVector() */)
     161{
    165162    /* Compose new map of currently cached media & their children.
    166163     * While composing we are using data from already cached media. */
    167164    UIMediumMap guiMedia;
    168165    addNullMediumToMap(guiMedia);
    169     /* If @p comMedia is empty we start the medium-enumeration with all
    170      * known hard disk media. Otherwise only passed comMedia will be
    171      * enumerated. But be aware we will enumerate all the optical media
    172      * in any case to make them listed within the first run wizard for
    173      * now. But I think later we can add proper enumeration call to the
    174      * wizard instead and enumerate only comMedia in 'else' case. */
    175166    if (comMedia.isEmpty())
    176167    {
    177         m_fFullMediumEnumerationRequested = true;
     168        /* Compose new map of all known media & their children: */
    178169        addMediaToMap(uiCommon().virtualBox().GetHardDisks(), guiMedia);
    179170        addMediaToMap(uiCommon().host().GetDVDDrives(), guiMedia);
     
    184175    else
    185176    {
    186         m_fFullMediumEnumerationRequested = false;
     177        /* Compose new map of passed media & their children: */
    187178        addMediaToMap(comMedia, guiMedia);
    188179    }
     
    192183        return;
    193184
    194     /* Replace existing media map: */
    195     m_media = guiMedia;
    196 
    197     /* If enumeration hasn't yet started: */
    198     if (!m_fMediumEnumerationInProgress)
    199     {
    200         /* Notify listener about enumeration started: */
    201         LogRel(("GUI: UIMediumEnumerator: Medium-enumeration started...\n"));
    202         m_fMediumEnumerationInProgress = true;
    203         emit sigMediumEnumerationStarted();
    204 
    205         /* Make sure we really have more than one UIMedium (which is NULL): */
    206         if (   guiMedia.size() == 1
    207             && guiMedia.first().id() == UIMedium::nullID())
    208         {
    209             /* Notify listener about enumeration finished instantly: */
    210             LogRel(("GUI: UIMediumEnumerator: Medium-enumeration finished!\n"));
    211             m_fMediumEnumerationInProgress = false;
    212             emit sigMediumEnumerationFinished();
    213         }
    214     }
    215 
    216     /* Start enumeration for media with non-NULL ID: */
    217     foreach (const QUuid &uMediumID, guiMedia.keys())
    218         if (!uMediumID.isNull())
    219             createMediumEnumerationTask(guiMedia[uMediumID]);
    220 }
    221 
    222 void UIMediumEnumerator::enumerateAdditionalMedia(const CMediumVector &comMedia)
    223 {
    224     /* Compose new map of passed medium & it's children.
    225      * While composing we are using data from already cached media. */
    226     UIMediumMap guiMedia;
    227     addMediaToMap(comMedia, guiMedia);
    228 
    229     /* UICommon is cleaning up, abort immediately: */
    230     if (UICommon::isCleaningUp())
    231         return;
    232 
    233     /* Throw the media to existing map: */
    234     foreach (const QUuid &uMediumId, guiMedia.keys())
    235         m_media[uMediumId] = guiMedia.value(uMediumId);
     185    if (comMedia.isEmpty())
     186    {
     187        /* Replace existing media map since
     188         * we have full medium enumeration: */
     189        m_fFullMediumEnumerationRequested = true;
     190        m_media = guiMedia;
     191    }
     192    else
     193    {
     194        /* Throw the media to existing map: */
     195        foreach (const QUuid &uMediumId, guiMedia.keys())
     196            m_media[uMediumId] = guiMedia.value(uMediumId);
     197    }
    236198
    237199    /* If enumeration hasn't yet started: */
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumEnumerator.h

    r80894 r80926  
    8181    bool isMediumEnumerationInProgress() const { return m_fMediumEnumerationInProgress; }
    8282    /** Makes a request to enumerate specified @a comMedia.
    83       * @note  Previous map will be replaced with the new one, values present in both
    84       *        maps will be merged from the previous to new one, keep that all in mind.
    85       * @note  Empty passed map means that full/overall medium-enumeration is requested. */
    86     void startMediumEnumeration(const CMediumVector &comMedia = CMediumVector());
    87     /** Makes a request to enumerate additionally specified @a comMedia.
    88       * @note  Previous map will be extended with the new one, composed of passed
    89       *        media and their children, values present in both maps will be merged
    90       *        from the previous to new one, keep that all in mind. */
    91     void enumerateAdditionalMedia(const CMediumVector &comMedia);
     83      * @note  Empty passed map means that full/overall medium-enumeration is requested.
     84      *        In that case previous map will be replaced with the new one, values
     85      *        present in both maps will be merged from the previous to new one.
     86      * @note  Non-empty passed map means that additional medium-enumeration is requested.
     87      *        In that case previous map will be extended with the new one, values
     88      *        present in both maps will be merged from the previous to new one. */
     89    void enumerateMedia(const CMediumVector &comMedia = CMediumVector());
    9290    /** Refresh all the lightweight UIMedium information for all the cached UIMedium(s).
    9391      * @note  Please note that this is a lightweight version, which doesn't perform
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r80884 r80926  
    580580{
    581581    /* Start medium-enumeration: */
    582     uiCommon().startMediumEnumeration();
     582    uiCommon().enumerateMedia();
    583583}
    584584
     
    696696    /* Start medium-enumeration (if necessary): */
    697697    if (!uiCommon().isFullMediumEnumerationRequested())
    698         uiCommon().startMediumEnumeration();
     698        uiCommon().enumerateMedia();
    699699    /* Emulate medium-enumeration otherwise: */
    700700    else
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp

    r80884 r80926  
    8282    /* Start medium-enumeration (if necessary): */
    8383    if (!uiCommon().isFullMediumEnumerationRequested())
    84         uiCommon().startMediumEnumeration();
     84        uiCommon().enumerateMedia();
    8585    configure();
    8686    finalize();
     
    497497{
    498498    /* Initialize media enumation: */
    499     uiCommon().startMediumEnumeration();
     499    uiCommon().enumerateMedia();
    500500    /* Update the search: */
    501501    m_pSearchWidget->search(m_pTreeWidget);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r80890 r80926  
    210210    {
    211211        AssertReturn(m_pSession, false);
    212         uiCommon().startMediumEnumeration(m_pSession->machineMedia());
     212        uiCommon().enumerateMedia(m_pSession->machineMedia());
    213213    }
    214214
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIVMInformationDialog.cpp

    r80884 r80926  
    170170    /* This is needed at least for some VM to show correct storage info. */
    171171    if (!uiCommon().isFullMediumEnumerationRequested())
    172         uiCommon().startMediumEnumeration();
     172        uiCommon().enumerateMedia();
    173173}
    174174
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r80884 r80926  
    37103710    /* Start medium-enumeration (only if necessary): */
    37113711    if (!uiCommon().isFullMediumEnumerationRequested())
    3712         uiCommon().startMediumEnumeration();
     3712        uiCommon().enumerateMedia();
    37133713
    37143714    /* Layout created in the .ui file. */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMediaComboBox.cpp

    r80900 r80926  
    6666        comMedia << uiCommon().host().GetDVDDrives();
    6767        comMedia << uiCommon().virtualBox().GetDVDImages();
    68         uiCommon().enumerateAdditionalMedia(comMedia);
     68        uiCommon().enumerateMedia(comMedia);
    6969    }
    7070    refresh();
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