Do WMDM static init in main() to avoid static mutex.
This commit is contained in:
parent
42e67dcc3c
commit
8501ac0d96
|
@ -31,8 +31,7 @@
|
|||
BYTE abPVK[] = {0x00};
|
||||
BYTE abCert[] = {0x00};
|
||||
|
||||
QMutex WmdmThread::sLoadLock;
|
||||
bool WmdmThread::sIsLoaded;
|
||||
bool WmdmThread::sIsLoaded = false;
|
||||
|
||||
decltype(&CSecureChannelClient_New) WmdmThread::_CSecureChannelClient_New;
|
||||
decltype(&CSecureChannelClient_Free) WmdmThread::_CSecureChannelClient_Free;
|
||||
|
@ -45,10 +44,9 @@ WmdmThread::WmdmThread()
|
|||
: device_manager_(NULL),
|
||||
sac_(NULL)
|
||||
{
|
||||
if (!MaybeStaticInit()) {
|
||||
qLog(Warning) << "Error loading SAC shim DLL";
|
||||
if (!sIsLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialise COM
|
||||
CoInitialize(0);
|
||||
|
||||
|
@ -104,8 +102,7 @@ T Resolve(QLibrary* library, const char* name) {
|
|||
|
||||
} // namespace
|
||||
|
||||
bool WmdmThread::MaybeStaticInit() {
|
||||
QMutexLocker locker(&sLoadLock);
|
||||
bool WmdmThread::StaticInit() {
|
||||
if (!sIsLoaded) {
|
||||
QLibrary library(QCoreApplication::applicationDirPath() + "/sac_shim.dll");
|
||||
if (!library.load()) {
|
||||
|
|
|
@ -37,8 +37,8 @@ public:
|
|||
IWMDMDevice* GetDeviceByCanonicalName(const QString& device_name);
|
||||
IWMDMStorage* GetRootStorage(const QString& device_name);
|
||||
|
||||
static bool StaticInit();
|
||||
private:
|
||||
static bool MaybeStaticInit();
|
||||
|
||||
Q_DISABLE_COPY(WmdmThread);
|
||||
|
||||
|
@ -51,7 +51,6 @@ private:
|
|||
static decltype(&CSecureChannelClient_SetInterface) _CSecureChannelClient_SetInterface;
|
||||
static decltype(&CSecureChannelClient_Authenticate) _CSecureChannelClient_Authenticate;
|
||||
|
||||
static QMutex sLoadLock;
|
||||
static bool sIsLoaded;
|
||||
};
|
||||
|
||||
|
|
|
@ -99,6 +99,7 @@ using boost::scoped_ptr;
|
|||
|
||||
#ifdef Q_OS_WIN32
|
||||
# include <qtsparkle/Updater>
|
||||
# include "devices/wmdmthread.h"
|
||||
#endif
|
||||
|
||||
// Load sqlite plugin on windows and mac.
|
||||
|
@ -421,6 +422,10 @@ int main(int argc, char *argv[]) {
|
|||
mpris::Mpris mpris(&app);
|
||||
#endif
|
||||
|
||||
if (!WmdmThread::StaticInit()) {
|
||||
qLog(Warning) << "Failed to initialise SAC shim";
|
||||
}
|
||||
|
||||
// Window
|
||||
MainWindow w(&app, tray_icon.get(), &osd);
|
||||
#ifdef Q_OS_DARWIN
|
||||
|
|
Loading…
Reference in New Issue