Changeset 35638 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jan 19, 2011 7:10:49 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 69546
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.cpp
r35524 r35638 22 22 #if !defined (VBOX_WITH_XPCOM) 23 23 24 24 25 #else /* !defined (VBOX_WITH_XPCOM) */ 25 26 … … 87 88 * Initializes COM/XPCOM. 88 89 */ 89 HRESULT COMBase::InitializeCOM( )90 HRESULT COMBase::InitializeCOM(bool fGui) 90 91 { 91 92 LogFlowFuncEnter(); 92 93 93 /* Note: On Win32, Qt somehow calls CoInitialize[Ex]() during creation of 94 * the QApplication instance (didn't explore deeply why it does so) with 95 * different flags which is incompatible with our multithreaded 96 * apartment. com::Initialize() will properly care of this situation. */ 97 98 HRESULT rc = com::Initialize(); 94 HRESULT rc = com::Initialize(fGui); 99 95 100 96 #if defined (VBOX_WITH_XPCOM) -
trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.h
r34740 r35638 203 203 public: 204 204 205 static HRESULT InitializeCOM( );205 static HRESULT InitializeCOM(bool fGui); 206 206 static HRESULT CleanupCOM(); 207 207 … … 355 355 356 356 /* no arbitrary instance creations */ 357 COMBase() : mRC (S_OK) {} ;357 COMBase() : mRC (S_OK) {} 358 358 359 359 #if defined (VBOX_WITH_XPCOM) … … 633 633 // constructors & destructor 634 634 635 CInterface() : mIface (NULL) {} 636 637 CInterface (const CInterface &that) : B (that), mIface (that.mIface) 638 { 639 addref (mIface); 640 } 641 642 CInterface (I *aIface) : mIface (aIface) { addref (mIface); } 643 644 virtual ~CInterface() { release (mIface); } 635 CInterface() 636 { 637 clear(); 638 } 639 640 CInterface (const CInterface &that) : B (that) 641 { 642 clear(); 643 mIface = that.mIface; 644 addref(ptr()); 645 } 646 647 CInterface (I *aIface) 648 { 649 clear(); 650 setPtr (aIface); 651 addref (aIface); 652 } 653 654 virtual ~CInterface() 655 { 656 detach(); 657 #ifdef DEBUG 658 mDead = true; 659 #endif 660 } 645 661 646 662 // utility methods 647 648 663 void createInstance (const CLSID &aClsId) 649 664 { 650 AssertMsg (!mIface, ("Instance is already non-NULL\n")); 651 if (!mIface) 652 { 665 AssertMsg (ptr() == NULL, ("Instance is already non-NULL\n")); 666 if (ptr() == NULL) 667 { 668 I* pObj = NULL; 653 669 #if !defined (VBOX_WITH_XPCOM) 654 655 670 B::mRC = CoCreateInstance (aClsId, NULL, CLSCTX_ALL, 656 _ATL_IIDOF (I), (void **) &mIface); 657 658 #else /* !defined (VBOX_WITH_XPCOM) */ 659 671 _ATL_IIDOF (I), (void **) &pObj); 672 #else 660 673 nsCOMPtr <nsIComponentManager> manager; 661 674 B::mRC = NS_GetComponentManager (getter_AddRefs (manager)); 662 675 if (SUCCEEDED (B::mRC)) 663 676 B::mRC = manager->CreateInstance (aClsId, nsnull, NS_GET_IID (I), 664 (void **) &mIface); 665 666 #endif /* !defined (VBOX_WITH_XPCOM) */ 667 677 (void **) &pObj); 678 #endif 679 680 if (SUCCEEDED (B::mRC)) 681 setPtr(pObj); 682 else 683 setPtr(NULL); 684 668 685 /* fetch error info, but don't assert if it's missing -- many other 669 686 * reasons can lead to an error (w/o providing error info), not only 670 687 * the instance initialization code (that should always provide it) */ 671 688 B::fetchErrorInfo (NULL, NULL); 672 }689 } 673 690 } 674 691 … … 680 697 void attach (OI *aIface) 681 698 { 699 #ifdef DEBUG 700 Assert(!mDead); 701 #endif 682 702 /* be aware of self assignment */ 703 I* amIface = ptr(); 683 704 addref (aIface); 684 release ( mIface);705 release (amIface); 685 706 if (aIface) 686 707 { 687 mIface = NULL;688 B::mRC = aIface->QueryInterface (COM_IIDOF (I), (void **) & mIface);708 amIface = NULL; 709 B::mRC = aIface->QueryInterface (COM_IIDOF (I), (void **) &amIface); 689 710 release (aIface); 711 setPtr(amIface); 690 712 } 691 713 else 692 714 { 693 mIface = NULL;715 setPtr(NULL); 694 716 B::mRC = S_OK; 695 717 } … … 699 721 void attach (I *aIface) 700 722 { 723 #ifdef DEBUG 724 Assert(!mDead); 725 #endif 701 726 /* be aware of self assignment */ 702 727 addref (aIface); 703 release ( mIface);704 mIface = aIface;728 release (ptr()); 729 setPtr(aIface); 705 730 B::mRC = S_OK; 706 731 }; 707 732 708 733 /** Detaches from the underlying interface pointer. */ 709 void detach() { release (mIface); mIface = NULL; } 734 void detach() 735 { 736 #ifdef DEBUG 737 Assert(!mDead); 738 #endif 739 release (ptr()); 740 setPtr(NULL); 741 } 710 742 711 743 /** Returns @c true if not attached to any interface pointer. */ 712 bool isNull() const { return mIface == NULL; } 744 bool isNull() const 745 { 746 #ifdef DEBUG 747 Assert(!mDead); 748 #endif 749 return mIface == NULL; 750 } 713 751 714 752 /** … … 733 771 CInterface &operator= (const CInterface &that) 734 772 { 735 attach (that. mIface);773 attach (that.ptr()); 736 774 B::operator= (that); 737 775 return *this; … … 748 786 * else but in generated wrappers and for debugging. You've been warned. 749 787 */ 750 I *raw() const { return mIface; } 751 752 bool operator== (const CInterface &that) const { return mIface == that.mIface; } 753 bool operator!= (const CInterface &that) const { return mIface != that.mIface; } 754 755 /** 756 * @todo: rethink if we'll ever need 'protected' back, removed to allow mIface access in rather 757 * nontrivial inheritance situations, see 'friend wrappers' code in COMWrappers.xsl 758 */ 759 //protected: 760 761 mutable I *mIface; 788 I *raw() const 789 { 790 return ptr(); 791 } 792 793 bool operator== (const CInterface &that) const { return ptr() == that.ptr(); } 794 bool operator!= (const CInterface &that) const { return ptr() != that.ptr(); } 795 796 I* ptr() const 797 { 798 #ifdef DEBUG 799 Assert(!mDead); 800 #endif 801 802 return mIface; 803 } 804 805 void setPtr(I* aObj) const 806 { 807 #ifdef DEBUG 808 Assert(!mDead); 809 #endif 810 mIface = aObj; 811 } 812 813 private: 814 #ifdef DEBUG 815 bool mDead; 816 #endif 817 mutable I * mIface; 818 819 void clear() 820 { 821 mIface = NULL; 822 #ifdef DEBUG 823 mDead = false; 824 #endif 825 } 762 826 }; 763 827 … … 776 840 explicit CUnknown (const CInterface <OI, OB> &that) 777 841 { 778 attach (that. mIface);842 attach (that.ptr()); 779 843 if (SUCCEEDED (mRC)) 780 844 { … … 802 866 CUnknown &operator= (const CInterface <OI, OB> &that) 803 867 { 804 attach (that. mIface);868 attach (that.ptr()); 805 869 if (SUCCEEDED (mRC)) 806 870 { … … 833 897 return *this; 834 898 } 835 836 /* @internal Used in generated wrappers. Never use directly. */837 IUnknown *&rawRef() { return mIface; };838 899 }; 839 900 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/COMWrappers.xsl
r34783 r35638 951 951 <xsl:text>
{
</xsl:text> 952 952 <!-- iface assertion --> 953 <xsl:text> AssertReturnVoid( mIface);
</xsl:text>953 <xsl:text> AssertReturnVoid(ptr());
</xsl:text> 954 954 <!-- method call --> 955 955 <xsl:call-template name="composeMethodCall"> … … 990 990 <xsl:text>;
</xsl:text> 991 991 <!-- iface assertion --> 992 <xsl:text> AssertReturn( mIface, a</xsl:text>992 <xsl:text> AssertReturn(ptr(), a</xsl:text> 993 993 <xsl:call-template name="capitalize"> 994 994 <xsl:with-param name="str" select="$return/@name"/> … … 1097 1097 </xsl:choose> 1098 1098 <!-- start the call --> 1099 <xsl:text> mRC = mIface-></xsl:text>1099 <xsl:text> mRC = ptr()-></xsl:text> 1100 1100 <xsl:choose> 1101 1101 <!-- attribute method call --> … … 1137 1137 </xsl:choose> 1138 1138 <xsl:text>);
</xsl:text> 1139 1140 <xsl:text>#ifdef RT_OS_WINDOWS
</xsl:text> 1141 <xsl:text> Assert(mRC != RPC_E_WRONG_THREAD);
</xsl:text> 1142 <xsl:text>#endif;
</xsl:text> 1143 1139 1144 <!-- apply 'post-call' hooks --> 1140 1145 <xsl:choose> … … 1201 1206 <xsl:if test="$supports='strict' or $supports='yes'"> 1202 1207 <xsl:text> if (RT_UNLIKELY(mRC != S_OK))
 {
</xsl:text> 1203 <xsl:text> fetchErrorInfo( mIface, &COM_IIDOF(Base::Iface));
</xsl:text>1208 <xsl:text> fetchErrorInfo(ptr(), &COM_IIDOF(Base::Iface));
</xsl:text> 1204 1209 <xsl:if test="$supports='strict'"> 1205 1210 <xsl:text> AssertMsg(errInfo.isFullAvailable(), </xsl:text> … … 1294 1299 <xsl:with-param name="str" select="@name"/> 1295 1300 </xsl:call-template> 1296 <xsl:choose> 1297 <xsl:when test="@type='$unknown'"> 1298 <xsl:text>.raw()</xsl:text> 1299 </xsl:when> 1300 <xsl:otherwise> 1301 <xsl:text>.mIface</xsl:text> 1302 </xsl:otherwise> 1303 </xsl:choose> 1301 <xsl:text>.ptr()</xsl:text> 1304 1302 </xsl:when> 1305 1303 <xsl:when test="$isOut"> 1306 <xsl:text>&a</xsl:text> 1307 <xsl:call-template name="capitalize"> 1308 <xsl:with-param name="str" select="@name"/> 1309 </xsl:call-template> 1310 <xsl:choose> 1311 <xsl:when test="@type='$unknown'"> 1312 <xsl:text>.rawRef()</xsl:text> 1313 </xsl:when> 1314 <xsl:otherwise> 1315 <xsl:text>.mIface</xsl:text> 1316 </xsl:otherwise> 1317 </xsl:choose> 1304 <xsl:value-of select="concat('&', @name, 'Ptr')"/> 1318 1305 </xsl:when> 1319 1306 </xsl:choose> … … 1783 1770 )"/> 1784 1771 1772 <xsl:variable name="is_out" select="( 1773 (name()='attribute' and not($isSetter)) or 1774 (name()='param' and (@dir='out' or @dir='return')) 1775 )"/> 1776 1785 1777 <xsl:choose> 1786 1778 <xsl:when test="$when='pre-call'"> … … 1838 1830 </xsl:if> 1839 1831 </xsl:when> 1832 <xsl:when test="$is_out and ($is_iface or (@type='$unknown'))"> 1833 <xsl:text> </xsl:text> 1834 <xsl:choose> 1835 <xsl:when test="@type='$unknown'"> 1836 <xsl:text>IUnknown</xsl:text> 1837 </xsl:when> 1838 <xsl:otherwise> 1839 <xsl:value-of select="@type"/> 1840 </xsl:otherwise> 1841 </xsl:choose> 1842 <xsl:value-of select="concat('* ',@name,'Ptr = NULL; ')"/> 1843 </xsl:when> 1840 1844 </xsl:choose> 1841 1845 </xsl:when> … … 1843 1847 <xsl:choose> 1844 1848 <xsl:when test="@safearray='yes'"> 1845 <xsl:if test="(name()='attribute' and not($isSetter)) or 1846 (name()='param' and (@dir='out' or @dir='return'))"> 1849 <xsl:if test="$is_out"> 1847 1850 <!-- convert SafeArray to QVector --> 1848 1851 <xsl:choose> … … 1864 1867 </xsl:if> 1865 1868 </xsl:when> 1869 <xsl:when test="$is_out and ($is_iface or (@type='$unknown'))"> 1870 <xsl:text> a</xsl:text> 1871 <xsl:call-template name="capitalize"> 1872 <xsl:with-param name="str" select="@name"/> 1873 </xsl:call-template> 1874 <xsl:value-of select="concat('.setPtr(',@name,'Ptr); ')"/> 1875 </xsl:when> 1866 1876 </xsl:choose> 1867 1877 </xsl:when> -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r35634 r35638 2390 2390 { 2391 2391 LogFlow (("MediaEnumThread started.\n")); 2392 COMBase::InitializeCOM( );2392 COMBase::InitializeCOM(false); 2393 2393 2394 2394 CVirtualBox mVBox = vboxGlobal().virtualBox(); … … 4765 4765 #endif 4766 4766 4767 #ifdef Q_WS_WIN 4768 /* COM for the main thread is initialized in main() */ 4769 #else 4770 HRESULT rc = COMBase::InitializeCOM(); 4767 HRESULT rc = COMBase::InitializeCOM(true); 4771 4768 if (FAILED (rc)) 4772 4769 { … … 4774 4771 return; 4775 4772 } 4776 #endif4777 4773 4778 4774 mVBox.createInstance (CLSID_VirtualBox); -
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r35636 r35638 290 290 ShutUpAppKit(); 291 291 # endif 292 293 #ifdef Q_WS_WIN294 /* Initialize COM early, before QApplication calls OleInitialize(), to295 * make sure we enter the multi threaded apartment instead of a single296 * threaded one. Note that this will make some non-threadsafe system297 * services that use OLE and require STA (such as Drag&Drop) not work298 * anymore, however it's still better because otherwise VBox will not work299 * on some Windows XP systems at all since it requires MTA (we cannot300 * leave STA by calling CoUninitialize() and re-enter MTA on those systems301 * for some unknown reason), see also src/VBox/Main/glue/initterm.cpp. */302 /// @todo find a proper solution that satisfies both OLE and VBox303 HRESULT hrc = COMBase::InitializeCOM();304 #endif305 292 306 293 for (int i=0; i<argc; i++) … … 464 451 do 465 452 { 466 #ifdef Q_WS_WIN467 /* Check for the COM error after we've initialized Qt */468 if (FAILED (hrc))469 {470 vboxProblem().cannotInitCOM (hrc);471 break;472 }473 #endif474 475 453 if (!vboxGlobal().isValid()) 476 454 break; … … 555 533 } 556 534 557 #ifdef Q_WS_WIN558 /* See COMBase::initializeCOM() above */559 if (SUCCEEDED (hrc))560 COMBase::CleanupCOM();561 #endif562 563 535 LogFlowFunc (("rc=%d\n", rc)); 564 536 LogFlowFuncLeave(); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQImage.cpp
r35613 r35638 67 67 QImage scaledImage; 68 68 69 69 70 /* If scaled-factor is set and current image is NOT null: */ 70 71 if (m_scaledSize.isValid() && !m_img.isNull()) … … 93 94 QPainter painter(m_pMachineView->viewport()); 94 95 96 95 97 if ((ulong)r.width() < m_width * 2 / 3) 96 98 {
Note:
See TracChangeset
for help on using the changeset viewer.