Changeset 39720 in vbox
- Timestamp:
- Jan 7, 2012 2:56:25 AM (13 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleImpl.h
r39711 r39720 694 694 const ComObjPtr<MachineDebugger> mDebugger; 695 695 const ComObjPtr<VRDEServerInfo> mVRDEServerInfo; 696 /** This can safely be used without holding any locks. 697 * An AutoCaller suffices to prevent it being destroy while in use and 698 * internally there is a lock providing the necessary serialization. */ 696 699 const ComObjPtr<EventSource> mEventSource; 697 700 #ifdef VBOX_WITH_EXTPACK -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r39711 r39720 5 5 6 6 /* 7 * Copyright (C) 2006-201 1Oracle Corporation7 * Copyright (C) 2006-2012 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 1853 1853 1854 1854 AutoCaller autoCaller(this); 1855 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1856 1857 // no need to lock - lifetime constant 1858 mEventSource.queryInterfaceTo(aEventSource); 1859 1860 return S_OK; 1855 HRESULT hrc = autoCaller.rc(); 1856 if (SUCCEEDED(hrc)) 1857 { 1858 // no need to lock - lifetime constant 1859 mEventSource.queryInterfaceTo(aEventSource); 1860 } 1861 1862 return hrc; 1861 1863 } 1862 1864 … … 3100 3102 m_mapSharedFolders.insert(std::make_pair(aName, pSharedFolder)); 3101 3103 3102 /* notify console callbacks after the folder is added to the list */ 3104 /* Notify console callbacks after the folder is added to the list. */ 3105 alock.release(); 3103 3106 fireSharedFolderChangedEvent(mEventSource, Scope_Session); 3104 3107 … … 3165 3168 m_mapSharedFolders.erase(strName); 3166 3169 3167 /* notify console callbacks after the folder is removed to the list */ 3170 /* Notify console callbacks after the folder is removed from the list. */ 3171 alock.release(); 3168 3172 fireSharedFolderChangedEvent(mEventSource, Scope_Session); 3169 3173 … … 4352 4356 /* notify console callbacks on success */ 4353 4357 if (SUCCEEDED(rc)) 4358 { 4359 alock.release(); /** @todo 101% safe? */ 4354 4360 fireNetworkAdapterChangedEvent(mEventSource, aNetworkAdapter); 4361 } 4355 4362 4356 4363 LogFlowThisFunc(("Leaving rc=%#x\n", rc)); … … 4639 4646 /** 4640 4647 * Called by IInternalSessionControl::OnSerialPortChange(). 4641 *4642 * @note Locks this object for writing.4643 4648 */ 4644 4649 HRESULT Console::onSerialPortChange(ISerialPort *aSerialPort) … … 4649 4654 AssertComRCReturnRC(autoCaller.rc()); 4650 4655 4651 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 4652 4653 HRESULT rc = S_OK; 4654 4655 /* don't trigger serial port change if the VM isn't running */ 4656 SafeVMPtrQuiet ptrVM(this); 4657 if (ptrVM.isOk()) 4658 { 4659 /* nothing to do so far */ 4660 ptrVM.release(); 4661 } 4662 4663 /* notify console callbacks on success */ 4664 if (SUCCEEDED(rc)) 4665 fireSerialPortChangedEvent(mEventSource, aSerialPort); 4666 4667 LogFlowThisFunc(("Leaving rc=%#x\n", rc)); 4668 return rc; 4656 fireSerialPortChangedEvent(mEventSource, aSerialPort); 4657 4658 LogFlowThisFunc(("Leaving rc=%#x\n", S_OK)); 4659 return S_OK; 4669 4660 } 4670 4661 4671 4662 /** 4672 4663 * Called by IInternalSessionControl::OnParallelPortChange(). 4673 *4674 * @note Locks this object for writing.4675 4664 */ 4676 4665 HRESULT Console::onParallelPortChange(IParallelPort *aParallelPort) … … 4681 4670 AssertComRCReturnRC(autoCaller.rc()); 4682 4671 4683 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 4684 4685 HRESULT rc = S_OK; 4686 4687 /* don't trigger parallel port change if the VM isn't running */ 4688 SafeVMPtrQuiet ptrVM(this); 4689 if (ptrVM.isOk()) 4690 { 4691 /* nothing to do so far */ 4692 ptrVM.release(); 4693 } 4694 4695 /* notify console callbacks on success */ 4696 if (SUCCEEDED(rc)) 4697 fireParallelPortChangedEvent(mEventSource, aParallelPort); 4698 4699 LogFlowThisFunc(("Leaving rc=%#x\n", rc)); 4700 return rc; 4672 fireParallelPortChangedEvent(mEventSource, aParallelPort); 4673 4674 LogFlowThisFunc(("Leaving rc=%#x\n", S_OK)); 4675 return S_OK; 4701 4676 } 4702 4677 4703 4678 /** 4704 4679 * Called by IInternalSessionControl::OnStorageControllerChange(). 4705 *4706 * @note Locks this object for writing.4707 4680 */ 4708 4681 HRESULT Console::onStorageControllerChange() … … 4713 4686 AssertComRCReturnRC(autoCaller.rc()); 4714 4687 4715 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 4716 4717 HRESULT rc = S_OK; 4718 4719 /* don't trigger storage controller change if the VM isn't running */ 4720 SafeVMPtrQuiet ptrVM(this); 4721 if (ptrVM.isOk()) 4722 { 4723 /* nothing to do so far */ 4724 ptrVM.release(); 4725 } 4726 4727 /* notify console callbacks on success */ 4728 if (SUCCEEDED(rc)) 4729 fireStorageControllerChangedEvent(mEventSource); 4730 4731 LogFlowThisFunc(("Leaving rc=%#x\n", rc)); 4732 return rc; 4688 fireStorageControllerChangedEvent(mEventSource); 4689 4690 LogFlowThisFunc(("Leaving rc=%#x\n", S_OK)); 4691 return S_OK; 4733 4692 } 4734 4693 … … 4759 4718 /* notify console callbacks on success */ 4760 4719 if (SUCCEEDED(rc)) 4720 { 4721 alock.release(); /** @todo 101% safe? */ 4761 4722 fireMediumChangedEvent(mEventSource, aMediumAttachment); 4723 } 4762 4724 4763 4725 LogFlowThisFunc(("Leaving rc=%#x\n", rc)); … … 4833 4795 /* notify console callbacks on success */ 4834 4796 if (SUCCEEDED(rc)) 4797 { 4798 alock.release(); 4835 4799 fireCPUExecutionCapChangedEvent(mEventSource, aExecutionCap); 4800 } 4836 4801 4837 4802 LogFlowThisFunc(("Leaving rc=%#x\n", rc)); … … 4893 4858 /* notify console callbacks on success */ 4894 4859 if (SUCCEEDED(rc)) 4860 { 4861 alock.release(); 4895 4862 fireVRDEServerChangedEvent(mEventSource); 4863 } 4896 4864 4897 4865 return rc; 4898 4866 } 4899 4867 4900 /**4901 * @note Locks this object for reading.4902 */4903 4868 void Console::onVRDEServerInfoChange() 4904 4869 { … … 4906 4871 AssertComRCReturnVoid(autoCaller.rc()); 4907 4872 4908 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);4909 4910 4873 fireVRDEServerInfoChangedEvent(mEventSource); 4911 4874 } … … 4914 4877 /** 4915 4878 * Called by IInternalSessionControl::OnUSBControllerChange(). 4916 *4917 * @note Locks this object for writing.4918 4879 */ 4919 4880 HRESULT Console::onUSBControllerChange() … … 4924 4885 AssertComRCReturnRC(autoCaller.rc()); 4925 4886 4926 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 4927 4928 HRESULT rc = S_OK; 4929 4930 /* don't trigger USB controller change if the VM isn't running */ 4931 SafeVMPtrQuiet ptrVM(this); 4932 if (ptrVM.isOk()) 4933 { 4934 /// @todo implement one day. 4935 // Anyway, if we want to query the machine's USB Controller we need 4936 // to cache it to mUSBController in #init() (similar to mDVDDrive). 4937 // 4938 // bird: While the VM supports hot-plugging, I doubt any guest can 4939 // handle it at this time... :-) 4940 4941 /* nothing to do so far */ 4942 ptrVM.release(); 4943 } 4944 4945 /* notify console callbacks on success */ 4946 if (SUCCEEDED(rc)) 4947 fireUSBControllerChangedEvent(mEventSource); 4948 4949 return rc; 4887 fireUSBControllerChangedEvent(mEventSource); 4888 4889 return S_OK; 4950 4890 } 4951 4891 … … 4969 4909 if (SUCCEEDED(rc)) 4970 4910 { 4911 alock.release(); 4971 4912 fireSharedFolderChangedEvent(mEventSource, aGlobal ? (Scope_T)Scope_Global : (Scope_T)Scope_Machine); 4972 4913 } … … 5179 5120 /* notify console callbacks on success */ 5180 5121 if (SUCCEEDED(rc)) 5122 { 5123 alock.release(); 5181 5124 fireBandwidthGroupChangedEvent(mEventSource, aBandwidthGroup); 5125 } 5182 5126 5183 5127 LogFlowThisFunc(("Leaving rc=%#x\n", rc)); … … 5214 5158 /* notify console callbacks on success */ 5215 5159 if (SUCCEEDED(rc)) 5160 { 5161 alock.release(); /** @todo 101% safe? */ 5216 5162 fireStorageDeviceChangedEvent(mEventSource, aMediumAttachment, aRemove); 5163 } 5217 5164 5218 5165 LogFlowThisFunc(("Leaving rc=%#x\n", rc)); … … 5685 5632 } 5686 5633 5634 #ifdef CONSOLE_WITH_EVENT_CACHE 5687 5635 /** 5688 5636 * @note Locks this object for writing. 5689 5637 */ 5638 #endif 5690 5639 void Console::onMousePointerShapeChange(bool fVisible, bool fAlpha, 5691 5640 uint32_t xHot, uint32_t yHot, … … 5702 5651 AssertComRCReturnVoid(autoCaller.rc()); 5703 5652 5704 #if ndef CONSOLE_WITH_EVENT_CACHE5705 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);5706 #else 5707 /* We need a write lock because we alter the cached callback data */5708 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 5709 5710 /* Save the callback arguments */5711 mCallbackData.mpsc.visible = fVisible;5712 mCallbackData.mpsc.alpha = fAlpha;5713 mCallbackData.mpsc.xHot = xHot;5714 mCallbackData.mpsc.yHot = yHot;5715 mCallbackData.mpsc.width = width;5716 mCallbackData.mpsc.height = height; 5717 5718 /* start with not valid */5719 bool wasValid = mCallbackData.mpsc.valid;5720 mCallbackData.mpsc.valid = false; 5721 5722 com::SafeArray<BYTE> aShape(ComSafeArrayInArg(pShape));5723 if (aShape.size() != 0)5724 mCallbackData.mpsc.shape.initFrom(aShape);5725 else5726 mCallbackData.mpsc. shape.resize(0);5727 mCallbackData.mpsc.valid = true;5653 #ifdef CONSOLE_WITH_EVENT_CACHE 5654 { 5655 /* We need a write lock because we alter the cached callback data */ 5656 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 5657 5658 /* Save the callback arguments */ 5659 mCallbackData.mpsc.visible = fVisible; 5660 mCallbackData.mpsc.alpha = fAlpha; 5661 mCallbackData.mpsc.xHot = xHot; 5662 mCallbackData.mpsc.yHot = yHot; 5663 mCallbackData.mpsc.width = width; 5664 mCallbackData.mpsc.height = height; 5665 5666 /* start with not valid */ 5667 bool wasValid = mCallbackData.mpsc.valid; 5668 mCallbackData.mpsc.valid = false; 5669 5670 com::SafeArray<BYTE> aShape(ComSafeArrayInArg(pShape)); 5671 if (aShape.size() != 0) 5672 mCallbackData.mpsc.shape.initFrom(aShape); 5673 else 5674 mCallbackData.mpsc.shape.resize(0); 5675 mCallbackData.mpsc.valid = true; 5676 } 5728 5677 #endif 5729 5678 … … 5735 5684 } 5736 5685 5686 #ifdef CONSOLE_WITH_EVENT_CACHE 5737 5687 /** 5738 5688 * @note Locks this object for writing. 5739 5689 */ 5690 #endif 5740 5691 void Console::onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative, BOOL needsHostCursor) 5741 5692 { … … 5746 5697 AssertComRCReturnVoid(autoCaller.rc()); 5747 5698 5748 #if ndef CONSOLE_WITH_EVENT_CACHE5749 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);5750 #else 5751 /* We need a write lock because we alter the cached callback data */5752 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 5753 5754 /* save the callback arguments */5755 mCallbackData.mcc.supportsAbsolute = supportsAbsolute;5756 mCallbackData.mcc.supportsRelative = supportsRelative;5757 mCallbackData.mcc.needsHostCursor = needsHostCursor;5758 mCallbackData.mcc.valid = true;5699 #ifdef CONSOLE_WITH_EVENT_CACHE 5700 { 5701 /* We need a write lock because we alter the cached callback data */ 5702 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 5703 5704 /* save the callback arguments */ 5705 mCallbackData.mcc.supportsAbsolute = supportsAbsolute; 5706 mCallbackData.mcc.supportsRelative = supportsRelative; 5707 mCallbackData.mcc.needsHostCursor = needsHostCursor; 5708 mCallbackData.mcc.valid = true; 5709 } 5759 5710 #endif 5760 5711 … … 5762 5713 } 5763 5714 5764 /**5765 * @note Locks this object for reading.5766 */5767 5715 void Console::onStateChange(MachineState_T machineState) 5768 5716 { … … 5770 5718 AssertComRCReturnVoid(autoCaller.rc()); 5771 5719 5772 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);5773 5720 fireStateChangedEvent(mEventSource, machineState); 5774 5721 } 5775 5722 5776 /**5777 * @note Locks this object for reading.5778 */5779 5723 void Console::onAdditionsStateChange() 5780 5724 { … … 5782 5726 AssertComRCReturnVoid(autoCaller.rc()); 5783 5727 5784 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);5785 5728 fireAdditionsStateChangedEvent(mEventSource); 5786 5729 } 5787 5730 5788 5731 /** 5789 * @note Locks this object for reading. 5790 * This notification only is for reporting an incompatible 5791 * Guest Additions interface, *not* the Guest Additions version! 5792 * 5793 * The user will be notified inside the guest if new Guest 5794 * Additions are available (via VBoxTray/VBoxClient). 5732 * @remarks This notification only is for reporting an incompatible 5733 * Guest Additions interface, *not* the Guest Additions version! 5734 * 5735 * The user will be notified inside the guest if new Guest 5736 * Additions are available (via VBoxTray/VBoxClient). 5795 5737 */ 5796 5738 void Console::onAdditionsOutdated() … … 5799 5741 AssertComRCReturnVoid(autoCaller.rc()); 5800 5742 5801 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 5802 } 5803 5743 /** @todo implement this */ 5744 } 5745 5746 #ifdef CONSOLE_WITH_EVENT_CACHE 5804 5747 /** 5805 5748 * @note Locks this object for writing. 5806 5749 */ 5750 #endif 5807 5751 void Console::onKeyboardLedsChange(bool fNumLock, bool fCapsLock, bool fScrollLock) 5808 5752 { … … 5810 5754 AssertComRCReturnVoid(autoCaller.rc()); 5811 5755 5812 #if ndef CONSOLE_WITH_EVENT_CACHE5813 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);5814 #else 5815 /* We need a write lock because we alter the cached callback data */5816 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 5817 5818 /* save the callback arguments */5819 mCallbackData.klc.numLock = fNumLock;5820 mCallbackData.klc.capsLock = fCapsLock;5821 mCallbackData.klc.scrollLock = fScrollLock;5822 mCallbackData.klc.valid = true;5756 #ifdef CONSOLE_WITH_EVENT_CACHE 5757 { 5758 /* We need a write lock because we alter the cached callback data */ 5759 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 5760 5761 /* save the callback arguments */ 5762 mCallbackData.klc.numLock = fNumLock; 5763 mCallbackData.klc.capsLock = fCapsLock; 5764 mCallbackData.klc.scrollLock = fScrollLock; 5765 mCallbackData.klc.valid = true; 5766 } 5823 5767 #endif 5824 5768 … … 5826 5770 } 5827 5771 5828 /**5829 * @note Locks this object for reading.5830 */5831 5772 void Console::onUSBDeviceStateChange(IUSBDevice *aDevice, bool aAttached, 5832 5773 IVirtualBoxErrorInfo *aError) … … 5835 5776 AssertComRCReturnVoid(autoCaller.rc()); 5836 5777 5837 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);5838 5778 fireUSBDeviceStateChangedEvent(mEventSource, aDevice, aAttached, aError); 5839 5779 } 5840 5780 5841 /**5842 * @note Locks this object for reading.5843 */5844 5781 void Console::onRuntimeError(BOOL aFatal, IN_BSTR aErrorID, IN_BSTR aMessage) 5845 5782 { … … 5847 5784 AssertComRCReturnVoid(autoCaller.rc()); 5848 5785 5849 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);5850 5786 fireRuntimeErrorEvent(mEventSource, aFatal, aErrorID, aMessage); 5851 5787 } 5852 5788 5853 /**5854 * @note Locks this object for reading.5855 */5856 5789 HRESULT Console::onShowWindow(BOOL aCheck, BOOL *aCanShow, LONG64 *aWinId) 5857 5790 { … … 5865 5798 AssertComRCReturnRC(autoCaller.rc()); 5866 5799 5867 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);5868 5800 VBoxEventDesc evDesc; 5869 5870 5801 if (aCheck) 5871 5802 { … … 5887 5818 else 5888 5819 { 5889 Assert (FALSE);5820 AssertFailed(); 5890 5821 *aCanShow = TRUE; 5891 5822 } … … 5904 5835 evDesc.getEvent(pEvent.asOutParam()); 5905 5836 ComPtr<IShowWindowEvent> pShowEvent = pEvent; 5906 LONG64 aEvWinId = 0;5907 5837 if (pShowEvent) 5908 5838 { 5909 pShowEvent->COMGETTER(WinId)(&aEvWinId); 5910 if ((aEvWinId != 0) && (*aWinId == 0)) 5911 *aWinId = aEvWinId; 5839 LONG64 iEvWinId = 0; 5840 pShowEvent->COMGETTER(WinId)(&iEvWinId); 5841 if (iEvWinId != 0 && *aWinId == 0) 5842 *aWinId = iEvWinId; 5912 5843 } 5913 5844 else 5914 Assert (FALSE);5845 AssertFailed(); 5915 5846 } 5916 5847 }
Note:
See TracChangeset
for help on using the changeset viewer.