Changeset 45273 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 1, 2013 1:48:52 PM (12 years ago)
- 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 895 895 updateNavigation(); 896 896 updateLayout(); 897 898 /* Make sure at least one item selected after that: */ 899 if (!currentItem() && !navigationList().isEmpty()) 900 setCurrentItem(navigationList().first()); 897 901 898 902 /* Notify listeners about selection change: */ … … 1955 1959 } 1956 1960 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 1977 1961 UIGroupDefinitionSaveThread::UIGroupDefinitionSaveThread() 1978 1962 { 1979 1963 /* Assign instance: */ 1980 1964 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&)));1986 1965 } 1987 1966 … … 1997 1976 void UIGroupDefinitionSaveThread::run() 1998 1977 { 1999 /* Lock other thread mutex: */2000 m_mutex.lock();2001 2002 1978 /* COM prepare: */ 2003 1979 COMBase::InitializeCOM(false); … … 2015 1991 if (newGroupSet != oldGroupSet) 2016 1992 { 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()) 2028 1996 { 2029 emit sigError(UIGroupsSavingError_MachineLockFailed, machineToLock); 2030 m_condition.wait(&m_mutex); 2031 session.detach(); 1997 emit sigReload(strId); 2032 1998 continue; 2033 1999 } 2034 2000 2035 /* Get session 'smachine: */2001 /* Get session machine: */ 2036 2002 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 } 2038 2009 2039 2010 /* Set groups: */ … … 2041 2012 if (!machine.isOk()) 2042 2013 { 2043 emit sigError(UIGroupsSavingError_MachineGroupSetFailed, machine); 2044 m_condition.wait(&m_mutex); 2045 session.UnlockMachine(); 2014 msgCenter().cannotSetGroups(machine); 2015 emit sigReload(strId); 2046 2016 continue; 2047 2017 } … … 2051 2021 if (!machine.isOk()) 2052 2022 { 2053 emit sigError(UIGroupsSavingError_MachineSettingsSaveFailed, machine); 2054 m_condition.wait(&m_mutex); 2055 session.UnlockMachine(); 2023 msgCenter().cannotSaveMachineSettings(machine); 2024 emit sigReload(strId); 2056 2025 continue; 2057 2026 } 2058 2027 2059 /* Close the session : */2028 /* Close the session finally: */ 2060 2029 session.UnlockMachine(); 2061 2030 } … … 2067 2036 /* COM cleanup: */ 2068 2037 COMBase::CleanupCOM(); 2069 2070 /* Unlock other thread mutex: */2071 m_mutex.unlock();2072 2038 } 2073 2039 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h
r45040 r45273 26 26 #include <QMap> 27 27 #include <QThread> 28 #include <QMutex>29 #include <QWaitCondition>30 28 31 29 /* GUI includes: */ … … 301 299 }; 302 300 303 /* Represents group definitions save error types: */304 enum UIGroupsSavingError305 {306 UIGroupsSavingError_MachineLockFailed,307 UIGroupsSavingError_MachineGroupSetFailed,308 UIGroupsSavingError_MachineSettingsSaveFailed309 };310 Q_DECLARE_METATYPE(UIGroupsSavingError);311 312 301 /* Allows to save group definitions asynchronously: */ 313 302 class UIGroupDefinitionSaveThread : public QThread … … 317 306 signals: 318 307 319 /* Notifier: Error stuff: */ 320 void sigError(UIGroupsSavingError errorType, const CMachine &machine); 321 322 /* Notifier: */ 308 /* Notifier: Reload stuff: */ 323 309 void sigReload(QString strId); 324 310 … … 338 324 const QMap<QString, QStringList> &newLists); 339 325 340 private slots:341 342 /* Handler: Error stuff: */343 void sltHandleError(UIGroupsSavingError errorType, const CMachine &machine);344 345 326 private: 346 327 … … 356 337 QMap<QString, QStringList> m_oldLists; 357 338 QMap<QString, QStringList> m_newLists; 358 QMutex m_mutex;359 QWaitCondition m_condition;360 339 }; 361 340
Note:
See TracChangeset
for help on using the changeset viewer.