Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-74096

Exception in QAxClientSite::releaseAll

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.14.0 Alpha
    • 5.9.5, 5.12.0, 5.12.1
    • ActiveX Support
    • None
    • Windows
    • d9a196a9a51d2a40ec7a64cacacab5608195be86 (qt/qtactiveqt/dev)

    Description

      When hosting a .Net control via QAxWidget, an exception is thrown in call to

       

      m_spOleObject->Unadvise(m_dwOleObject);
      

      Exception text: "COM object that has been separated from its underlying RCW cannot be used"

      The reason of the exception is a previous call to

       

      m_spOleObject->SetClientSite(0);
      

       

       

      When .Net ActiveX wrapper (from .Net framework) performs that function, it completely destroys RCW for the client site:

       

      internal void SetClientSite(UnsafeNativeMethods.IOleClientSite value) {
      	...
      	if (UnsafeNativeMethods.IsComObject(clientSite)) {
      		IntSecurity.UnmanagedCode.Assert();
      		try {
      			Marshal.FinalReleaseComObject(clientSite);
      		}
      		finally {
      			CodeAccessPermission.RevertAssert();
      		}
      	}
      	...
      }

      The call to FinalReleaseComObject completely destroys RCW (Runtime Callable Wrapper) for COM object.

      Due to the fact that both IOleClientSite and IAdviseSink interfaces are represented by the same QAxClientSite object, the next call to Unadvise fails with an exception.

       

      Proposed solution:

      If there is no obvious reason why the order of the calls is as is, I propose to change the order:

      m_spOleObject->Unadvise(m_dwOleObject);
      m_spOleObject->SetClientSite(0);
      

      Thus the RCW won't be deleted.

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vhilshei Volker Hilsheimer
            cadmiy Artyom Chirkov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes