Changeset 43943 in vbox for trunk/src/VBox/Main
- Timestamp:
- Nov 22, 2012 5:00:42 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/glue/EventQueue.cpp
r41015 r43943 6 6 7 7 /* 8 * Copyright (C) 2006-201 0Oracle Corporation8 * Copyright (C) 2006-2012 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 118 118 EventQueue::EventQueue() 119 119 { 120 /** @todo r=andy This constructor does way too much. In case of failure 121 * it's up to the caller to verify all sorts of stuff. Why 122 * isn't this done in init() and moving the main queue 123 * creation/deletion stuff to a dedicated function? */ 120 124 #ifndef VBOX_WITH_XPCOM 121 125 … … 212 216 Assert(sMainQueue == NULL); 213 217 Assert(RTThreadIsMain(RTThreadSelf())); 214 sMainQueue = new EventQueue(); 218 219 try 220 { 221 sMainQueue = new EventQueue(); 215 222 216 223 #ifdef VBOX_WITH_XPCOM 217 /* Check that it actually is the main event queue, i.e. that 218 we're called on the right thread. */ 219 nsCOMPtr<nsIEventQueue> q; 220 nsresult rv = NS_GetMainEventQ(getter_AddRefs(q)); 221 Assert(NS_SUCCEEDED(rv)); 222 Assert(q == sMainQueue->mEventQ); 223 224 /* Check that it's a native queue. */ 225 PRBool fIsNative = PR_FALSE; 226 rv = sMainQueue->mEventQ->IsQueueNative(&fIsNative); 227 Assert(NS_SUCCEEDED(rv) && fIsNative); 228 #endif // VBOX_WITH_XPCOM 224 /* Check that it actually is the main event queue, i.e. that 225 we're called on the right thread. */ 226 nsCOMPtr<nsIEventQueue> q; 227 nsresult rv = NS_GetMainEventQ(getter_AddRefs(q)); 228 Assert(NS_SUCCEEDED(rv)); 229 Assert(q == sMainQueue->mEventQ); 230 231 /* Check that it's a native queue. */ 232 PRBool fIsNative = PR_FALSE; 233 rv = sMainQueue->mEventQ->IsQueueNative(&fIsNative); 234 Assert(NS_SUCCEEDED(rv) && fIsNative); 235 #endif // VBOX_WITH_XPCOM 236 } 237 catch (bad_alloc &ba) 238 { 239 return VERR_NO_MEMORY; 240 } 229 241 230 242 return VINF_SUCCESS; … … 589 601 * @return TRUE if successful and false otherwise 590 602 */ 591 BOOL EventQueue::postEvent(Event * event)603 BOOL EventQueue::postEvent(Event *pEvent) 592 604 { 593 605 #ifndef VBOX_WITH_XPCOM 594 606 /* Note! The event == NULL case is duplicated in vboxapi/PlatformMSCOM::interruptWaitEvents(). */ 595 return PostThreadMessage(mThreadId, WM_USER, (WPARAM) event, EVENTQUEUE_WIN_LPARAM_MAGIC);607 return PostThreadMessage(mThreadId, WM_USER, (WPARAM)pEvent, EVENTQUEUE_WIN_LPARAM_MAGIC); 596 608 597 609 #else // VBOX_WITH_XPCOM … … 600 612 return FALSE; 601 613 602 MyPLEvent *ev = new MyPLEvent(event); 603 mEventQ->InitEvent(ev, this, com::EventQueue::plEventHandler, 604 com::EventQueue::plEventDestructor); 605 HRESULT rc = mEventQ->PostEvent(ev); 606 return NS_SUCCEEDED(rc); 607 614 try 615 { 616 MyPLEvent *pMyEvent = new MyPLEvent(pEvent); 617 mEventQ->InitEvent(pMyEvent, this, com::EventQueue::plEventHandler, 618 com::EventQueue::plEventDestructor); 619 HRESULT rc = mEventQ->PostEvent(pMyEvent); 620 return NS_SUCCEEDED(rc); 621 } 622 catch (bad_alloc &ba) 623 { 624 AssertMsgFailed(("Out of memory while allocating memory for event=%p: %s\n", 625 pEvent, ba.what())); 626 } 627 628 return FALSE; 608 629 #endif // VBOX_WITH_XPCOM 609 630 }
Note:
See TracChangeset
for help on using the changeset viewer.