Initialize WMI only once, remove init calls from everywhere it is called and initialize it once as a static variable

* See comment: https://gitlab.com/CalcProgrammer1/OpenRGB/-/issues/1581#note_684260496
This commit is contained in:
Adam Honse committed 2021-09-24 18:05:04 +00:00
1 parent eaaed7fd83
commit dd47256f06
6 files changed
+2 -5

No files matched your search

@@ -16,7 +16,6 @@ static void DetectAsusTUFLaptopWMIControllers(std::vector<RGBController*>&)
// For now, checking for "TUF Gaming" should suffice
Wmi wmi;
wmi.init();
std::vector<QueryObj> systemProduct;
if (wmi.query("SELECT * FROM Win32_ComputerSystemProduct", systemProduct))
-1
View File
@@ -27,7 +27,6 @@ DMIInfo::DMIInfo()
manufacturer = "";
HRESULT hres;
Wmi wmi;
wmi.init();
// Query WMI for Win32_PnPSignedDriver entries with names matching "SMBUS" or "SM BUS"
// These devices may be browsed under Device Manager -> System Devices
-1
View File
@@ -498,7 +498,6 @@ void i2c_smbus_i801_detect()
i2c_smbus_interface * bus;
HRESULT hres;
Wmi wmi;
wmi.init();
// Query WMI for Win32_PnPSignedDriver entries with names matching "SMBUS" or "SM BUS"
// These devices may be browsed under Device Manager -> System Devices
-1
View File
@@ -192,7 +192,6 @@ void i2c_smbus_piix4_detect()
i2c_smbus_interface * bus;
HRESULT hres;
Wmi wmi;
wmi.init();
// Query WMI for Win32_PnPSignedDriver entries with names matching "SMBUS" or "SM BUS"
// These devices may be browsed under Device Manager -> System Devices
+1
View File
@@ -2,6 +2,7 @@
IWbemLocator* Wmi::pLoc = nullptr;
IWbemServices* Wmi::pSvc = nullptr;
HRESULT WmiInit = Wmi::init();
// Taken from https://stackoverflow.com/questions/215963/
// Convert a wide Unicode string to an UTF8 string
+1 -1
View File
@@ -26,7 +26,7 @@ public:
~Wmi();
// Initialises connection to WMI host
HRESULT init();
static HRESULT init();
HRESULT query(std::string queryStr,
std::vector<QueryObj>& queryVectorOut,