Hello all.

I use both these libraries in my project. Below I describe a conflict between them.

See ole initialization code used in Qt:
file C:\Qt\4.8.3\src\gui\kernel\qapplication_win.cpp
Qt Code:
  1. #ifndef Q_WS_WINCE
  2. // Initialize OLE/COM
  3. // S_OK means success and S_FALSE means that it has already
  4. // been initialized
  5. HRESULT r;
  6. r = OleInitialize(0);
  7. if (r != S_OK && r != S_FALSE) {
  8. qWarning("Qt: Could not initialize OLE (error %x)", (unsigned int)r);
  9. }
  10. #endif
To copy to clipboard, switch view to plain text mode 
WinAPI function OleInitialize returns error code defined as RPC_E_CHANGED_MODE (Cannot change thread mode after it is set), because OLE has already been initialized by ptlib by
::CoInitializeEx(NULL, COINIT_MULTITHREADED);
invocation.
qWarning shows this message: "Qt: Could not initialize OLE (error 80010106)".

But after application is closed, it crashes with access violation and following call stack:


Here we see ole32.dll...
Apparently, root cause is differed OLE initialization parameters and maybe combined OLE usage.

Can anyone help me to reveal a workaround?
Thank you.