mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Make MachineInfo a singleton class
Because on windows MachineInfo take a little time to init, we make it to a singleton. MachineInfo is build the first time in main.cpp. Now all other places where we use MachineInfo (aboutqetdialog and configdialog) gui don't hang anymore in waiting to MachineInfo finish to build.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#define MACHINE_INFO_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
|
||||
/**
|
||||
@brief The MachineInfo class
|
||||
@@ -26,19 +27,48 @@
|
||||
*/
|
||||
class MachineInfo
|
||||
{
|
||||
static MachineInfo *m_instance;
|
||||
public:
|
||||
explicit MachineInfo();
|
||||
static int32_t i_max_screen_width();
|
||||
static int32_t i_max_screen_height();
|
||||
static MachineInfo *instance()
|
||||
{
|
||||
static QMutex mutex;
|
||||
if (!m_instance)
|
||||
{
|
||||
mutex.lock();
|
||||
if (!m_instance) {
|
||||
m_instance = new MachineInfo();
|
||||
}
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
static void dropInstance()
|
||||
{
|
||||
static QMutex mutex;
|
||||
if (m_instance) {
|
||||
mutex.lock();
|
||||
delete m_instance;
|
||||
m_instance = nullptr;
|
||||
mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
int32_t i_max_screen_width();
|
||||
int32_t i_max_screen_height();
|
||||
QString compilation_info();
|
||||
void send_info_to_debug();
|
||||
|
||||
|
||||
private:
|
||||
MachineInfo();
|
||||
void init_get_Screen_info();
|
||||
void init_get_cpu_info();
|
||||
void init_get_cpu_info_linux();
|
||||
void init_get_cpu_info_winnt();
|
||||
void init_get_cpu_info_macos();
|
||||
|
||||
struct Pc
|
||||
{
|
||||
struct Screen
|
||||
|
||||
Reference in New Issue
Block a user