VirtualBox

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


Ignore:
Timestamp:
Apr 1, 2013 1:48:52 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: VM selector: Chooser-view: Cleanup obsolete inter-thread stuff, rework alerts to use new inter-thread stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r45193 r45273  
    895895    updateNavigation();
    896896    updateLayout();
     897
     898    /* Make sure at least one item selected after that: */
     899    if (!currentItem() && !navigationList().isEmpty())
     900        setCurrentItem(navigationList().first());
    897901
    898902    /* Notify listeners about selection change: */
     
    19551959}
    19561960
    1957 void UIGroupDefinitionSaveThread::sltHandleError(UIGroupsSavingError errorType, const CMachine &machine)
    1958 {
    1959     switch (errorType)
    1960     {
    1961         case UIGroupsSavingError_MachineLockFailed:
    1962             msgCenter().cannotOpenSession(machine);
    1963             break;
    1964         case UIGroupsSavingError_MachineGroupSetFailed:
    1965             msgCenter().cannotSetGroups(machine);
    1966             break;
    1967         case UIGroupsSavingError_MachineSettingsSaveFailed:
    1968             msgCenter().cannotSaveMachineSettings(machine);
    1969             break;
    1970         default:
    1971             break;
    1972     }
    1973     emit sigReload(machine.GetId());
    1974     m_condition.wakeAll();
    1975 }
    1976 
    19771961UIGroupDefinitionSaveThread::UIGroupDefinitionSaveThread()
    19781962{
    19791963    /* Assign instance: */
    19801964    m_spInstance = this;
    1981 
    1982     /* Setup connections: */
    1983     qRegisterMetaType<UIGroupsSavingError>();
    1984     connect(this, SIGNAL(sigError(UIGroupsSavingError, const CMachine&)),
    1985             this, SLOT(sltHandleError(UIGroupsSavingError, const CMachine&)));
    19861965}
    19871966
     
    19971976void UIGroupDefinitionSaveThread::run()
    19981977{
    1999     /* Lock other thread mutex: */
    2000     m_mutex.lock();
    2001 
    20021978    /* COM prepare: */
    20031979    COMBase::InitializeCOM(false);
     
    20151991        if (newGroupSet != oldGroupSet)
    20161992        {
    2017             /* Create new session instance: */
    2018             CSession session;
    2019             session.createInstance(CLSID_Session);
    2020             AssertMsg(!session.isNull(), ("Session instance creation failed!"));
    2021             /* Search for the corresponding machine: */
    2022             CMachine machineToLock = vboxGlobal().virtualBox().FindMachine(strId);
    2023             AssertMsg(!machineToLock.isNull(), ("Machine not found!"));
    2024 
    2025             /* Lock machine: */
    2026             machineToLock.LockMachine(session, KLockType_Write);
    2027             if (!machineToLock.isOk())
     1993            /* Open session to modify iterated machine: */
     1994            CSession session = vboxGlobal().openSession(strId);
     1995            if (session.isNull())
    20281996            {
    2029                 emit sigError(UIGroupsSavingError_MachineLockFailed, machineToLock);
    2030                 m_condition.wait(&m_mutex);
    2031                 session.detach();
     1997                emit sigReload(strId);
    20321998                continue;
    20331999            }
    20342000
    2035             /* Get session's machine: */
     2001            /* Get session machine: */
    20362002            CMachine machine = session.GetMachine();
    2037             AssertMsg(!machine.isNull(), ("Machine is null!"));
     2003            AssertMsg(!machine.isNull(), ("Session machine is NULL!"));
     2004            if (machine.isNull())
     2005            {
     2006                emit sigReload(strId);
     2007                continue;
     2008            }
    20382009
    20392010            /* Set groups: */
     
    20412012            if (!machine.isOk())
    20422013            {
    2043                 emit sigError(UIGroupsSavingError_MachineGroupSetFailed, machine);
    2044                 m_condition.wait(&m_mutex);
    2045                 session.UnlockMachine();
     2014                msgCenter().cannotSetGroups(machine);
     2015                emit sigReload(strId);
    20462016                continue;
    20472017            }
     
    20512021            if (!machine.isOk())
    20522022            {
    2053                 emit sigError(UIGroupsSavingError_MachineSettingsSaveFailed, machine);
    2054                 m_condition.wait(&m_mutex);
    2055                 session.UnlockMachine();
     2023                msgCenter().cannotSaveMachineSettings(machine);
     2024                emit sigReload(strId);
    20562025                continue;
    20572026            }
    20582027
    2059             /* Close the session: */
     2028            /* Close the session finally: */
    20602029            session.UnlockMachine();
    20612030        }
     
    20672036    /* COM cleanup: */
    20682037    COMBase::CleanupCOM();
    2069 
    2070     /* Unlock other thread mutex: */
    2071     m_mutex.unlock();
    20722038}
    20732039
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h

    r45040 r45273  
    2626#include <QMap>
    2727#include <QThread>
    28 #include <QMutex>
    29 #include <QWaitCondition>
    3028
    3129/* GUI includes: */
     
    301299};
    302300
    303 /* Represents group definitions save error types: */
    304 enum UIGroupsSavingError
    305 {
    306     UIGroupsSavingError_MachineLockFailed,
    307     UIGroupsSavingError_MachineGroupSetFailed,
    308     UIGroupsSavingError_MachineSettingsSaveFailed
    309 };
    310 Q_DECLARE_METATYPE(UIGroupsSavingError);
    311 
    312301/* Allows to save group definitions asynchronously: */
    313302class UIGroupDefinitionSaveThread : public QThread
     
    317306signals:
    318307
    319     /* Notifier: Error stuff: */
    320     void sigError(UIGroupsSavingError errorType, const CMachine &machine);
    321 
    322     /* Notifier: */
     308    /* Notifier: Reload stuff: */
    323309    void sigReload(QString strId);
    324310
     
    338324                   const QMap<QString, QStringList> &newLists);
    339325
    340 private slots:
    341 
    342     /* Handler: Error stuff: */
    343     void sltHandleError(UIGroupsSavingError errorType, const CMachine &machine);
    344 
    345326private:
    346327
     
    356337    QMap<QString, QStringList> m_oldLists;
    357338    QMap<QString, QStringList> m_newLists;
    358     QMutex m_mutex;
    359     QWaitCondition m_condition;
    360339};
    361340
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