mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
config: singleton shared pointer refactor
This commit is contained in:
parent
7d1f0e2a69
commit
9405b17e14
@ -36,7 +36,12 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
|
||||
#define QT_TO_UTF8(str) str.toUtf8().constData()
|
||||
|
||||
Config* Config::_instance = new Config();
|
||||
ConfigPtr Config::_instance = ConfigPtr(new Config());
|
||||
|
||||
ConfigPtr Config::Current()
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
|
||||
Config::Config() :
|
||||
ServerEnabled(true),
|
||||
@ -179,8 +184,3 @@ bool Config::CheckAuth(QString response)
|
||||
|
||||
return authSuccess;
|
||||
}
|
||||
|
||||
Config* Config::Current()
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
|
10
src/Config.h
10
src/Config.h
@ -20,9 +20,15 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
#define CONFIG_H
|
||||
|
||||
#include <QString>
|
||||
#include <QSharedPointer>
|
||||
|
||||
class Config;
|
||||
typedef QSharedPointer<Config> ConfigPtr;
|
||||
|
||||
class Config {
|
||||
public:
|
||||
static ConfigPtr Current();
|
||||
|
||||
Config();
|
||||
~Config();
|
||||
void Load();
|
||||
@ -46,10 +52,8 @@ class Config {
|
||||
QString SessionChallenge;
|
||||
bool SettingsLoaded;
|
||||
|
||||
static Config* Current();
|
||||
|
||||
private:
|
||||
static Config* _instance;
|
||||
static ConfigPtr _instance;
|
||||
};
|
||||
|
||||
#endif // CONFIG_H
|
||||
|
@ -41,7 +41,7 @@ SettingsDialog::SettingsDialog(QWidget* parent) :
|
||||
}
|
||||
|
||||
void SettingsDialog::showEvent(QShowEvent* event) {
|
||||
Config* conf = Config::Current();
|
||||
auto conf = Config::Current();
|
||||
|
||||
ui->serverEnabled->setChecked(conf->ServerEnabled);
|
||||
ui->serverPort->setValue(conf->ServerPort);
|
||||
@ -68,7 +68,7 @@ void SettingsDialog::AuthCheckboxChanged() {
|
||||
}
|
||||
|
||||
void SettingsDialog::FormAccepted() {
|
||||
Config* conf = Config::Current();
|
||||
auto conf = Config::Current();
|
||||
|
||||
conf->ServerEnabled = ui->serverEnabled->isChecked();
|
||||
conf->ServerPort = ui->serverPort->value();
|
||||
|
@ -45,7 +45,7 @@ bool obs_module_load(void) {
|
||||
QT_VERSION_STR, qVersion());
|
||||
|
||||
// Core setup
|
||||
Config* config = Config::Current();
|
||||
auto config = Config::Current();
|
||||
config->Load();
|
||||
|
||||
WSEvents::Instance = new WSEvents(WSServer::Current());
|
||||
|
Loading…
x
Reference in New Issue
Block a user