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

Exception in QAxClientSite::releaseAll

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Done
    • Affects Version/s: 5.9.5, 5.12.0, 5.12.1
    • Fix Version/s: 5.14.0 Alpha
    • Component/s: ActiveX Support
    • Labels:
      None
    • Platform/s:
      Windows
    • Commits:
      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

            Assignee:
            vhilshei Volker Hilsheimer
            Reporter:
            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