VirtualBox

Ignore:
Timestamp:
Oct 21, 2015 2:18:26 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: VBoxGlobal: Missed COM wrappers to be recreated on VBoxSVC restart.

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

Legend:

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

    r58346 r58360  
    632632{
    633633    QList<CGuestOSType> result;
    634     for (int i = 0; i < mFamilyIDs.size(); ++i)
    635         result << mTypes[i][0];
     634    for (int i = 0; i < m_guestOSFamilyIDs.size(); ++i)
     635        result << m_guestOSTypes[i][0];
    636636    return result;
    637637}
     
    643643QList<CGuestOSType> VBoxGlobal::vmGuestOSTypeList(const QString &aFamilyId) const
    644644{
    645     AssertMsg(mFamilyIDs.contains(aFamilyId), ("Family ID incorrect: '%s'.", aFamilyId.toLatin1().constData()));
    646     return mFamilyIDs.contains(aFamilyId) ?
    647            mTypes[mFamilyIDs.indexOf(aFamilyId)] : QList<CGuestOSType>();
     645    AssertMsg(m_guestOSFamilyIDs.contains(aFamilyId), ("Family ID incorrect: '%s'.", aFamilyId.toLatin1().constData()));
     646    return m_guestOSFamilyIDs.contains(aFamilyId) ?
     647           m_guestOSTypes[m_guestOSFamilyIDs.indexOf(aFamilyId)] : QList<CGuestOSType>();
    648648}
    649649
     
    693693{
    694694    QList <CGuestOSType> list;
    695     if (mFamilyIDs.contains (aFamilyId))
    696     {
    697         list = mTypes [mFamilyIDs.indexOf (aFamilyId)];
     695    if (m_guestOSFamilyIDs.contains (aFamilyId))
     696    {
     697        list = m_guestOSTypes [m_guestOSFamilyIDs.indexOf (aFamilyId)];
    698698    }
    699699    else
    700700    {
    701         for (int i = 0; i < mFamilyIDs.size(); ++ i)
    702             list += mTypes [i];
     701        for (int i = 0; i < m_guestOSFamilyIDs.size(); ++ i)
     702            list += m_guestOSTypes [i];
    703703    }
    704704    for (int j = 0; j < list.size(); ++ j)
     
    714714QString VBoxGlobal::vmGuestOSTypeDescription (const QString &aTypeId) const
    715715{
    716     for (int i = 0; i < mFamilyIDs.size(); ++ i)
    717     {
    718         QList <CGuestOSType> list (mTypes [i]);
     716    for (int i = 0; i < m_guestOSFamilyIDs.size(); ++ i)
     717    {
     718        QList <CGuestOSType> list (m_guestOSTypes [i]);
    719719        for ( int j = 0; j < list.size(); ++ j)
    720720            if (!list [j].GetId().compare (aTypeId))
     
    40074007        return;
    40084008    }
    4009     /* Fetch corresponding objects/values: */
    4010     m_vbox = virtualBoxClient().GetVirtualBox();
    4011     m_host = virtualBox().GetHost();
    4012     m_strHomeFolder = virtualBox().GetHomeFolder();
    4013     /* Mark wrappers valid: */
    4014     m_fWrappersValid = true;
     4009    /* Init wrappers: */
     4010    comWrappersReinit();
    40154011
    40164012    /* Watch for the VBoxSVC availability changes: */
     
    40414037    connect(gEDataManager, SIGNAL(sigLanguageChange(QString)),
    40424038            this, SLOT(sltGUILanguageChange(QString)));
    4043 
    4044     /* Initialize guest OS Type list. */
    4045     CGuestOSTypeVector coll = m_vbox.GetGuestOSTypes();
    4046     int osTypeCount = coll.size();
    4047     AssertMsg(osTypeCount > 0, ("Number of OS types must not be zero"));
    4048     if (osTypeCount > 0)
    4049     {
    4050         /* Here we ASSUME the 'Other' types are always the first, so we
    4051          * remember it and will append it to the list when finished.
    4052          * We do a two pass, first adding the specific types, then the two
    4053          * 'Other' types. */
    4054         for (int j = 0; j < 2; j++)
    4055         {
    4056             int cMax = j == 0 ? coll.size() : RT_MIN(2, coll.size());
    4057             for (int i = j == 0 ? 2 : 0; i < cMax; ++i)
    4058             {
    4059                 CGuestOSType os = coll[i];
    4060                 QString familyId(os.GetFamilyId());
    4061                 if (!mFamilyIDs.contains(familyId))
    4062                 {
    4063                     mFamilyIDs << familyId;
    4064                     mTypes << QList<CGuestOSType>();
    4065                 }
    4066                 mTypes[mFamilyIDs.indexOf(familyId)].append(os);
    4067             }
    4068         }
    4069     }
    40704039
    40714040    qApp->installEventFilter (this);
     
    44194388
    44204389    /* ensure CGuestOSType objects are no longer used */
    4421     mFamilyIDs.clear();
    4422     mTypes.clear();
     4390    m_guestOSFamilyIDs.clear();
     4391    m_guestOSTypes.clear();
    44234392
    44244393    /* Starting COM cleanup: */
     
    44744443        if (!m_fWrappersValid)
    44754444        {
    4476             /* Re-fetch corresponding objects/values: */
    4477             m_vbox = virtualBoxClient().GetVirtualBox();
    4478             m_host = virtualBox().GetHost();
    4479             m_strHomeFolder = virtualBox().GetHomeFolder();
    4480             /* Mark wrappers valid: */
    4481             m_fWrappersValid = true;
     4445            /* Re-init wrappers: */
     4446            comWrappersReinit();
    44824447
    44834448            /* If that is Selector UI: */
     
    44934458    /* Notify listeners about the VBoxSVC availability change: */
    44944459    emit sigVBoxSVCAvailabilityChange();
     4460}
     4461
     4462void VBoxGlobal::comWrappersReinit()
     4463{
     4464    /* Re-fetch corresponding objects/values: */
     4465    m_vbox = virtualBoxClient().GetVirtualBox();
     4466    m_host = virtualBox().GetHost();
     4467    m_strHomeFolder = virtualBox().GetHomeFolder();
     4468
     4469    /* Re-initialize guest OS Type list: */
     4470    m_guestOSFamilyIDs.clear();
     4471    m_guestOSTypes.clear();
     4472    const CGuestOSTypeVector guestOSTypes = m_vbox.GetGuestOSTypes();
     4473    const int cGuestOSTypeCount = guestOSTypes.size();
     4474    AssertMsg(cGuestOSTypeCount > 0, ("Number of OS types must not be zero"));
     4475    if (cGuestOSTypeCount > 0)
     4476    {
     4477        /* Here we ASSUME the 'Other' types are always the first,
     4478         * so we remember them and will append them to the list when finished.
     4479         * We do a two pass, first adding the specific types, then the two 'Other' types. */
     4480        for (int j = 0; j < 2; ++j)
     4481        {
     4482            int cMax = j == 0 ? cGuestOSTypeCount : RT_MIN(2, cGuestOSTypeCount);
     4483            for (int i = j == 0 ? 2 : 0; i < cMax; ++i)
     4484            {
     4485                const CGuestOSType os = guestOSTypes.at(i);
     4486                const QString strFamilyID = os.GetFamilyId();
     4487                if (!m_guestOSFamilyIDs.contains(strFamilyID))
     4488                {
     4489                    m_guestOSFamilyIDs << strFamilyID;
     4490                    m_guestOSTypes << QList<CGuestOSType>();
     4491                }
     4492                m_guestOSTypes[m_guestOSFamilyIDs.indexOf(strFamilyID)].append(os);
     4493            }
     4494        }
     4495    }
     4496
     4497    /* Mark wrappers valid: */
     4498    m_fWrappersValid = true;
    44954499}
    44964500
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r58346 r58360  
    515515    ~VBoxGlobal();
    516516
     517    /** Re-initializes COM wrappers and containers. */
     518    void comWrappersReinit();
     519
    517520#ifdef VBOX_WITH_DEBUGGER_GUI
    518521    void initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault = false);
     
    539542    /** Holds the symbolic VirtualBox home-folder representation. */
    540543    QString m_strHomeFolder;
     544    /** Holds the guest OS family IDs. */
     545    QList<QString> m_guestOSFamilyIDs;
     546    /** Holds the guest OS types for each family ID. */
     547    QList<QList<CGuestOSType> > m_guestOSTypes;
    541548
    542549    /** Holds whether acquired COM wrappers are currently valid. */
     
    628635    int m3DAvailable;
    629636
    630     QList <QString> mFamilyIDs;
    631     QList <QList <CGuestOSType> > mTypes;
    632 
    633637    QString mDiskTypes_Differencing;
    634638
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