Skip to content

Commit

Permalink
Make SettingsManager a plain C++ class
Browse files Browse the repository at this point in the history
  • Loading branch information
uklotzde committed Jul 7, 2020
1 parent b25fe09 commit 04017eb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 49 deletions.
28 changes: 16 additions & 12 deletions src/mixxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ MixxxMainWindow::MixxxMainWindow(QApplication* pApp, const CmdlineArgs& args)
StatsManager::createInstance();
}

m_pSettingsManager = make_parented<SettingsManager>(this, args.getSettingsPath());
m_pSettingsManager = std::make_unique<SettingsManager>(args.getSettingsPath());

initializeKeyboard();

Expand Down Expand Up @@ -284,10 +284,10 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) {

m_pRecordingManager = new RecordingManager(pConfig, m_pEngine);


#ifdef __BROADCAST__
m_pBroadcastManager = new BroadcastManager(m_pSettingsManager,
m_pSoundManager);
m_pBroadcastManager = new BroadcastManager(
m_pSettingsManager.get(),
m_pSoundManager);
#endif

launchProgress(11);
Expand Down Expand Up @@ -470,9 +470,17 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) {
}

// Initialize preference dialog
m_pPrefDlg = new DlgPreferences(this, m_pSkinLoader, m_pSoundManager, m_pPlayerManager,
m_pControllerManager, m_pVCManager, pLV2Backend, m_pEffectsManager,
m_pSettingsManager, m_pLibrary);
m_pPrefDlg = new DlgPreferences(
this,
m_pSkinLoader,
m_pSoundManager,
m_pPlayerManager,
m_pControllerManager,
m_pVCManager,
pLV2Backend,
m_pEffectsManager,
m_pSettingsManager.get(),
m_pLibrary);
m_pPrefDlg->setWindowIcon(QIcon(":/images/mixxx_icon.svg"));
m_pPrefDlg->setHidden(true);

Expand Down Expand Up @@ -819,11 +827,7 @@ void MixxxMainWindow::finalize() {
Sandbox::shutdown();

qDebug() << t.elapsed(false).debugMillisWithUnit() << "deleting SettingsManager";
{
auto* pSettingsManager = m_pSettingsManager.get();
m_pSettingsManager = nullptr; // reset parented_ptr
delete pSettingsManager;
}
m_pSettingsManager.reset();

delete m_pKeyboard;
delete m_pKbdConfig;
Expand Down
25 changes: 3 additions & 22 deletions src/mixxx.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
/***************************************************************************
mixxx.h - description
-------------------
begin : Mon Feb 18 09:48:17 CET 2002
copyright : (C) 2002 by Tue and Ken Haste Andersen
email :
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef MIXXX_H
#define MIXXX_H
#pragma once

#include <QMainWindow>
#include <QSharedPointer>
#include <QString>
#include <memory>

#include "preferences/configobject.h"
#include "preferences/constants.h"
Expand Down Expand Up @@ -143,7 +126,7 @@ class MixxxMainWindow : public QMainWindow {
QWidget* m_pWidgetParent;
LaunchImage* m_pLaunchImage;

parented_ptr<SettingsManager> m_pSettingsManager;
std::unique_ptr<SettingsManager> m_pSettingsManager;

// The effects processing system
EffectsManager* m_pEffectsManager;
Expand Down Expand Up @@ -204,5 +187,3 @@ class MixxxMainWindow : public QMainWindow {
static const int kMicrophoneCount;
static const int kAuxiliaryCount;
};

#endif
6 changes: 2 additions & 4 deletions src/preferences/settingsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
#include "preferences/upgrade.h"
#include "util/assert.h"

SettingsManager::SettingsManager(QObject* pParent,
const QString& settingsPath)
: QObject(pParent),
m_bShouldRescanLibrary(false) {
SettingsManager::SettingsManager(const QString& settingsPath)
: m_bShouldRescanLibrary(false) {
// First make sure the settings path exists. If we don't then other parts of
// Mixxx (such as the library) will produce confusing errors.
if (!QDir(settingsPath).exists()) {
Expand Down
14 changes: 3 additions & 11 deletions src/preferences/settingsmanager.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
#ifndef PREFERENCES_SETTINGSMANAGER_H
#define PREFERENCES_SETTINGSMANAGER_H

#include <QObject>
#include <QSharedPointer>
#include <QString>
#pragma once

#include "preferences/broadcastsettings.h"
#include "preferences/usersettings.h"

class SettingsManager : public QObject {
Q_OBJECT
class SettingsManager {
public:
SettingsManager(QObject* pParent, const QString& settingsPath);
explicit SettingsManager(const QString& settingsPath);
virtual ~SettingsManager();

UserSettingsPointer settings() const {
Expand All @@ -37,5 +31,3 @@ class SettingsManager : public QObject {
bool m_bShouldRescanLibrary;
BroadcastSettingsPointer m_pBroadcastSettings;
};

#endif /* PREFERENCES_SETTINGSMANAGER_H */

0 comments on commit 04017eb

Please sign in to comment.