VirtualBox

Ignore:
Timestamp:
Oct 20, 2024 2:00:07 AM (3 months ago)
Author:
vboxsync
Message:

Main/ovfreader.h: Tried to fix botched copy constructor suppression in HardwareItemVector only to find that it is required for a default (empty) VirtualSystem() instance that gets push_back() onto some list. So, added a restricted copy constructor that asserts if the list isn't empty. Untested! jiraref:VBP-1171

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ovfreader.h

    r106061 r106515  
    532532    RTCString itemName;
    533533
    534     virtual const RTCString& _getItemName()
     534    virtual const RTCString &_getItemName()
    535535    {
    536536        return itemName;
     
    560560    }
    561561
    562     /* There is no copying of this vector.  We'd need something like shared_ptr for that. */
     562    /* We only support copying if the vector is empty, we'd need something like
     563       shared_ptr for dealing with a populated list. (Problem found by VS 2022.) */
     564    HardwareItemVector(const HardwareItemVector &a_rThat)
     565        : std::vector<VirtualHardwareItem *>()
     566    {
     567        Assert(a_rThat.begin() == a_rThat.end());
     568    }
     569
    563570private:
    564     HardwareItemVector(const VirtualSystem &);
    565 
     571#if RT_CPLUSPLUS_PREREQ(201100) /* VC2022: No copy assignment operator (see copy constructor). */
     572    HardwareItemVector &operator=(const HardwareItemVector &) = delete;
     573#else
     574    HardwareItemVector &operator=(const HardwareItemVector &);
     575#endif
    566576};
    567577
     
    667677
    668678    VirtualSystem()
    669         : cimos(CIMOSType_CIMOS_Unknown),
    670           ullMemorySize(0),
    671           cCPUs(1),
    672           fHasFloppyDrive(false),
    673           fHasCdromDrive(false),
    674           fHasUsbController(false),
    675           pelmVBoxMachine(NULL)
    676     {
    677     }
     679        : cimos(CIMOSType_CIMOS_Unknown)
     680        , ullMemorySize(0)
     681        , cCPUs(1)
     682        , fHasFloppyDrive(false)
     683        , fHasCdromDrive(false)
     684        , fHasUsbController(false)
     685        , pelmVBoxMachine(NULL)
     686    {
     687    }
     688
     689#if RT_CPLUSPLUS_PREREQ(201100) /* VC2022: Excplit default copy constructor and copy assignment operator to avoid warnings. */
     690    /* Note! HardwareItemVector only allow copying if it's empty. */
     691    VirtualSystem(VirtualSystem const &) = default;
     692    VirtualSystem &operator=(VirtualSystem const &) = delete;
     693#endif
    678694};
    679695
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