VirtualBox

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


Ignore:
Timestamp:
Mar 2, 2009 10:58:10 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
43560
Message:

3551: “Main: Replace remaining collections with safe arrays”
Converted HostDVDDriveCollection.
Fixed a locking problem that caused hangs in r43495. Tested locally and by lelik.

Location:
trunk/src/VBox/Frontends
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r17218 r17238  
    671671                ComPtr<IHost> host;
    672672                CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
    673                 ComPtr<IHostDVDDriveCollection> hostDVDs;
    674                 CHECK_ERROR(host, COMGETTER(DVDDrives)(hostDVDs.asOutParam()));
     673                com::SafeIfaceArray <IHostDVDDrive> hostDVDs;
     674                rc = host->COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(hostDVDs));
     675
    675676                ComPtr<IHostDVDDrive> hostDVDDrive;
    676                 rc = hostDVDs->FindByName(Bstr(a->argv[2] + 5), hostDVDDrive.asOutParam());
     677                rc = host->FindHostDVDDrive(Bstr(a->argv[2] + 5), hostDVDDrive.asOutParam());
    677678                if (!hostDVDDrive)
    678679                {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r17218 r17238  
    224224            {
    225225                /*
    226                 * Iterate through the collection.
    227                 */
     226                 * Iterate through the collection.
     227                 */
    228228                for (size_t i = 0; i < coll.size(); ++ i)
    229229                {
     
    245245            ComPtr<IHost> host;
    246246            CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
    247             ComPtr<IHostDVDDriveCollection> coll;
    248             ComPtr<IHostDVDDriveEnumerator> enumerator;
    249             CHECK_ERROR(host, COMGETTER(DVDDrives)(coll.asOutParam()));
    250             if (SUCCEEDED(rc) && coll)
    251             {
    252                 CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
    253                 BOOL hasMore;
    254                 while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
    255                 {
    256                     ComPtr<IHostDVDDrive> dvdDrive;
    257                     CHECK_ERROR_BREAK(enumerator, GetNext(dvdDrive.asOutParam()));
     247            com::SafeIfaceArray <IHostDVDDrive> coll;
     248            CHECK_ERROR(host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll)));
     249            if (SUCCEEDED(rc))
     250            {
     251                for (size_t i = 0; i < coll.size(); ++ i)
     252                {
     253                    ComPtr<IHostDVDDrive> dvdDrive = coll[i];
    258254                    Bstr name;
    259255                    dvdDrive->COMGETTER(Name)(name.asOutParam());
     
    779775
    780776#endif /* !VBOX_ONLY_DOCS */
    781 
     777/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r17218 r17238  
    2525#ifndef VBOX_ONLY_DOCS
    2626#include <VBox/com/com.h>
     27#include <VBox/com/array.h>
    2728#include <VBox/com/ErrorInfo.h>
    2829#include <VBox/com/errorprint2.h>
     
    10911092                ComPtr<IHost> host;
    10921093                CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
    1093                 ComPtr<IHostDVDDriveCollection> hostDVDs;
    1094                 CHECK_ERROR(host, COMGETTER(DVDDrives)(hostDVDs.asOutParam()));
     1094                com::SafeIfaceArray <IHostDVDDrive> hostDVDs;
     1095                rc = host->COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(hostDVDs));
     1096
    10951097                ComPtr<IHostDVDDrive> hostDVDDrive;
    1096                 rc = hostDVDs->FindByName(Bstr(dvd + 5), hostDVDDrive.asOutParam());
     1098                rc = host->FindHostDVDDrive(Bstr(dvd + 5), hostDVDDrive.asOutParam());
    10971099                if (!hostDVDDrive)
    10981100                {
     
    11051107                        break;
    11061108                    }
    1107                     rc = hostDVDs->FindByName(Bstr(szPathReal), hostDVDDrive.asOutParam());
     1109                    rc = host->FindHostDVDDrive(Bstr(szPathReal), hostDVDDrive.asOutParam());
    11081110                    if (!hostDVDDrive)
    11091111                    {
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r17218 r17238  
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    17721772            ComPtr <IHost> host;
    17731773            CHECK_ERROR_BREAK (virtualBox, COMGETTER(Host)(host.asOutParam()));
    1774             ComPtr <IHostDVDDriveCollection> coll;
    1775             CHECK_ERROR_BREAK (host, COMGETTER(DVDDrives)(coll.asOutParam()));
     1774            SafeIfaceArray <IHostDVDDrive> coll;
     1775            CHECK_ERROR_BREAK (host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll)));
    17761776            ComPtr <IHostDVDDrive> hostDrive;
    1777             rc = coll->FindByName (medium, hostDrive.asOutParam());
     1777            rc = host->FindHostDVDDrive (medium, hostDrive.asOutParam());
    17781778            if (SUCCEEDED (rc))
    17791779            {
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r17218 r17238  
    66
    77/*
    8  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     8 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    30643064
    30653065    hostDVDMap.clear();
    3066     CHostDVDDriveEnumerator en =
    3067         vboxGlobal().virtualBox().GetHost().GetDVDDrives().Enumerate();
    3068     while (en.HasMore())
    3069     {
    3070         CHostDVDDrive hostDVD = en.GetNext();
     3066    CHostDVDDriveVector drvvec =
     3067        vboxGlobal().virtualBox().GetHost().GetDVDDrives();
     3068    for (int i = 0; i < drvvec.size(); ++i)
     3069    {
     3070        CHostDVDDrive hostDVD = drvvec[i];
    30713071        /** @todo set icon */
    30723072        QString drvName = hostDVD.GetName();
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMFirstRunWzd.cpp

    r17218 r17238  
    66
    77/*
    8  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     8 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    176176    {
    177177        /* Search for the host dvd-drives */
    178         CHostDVDDriveCollection coll =
     178        CHostDVDDriveVector coll =
    179179            vboxGlobal().virtualBox().GetHost().GetDVDDrives();
    180         mHostDVDs.resize (coll.GetCount());
    181         int id = 0;
    182         CHostDVDDriveEnumerator en = coll.Enumerate();
    183         while (en.HasMore())
    184         {
    185             CHostDVDDrive hostDVD = en.GetNext();
     180        mHostDVDs.resize (coll.size());
     181
     182        for (int id = 0; id < coll.size(); ++id)
     183        {
     184            CHostDVDDrive hostDVD = coll[id];
    186185            QString name = hostDVD.GetName();
    187186            QString description = hostDVD.GetDescription();
     
    190189            mCbHost->insertItem (id, fullName);
    191190            mHostDVDs [id] = hostDVD;
    192             ++ id;
    193191        }
    194192
     
    222220
    223221    /* Repopulate the media list */
    224         mCbImage->repopulate();
     222    mCbImage->repopulate();
    225223
    226224    /* Revalidate updated page */
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsCD.cpp

    r17218 r17238  
    66
    77/*
    8  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     8 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5959
    6060    /* Read out the host DVD drive list and prepare the combobox */
    61     CHostDVDDriveCollection coll =
     61    CHostDVDDriveVector coll =
    6262        vboxGlobal().virtualBox().GetHost().GetDVDDrives();
    63     mHostCDs.resize (coll.GetCount());
     63    mHostCDs.resize (coll.size());
    6464    mCbHostCD->clear();
    65     int id = 0;
    66     CHostDVDDriveEnumerator en = coll.Enumerate();
    67     while (en.HasMore())
    68     {
    69         CHostDVDDrive hostDVD = en.GetNext();
     65
     66    for (int id = 0; id < coll.size(); ++id)
     67    {
     68        CHostDVDDrive hostDVD = coll[id];
    7069        /// @todo (r=dmik) set icon?
    7170        QString name = hostDVD.GetName();
     
    7574        mCbHostCD->insertItem (id, fullName);
    7675        mHostCDs [id] = hostDVD;
    77         ++ id;
    7876    }
    7977
     
    8987                name :
    9088                QString ("%1 (%2)").arg (description, name);
    91             if (coll.FindByName (name).isNull())
     89            if (vboxGlobal().virtualBox().GetHost().FindHostDVDDrive (name).isNull())
    9290            {
    9391                /* If the DVD drive is not currently available,
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