- Timestamp:
- Aug 28, 2013 12:46:51 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 88504
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h
r47594 r48124 71 71 , SetRegionEventType 72 72 , ModifierKeyChangeEventType 73 , MediaEnumEventType 73 , MediumEnumeratedEventType 74 , MediumsEnumeratedEventType 74 75 #ifdef Q_WS_WIN 75 76 , ShellExecuteEventType -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r48061 r48124 162 162 #endif 163 163 164 // VBoxMediaEnumEvent 165 ///////////////////////////////////////////////////////////////////////////// 166 167 class VBoxMediaEnumEvent : public QEvent 164 /* Medium enumerated event: */ 165 class UIMediumEnumeratedEvent : public QEvent 168 166 { 169 167 public: 170 168 171 /** Constructs a regular enum event */ 172 VBoxMediaEnumEvent (const UIMedium &aMedium, 173 const VBoxMediaList::iterator &aIterator) 174 : QEvent ((QEvent::Type) MediaEnumEventType) 175 , mMedium (aMedium), mIterator (aIterator), mLast (false) 176 {} 177 /** Constructs the last enum event */ 178 VBoxMediaEnumEvent (const VBoxMediaList::iterator &aIterator) 179 : QEvent ((QEvent::Type) MediaEnumEventType) 180 , mIterator (aIterator), mLast (true) 181 {} 182 183 /** Last enumerated medium (not valid when #last is true) */ 184 const UIMedium mMedium; 185 /* Iterator which points to the corresponding item in the GUI thread: */ 186 const VBoxMediaList::iterator mIterator; 187 /** Whether this is the last event for the given enumeration or not */ 188 const bool mLast; 169 /* Constructor: */ 170 UIMediumEnumeratedEvent(const UIMedium &medium, const VBoxMediaList::iterator &iterator) 171 : QEvent((QEvent::Type)MediumEnumeratedEventType) 172 , m_medium(medium), m_iterator(iterator) 173 {} 174 175 /* Variables: */ 176 const UIMedium m_medium; 177 const VBoxMediaList::iterator m_iterator; 178 }; 179 180 /* Mediums enumerated event: */ 181 class UIMediumsEnumeratedEvent : public QEvent 182 { 183 public: 184 185 /* Constructor: */ 186 UIMediumsEnumeratedEvent(const VBoxMediaList::iterator &iterator) 187 : QEvent((QEvent::Type)MediumsEnumeratedEventType) 188 , m_iterator(iterator) 189 {} 190 191 /* Variable: */ 192 const VBoxMediaList::iterator m_iterator; 189 193 }; 190 194 … … 957 961 } 958 962 959 QString VBoxGlobal::details (const CMedium &aMedium, bool aPredictDiff, bool fUseHtml /* = true */) 960 { 961 CMedium cmedium (aMedium); 962 UIMedium medium; 963 964 if (!findMedium (cmedium, medium)) 965 { 966 /* Medium may be new and not already in the media list, request refresh */ 967 startEnumeratingMedia(); 968 if (!findMedium (cmedium, medium)) 969 /* Medium might be deleted already, return null string */ 963 QString VBoxGlobal::details(const CMedium &medium, bool fPredictDiff, bool fUseHtml /*= true*/) 964 { 965 /* Search for corresponding UI medium: */ 966 UIMedium uimedium; 967 if (!findMedium(medium, uimedium)) 968 { 969 /* UI medium may be new and not in medium list, request enumeration: */ 970 startMediumEnumeration(); 971 972 /* Search for corresponding UI medium again: */ 973 if (!findMedium(medium, uimedium)) 974 { 975 /* Medium might be deleted already, return null string: */ 970 976 return QString(); 971 } 972 973 return fUseHtml ? medium.detailsHTML (true /* aNoDiffs */, aPredictDiff) : 974 medium.details(true /* aNoDiffs */, aPredictDiff); 977 } 978 } 979 980 /* Return UI medium details: */ 981 return fUseHtml ? uimedium.detailsHTML(true /* aNoDiffs */, fPredictDiff) : 982 uimedium.details(true /* aNoDiffs */, fPredictDiff); 975 983 } 976 984 … … 1718 1726 } 1719 1727 1720 void VBoxGlobal::start EnumeratingMedia(bool fForceStart /*= true*/)1728 void VBoxGlobal::startMediumEnumeration(bool fForceStart /*= true*/) 1721 1729 { 1722 1730 /* Make sure VBoxGlobal is already valid: */ … … 1774 1782 { 1775 1783 m_mediums[i].blockAndQueryState(); 1776 QApplication::postEvent(pSelf, new VBoxMediaEnumEvent(m_mediums[i], m_iterator));1784 QApplication::postEvent(pSelf, new UIMediumEnumeratedEvent(m_mediums[i], m_iterator)); 1777 1785 ++m_iterator; 1778 1786 } … … 1780 1788 /* Post the end-of-enumeration event: */ 1781 1789 if (!m_sfCleanupInProgress) 1782 QApplication::postEvent(pSelf, new VBoxMediaEnumEvent(m_iterator));1790 QApplication::postEvent(pSelf, new UIMediumsEnumeratedEvent(m_iterator)); 1783 1791 1784 1792 COMBase::CleanupCOM(); … … 4016 4024 //////////////////////////////////////////////////////////////////////////////// 4017 4025 4018 bool VBoxGlobal::event (QEvent *e) 4019 { 4020 switch (e->type()) 4021 { 4022 case MediaEnumEventType: 4023 { 4024 VBoxMediaEnumEvent *ev = (VBoxMediaEnumEvent*) e; 4025 4026 if (!ev->mLast) 4027 { 4028 if (ev->mMedium.state() == KMediumState_Inaccessible && 4029 !ev->mMedium.result().isOk()) 4030 msgCenter().cannotGetMediaAccessibility (ev->mMedium); 4031 Assert (ev->mIterator != m_mediums.end()); 4032 *(ev->mIterator) = ev->mMedium; 4033 emit sigMediumEnumerated(*ev->mIterator); 4034 } 4035 else 4036 { 4037 /* the thread has posted the last message, wait for termination */ 4038 m_pMediumEnumerationThread->wait(); 4039 delete m_pMediumEnumerationThread; 4040 m_pMediumEnumerationThread = 0; 4041 emit sigMediumEnumerationFinished(m_mediums); 4042 } 4043 4026 bool VBoxGlobal::event(QEvent *pEvent) 4027 { 4028 /* Handle events: */ 4029 switch (pEvent->type()) 4030 { 4031 case MediumEnumeratedEventType: 4032 { 4033 /* Cast to corresponding event: */ 4034 UIMediumEnumeratedEvent *pMediumEnumeratedEvent = static_cast<UIMediumEnumeratedEvent*>(pEvent); 4035 4036 /* Show accessibility error message if necessary: */ 4037 if (pMediumEnumeratedEvent->m_medium.state() == KMediumState_Inaccessible && 4038 !pMediumEnumeratedEvent->m_medium.result().isOk()) 4039 msgCenter().cannotGetMediaAccessibility(pMediumEnumeratedEvent->m_medium); 4040 4041 /* Make sure incoming iterator is valid: */ 4042 AssertReturn(pMediumEnumeratedEvent->m_iterator != m_mediums.end(), false); 4043 4044 /* Assign enumeration result to corresponding medium: */ 4045 *(pMediumEnumeratedEvent->m_iterator) = pMediumEnumeratedEvent->m_medium; 4046 4047 /* Notify listeners about newly enumerated medium: */ 4048 emit sigMediumEnumerated(*pMediumEnumeratedEvent->m_iterator); 4049 4050 /* Accept event: */ 4044 4051 return true; 4045 4052 } 4046 4053 case MediumsEnumeratedEventType: 4054 { 4055 /* Cleanup enumeration thread: */ 4056 m_pMediumEnumerationThread->wait(); 4057 delete m_pMediumEnumerationThread; 4058 m_pMediumEnumerationThread = 0; 4059 4060 /* Notify listeners about enumeration finished: */ 4061 emit sigMediumEnumerationFinished(m_mediums); 4062 4063 /* Accept event: */ 4064 return true; 4065 } 4047 4066 default: 4048 4067 break; 4049 4068 } 4050 4051 return QObject::event (e);4069 /* Call to base-class: */ 4070 return QObject::event(pEvent); 4052 4071 } 4053 4072 … … 4566 4585 * used by some VBox smart widgets, like VBoxMediaComboBox: */ 4567 4586 if (agressiveCaching()) 4568 start EnumeratingMedia();4587 startMediumEnumeration(); 4569 4588 4570 4589 /* Prepare global settings change handler: */ … … 4649 4668 mVBox.detach(); 4650 4669 4651 /* There may be VBoxMediaEnumEvent instances still in the message4670 /* There may be UIMedium(s)EnumeratedEvent instances still in the message 4652 4671 * queue which reference COM objects. Remove them to release those objects 4653 4672 * before uninitializing the COM subsystem. */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r48089 r48124 225 225 /* details generators */ 226 226 227 QString details (const CMedium &aHD, bool aPredictDiff, bool fUseHtml = true);227 QString details(const CMedium &medium, bool fPredictDiff, bool fUseHtml = true); 228 228 229 229 QString details (const CUSBDevice &aDevice) const; … … 243 243 244 244 /* API: Medium-enumeration stuff: */ 245 void start EnumeratingMedia(bool fForceStart = true);245 void startMediumEnumeration(bool fForceStart = true); 246 246 bool agressiveCaching() const { return mAgressiveCaching; } 247 247 bool isMediaEnumerationStarted() const { return !!m_pMediumEnumerationThread; } … … 404 404 protected: 405 405 406 bool event (QEvent *e);406 bool event(QEvent *pEvent); 407 407 bool eventFilter (QObject *, QEvent *); 408 408 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
r48090 r48124 269 269 // to machine who's event called for *full-refresh* and start medium-enumeration. 270 270 // But medium-enumeration itself should update *only* invalidated mediums. 271 vboxGlobal().start EnumeratingMedia();271 vboxGlobal().startMediumEnumeration(); 272 272 } 273 273 … … 1140 1140 { 1141 1141 /* Just start medium-enumeration: */ 1142 vboxGlobal().start EnumeratingMedia();1142 vboxGlobal().startMediumEnumeration(); 1143 1143 } 1144 1144 /* If refresh was not requested or enumeration already started: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r47995 r48124 383 383 384 384 /* Cache medium data only if really necessary: */ 385 vboxGlobal().start EnumeratingMedia(false /* force start */);385 vboxGlobal().startMediumEnumeration(false /* force start */); 386 386 387 387 /* Load machine settings: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp
r47998 r48124 1735 1735 * lasted point, where we can start. The rest of the media checking is done 1736 1736 * in a background thread. */ 1737 vboxGlobal().start EnumeratingMedia();1737 vboxGlobal().startMediumEnumeration(); 1738 1738 1739 1739 /* Initialize pixmap pool */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/VBoxMediaComboBox.cpp
r47998 r48124 90 90 { 91 91 if (!vboxGlobal().isMediaEnumerationStarted()) 92 vboxGlobal().start EnumeratingMedia();92 vboxGlobal().startMediumEnumeration(); 93 93 else 94 94 refresh();
Note:
See TracChangeset
for help on using the changeset viewer.