Changeset 31759 in vbox
- Timestamp:
- Aug 18, 2010 12:18:20 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 64940
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp
r31017 r31759 3884 3884 public: 3885 3885 RemindEvent (ulong aRealBPP) 3886 : mRealBPP (aRealBPP) {}3886 : VBoxAsyncEvent(100), mRealBPP (aRealBPP) {} 3887 3887 void handle() 3888 3888 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r31533 r31759 4900 4900 */ 4901 4901 4902 VBoxAsyncEvent::VBoxAsyncEvent(uint uDelay) 4903 : QEvent((QEvent::Type)VBoxDefs::AsyncEventType) 4904 , m_uDelay(uDelay) 4905 { 4906 } 4907 4908 void VBoxAsyncEvent::post() 4909 { 4910 UIAsyncEventPoster::post(this); 4911 } 4912 4913 uint VBoxAsyncEvent::delay() const 4914 { 4915 return m_uDelay; 4916 } 4917 4918 UIAsyncEventPoster* UIAsyncEventPoster::m_spInstance = 0; 4919 4920 void UIAsyncEventPoster::post(VBoxAsyncEvent *pAsyncEvent) 4921 { 4922 if (!m_spInstance) 4923 new UIAsyncEventPoster(pAsyncEvent); 4924 } 4925 4926 UIAsyncEventPoster::UIAsyncEventPoster(VBoxAsyncEvent *pAsyncEvent) 4927 : m_pAsyncEvent(pAsyncEvent) 4928 { 4929 m_spInstance = this; 4930 QTimer::singleShot(m_pAsyncEvent->delay(), this, SLOT(sltPostAsyncEvent())); 4931 } 4932 4933 UIAsyncEventPoster::~UIAsyncEventPoster() 4934 { 4935 m_spInstance = 0; 4936 } 4937 4938 void UIAsyncEventPoster::sltPostAsyncEvent() 4939 { 4940 if (m_pAsyncEvent) 4941 QApplication::postEvent(&vboxGlobal(), m_pAsyncEvent); 4942 m_pAsyncEvent = 0; 4943 deleteLater(); 4944 } 4902 4945 4903 4946 /** -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r31533 r31759 816 816 //////////////////////////////////////////////////////////////////////////////// 817 817 818 /** 819 * Generic asyncronous event. 820 * 821 * This abstract class is intended to provide a conveinent way to execute 822 * code on the main GUI thread asynchronously to the calling party. This is 823 * done by putting necessary actions to the #handle() function in a subclass 824 * and then posting an instance of the subclass using #post(). The instance 825 * must be allocated on the heap using the <tt>new</tt> operation and will be 826 * automatically deleted after processing. Note that if you don't call #post() 827 * on the created instance, you have to delete it yourself. 828 */ 818 /* Generic asyncronous event. 819 * This abstract class is intended to provide a conveinent way 820 * to execute code on the main GUI thread asynchronously to the calling party. 821 * This is done by putting necessary actions to the handle() function 822 * in a subclass and then posting an instance of the subclass using post(). 823 * The instance must be allocated on the heap and will be automatically deleted after processing. */ 829 824 class VBoxAsyncEvent : public QEvent 830 825 { 831 826 public: 832 827 833 VBoxAsyncEvent() : QEvent ((QEvent::Type) VBoxDefs::AsyncEventType) {} 834 835 /** 836 * Worker function. Gets executed on the GUI thread when the posted event 837 * is processed by the main event loop. 838 */ 828 /* VBoxAsyncEvent constructor: */ 829 VBoxAsyncEvent(uint uDelay = 0); 830 831 /* Worker function. Gets executed on the GUI thread when 832 * the posted event is processed by the main event loop. */ 839 833 virtual void handle() = 0; 840 834 841 /** 842 * Posts this event to the main event loop. 843 * The caller loses ownership of this object after this method returns 844 * and must not delete the object. 845 */ 846 void post() 847 { 848 QApplication::postEvent (&vboxGlobal(), this); 849 } 835 /* Posts this event to the main event loop. The caller loses ownership of 836 * this object after this method returns and must not delete the object. */ 837 void post(); 838 839 /* Returns delay for this event: */ 840 uint delay() const; 841 842 private: 843 844 uint m_uDelay; 845 }; 846 847 /* Asyncronous event poster. 848 * This class is used to post async event into VBoxGlobal event handler 849 * taking into account delay set during async event creation procedure. */ 850 class UIAsyncEventPoster : public QObject 851 { 852 Q_OBJECT; 853 854 public: 855 856 /* Async event poster creator: */ 857 static void post(VBoxAsyncEvent *pAsyncEvent); 858 859 protected: 860 861 /* Constructor/destructor: */ 862 UIAsyncEventPoster(VBoxAsyncEvent *pAsyncEvent); 863 ~UIAsyncEventPoster(); 864 865 private slots: 866 867 /* Async event poster: */ 868 void sltPostAsyncEvent(); 869 870 private: 871 872 static UIAsyncEventPoster *m_spInstance; 873 VBoxAsyncEvent *m_pAsyncEvent; 850 874 }; 851 875 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQImage.cpp
r30753 r31759 193 193 public: 194 194 RemindEvent (ulong aRealBPP) 195 : mRealBPP (aRealBPP) {}195 : VBoxAsyncEvent(100), mRealBPP (aRealBPP) {} 196 196 void handle() 197 197 {
Note:
See TracChangeset
for help on using the changeset viewer.