diff options
| -rw-r--r-- | compat/win32-com.cpp | 53 | ||||
| -rw-r--r-- | dinput/dinput.cpp | 3 | ||||
| -rw-r--r-- | dinput/dinput.hpp | 1 | 
3 files changed, 12 insertions, 45 deletions
| diff --git a/compat/win32-com.cpp b/compat/win32-com.cpp index a037b3ba..689e1411 100644 --- a/compat/win32-com.cpp +++ b/compat/win32-com.cpp @@ -2,61 +2,30 @@  #include "win32-com.hpp" +#include "compat/util.hpp" +  #include <QString>  #include <QThread>  #include <QDebug>  bool OPENTRACK_COMPAT_EXPORT init_com_threading(com_type t)  { -    static thread_local com_type initialized = com_type(-1); - -    if (initialized != com_type(-1)) -    { -        if (t != initialized) -        { -            QString tp("invalid type"); -            switch (t) -            { -            case com_apartment: -                tp = "apartment threaded"; -                break; -            case com_multithreaded: -                tp = "multithreaded"; -                break; -            } - -            qDebug() << "COM for thread" -                     << QThread::currentThread() << QThread::currentThreadId() -                     << "already initialized to" << tp; - -            return false; -        } - -        return true; -    } -      HRESULT ret = CoInitializeEx(0, t);      if (ret != S_OK && ret != S_FALSE)      { -        qDebug() << "CoInitializeEx failed:" << ret << GetLastError(); +        qDebug() << "CoInitializeEx failed" << (progn ( +                                                     switch (ret) +                                                     { +                                                         case RPC_E_CHANGED_MODE: +                                                            return QStringLiteral("COM threading mode already set"); +                                                         default: +                                                            return QStringLiteral("Unknown error ") + QString::number(long(ret)); +                                                     } +                                                     ));          return false;      } -#if 0 -    if (t == com_apartment) -    { -        ret = OleInitialize(nullptr); - -        if (ret != S_OK && ret != S_FALSE) -            qDebug() << "OleInitialize() failed:" << ret << GetLastError(); - -        return false; -    } -#endif - -    initialized = t; -      return true;  }  #endif diff --git a/dinput/dinput.cpp b/dinput/dinput.cpp index 9556815a..1b0cf09d 100644 --- a/dinput/dinput.cpp +++ b/dinput/dinput.cpp @@ -6,11 +6,10 @@  std::atomic<int> dinput_handle::refcnt;  std::atomic_flag dinput_handle::init_lock = ATOMIC_FLAG_INIT; -dinput_handle::di_t dinput_handle::handle(dinput_handle::make_di());  LPDIRECTINPUT8& dinput_handle::init_di()  { -    init_com_threading(com_apartment); +    init_com_threading(com_multithreaded);      static LPDIRECTINPUT8 di_ = nullptr;      if (di_ == nullptr) diff --git a/dinput/dinput.hpp b/dinput/dinput.hpp index 53f1c4af..59873527 100644 --- a/dinput/dinput.hpp +++ b/dinput/dinput.hpp @@ -27,7 +27,6 @@ public:  private:      static std::atomic<int> refcnt;      static std::atomic_flag init_lock; -    static di_t handle;      static LPDIRECTINPUT8& init_di();  public: | 
