summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Schürmann <daschuer@mixxx.org>2020-08-05 09:55:44 +0200
committerGitHub <noreply@github.com>2020-08-05 09:55:44 +0200
commitb747cc135eda88e302712e99225a5b3660ea57da (patch)
tree2535d5681ff12cac87f8b7af3a016cd27724f40e
parentaca1f28e1f873655f51628933136f7c4a1230334 (diff)
parenta6f59f7766a64cb44a67f02ff1705aaeb7e62b30 (diff)
Merge pull request #2988 from Holzhaus/explict-playerinfo
mixer/playerinfo: Make implicit PlayerInfo creation explicit
-rw-r--r--src/mixer/playerinfo.cpp10
-rw-r--r--src/mixer/playerinfo.h1
-rw-r--r--src/mixxx.cpp1
-rw-r--r--src/test/autodjprocessor_test.cpp20
-rw-r--r--src/test/signalpathtest.h21
5 files changed, 34 insertions, 19 deletions
diff --git a/src/mixer/playerinfo.cpp b/src/mixer/playerinfo.cpp
index 2a9c98e206..47771586fc 100644
--- a/src/mixer/playerinfo.cpp
+++ b/src/mixer/playerinfo.cpp
@@ -42,9 +42,17 @@ PlayerInfo::~PlayerInfo() {
clearControlCache();
}
+PlayerInfo& PlayerInfo::create() {
+ VERIFY_OR_DEBUG_ASSERT(!s_pPlayerInfo) {
+ return *s_pPlayerInfo;
+ }
+ s_pPlayerInfo = new PlayerInfo();
+ return *s_pPlayerInfo;
+}
+
// static
PlayerInfo& PlayerInfo::instance() {
- if (!s_pPlayerInfo) {
+ VERIFY_OR_DEBUG_ASSERT(s_pPlayerInfo) {
s_pPlayerInfo = new PlayerInfo();
}
return *s_pPlayerInfo;
diff --git a/src/mixer/playerinfo.h b/src/mixer/playerinfo.h
index 9a94eb15a6..5aee4fc06c 100644
--- a/src/mixer/playerinfo.h
+++ b/src/mixer/playerinfo.h
@@ -28,6 +28,7 @@
class PlayerInfo : public QObject {
Q_OBJECT
public:
+ static PlayerInfo& create();
static PlayerInfo& instance();
static void destroy();
TrackPointer getTrackInfo(const QString& group);
diff --git a/src/mixxx.cpp b/src/mixxx.cpp
index d4bc6e4d12..869ab53db6 100644
--- a/src/mixxx.cpp
+++ b/src/mixxx.cpp
@@ -321,6 +321,7 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) {
&PlayerManager::noVinylControlInputConfigured,
this,
&MixxxMainWindow::slotNoVinylControlInputConfigured);
+ PlayerInfo::create();
for (int i = 0; i < kMicrophoneCount; ++i) {
m_pPlayerManager->addMicrophone();
diff --git a/src/test/autodjprocessor_test.cpp b/src/test/autodjprocessor_test.cpp
index ce85211060..dfb12f7e23 100644
--- a/src/test/autodjprocessor_test.cpp
+++ b/src/test/autodjprocessor_test.cpp
@@ -1,19 +1,21 @@
-#include <gtest/gtest.h>
+#include "library/autodj/autodjprocessor.h"
+
#include <gmock/gmock.h>
+#include <gtest/gtest.h>
-#include <QString>
#include <QScopedPointer>
+#include <QString>
-#include "test/librarytest.h"
-#include "library/autodj/autodjprocessor.h"
-#include "control/controlpushbutton.h"
-#include "control/controlpotmeter.h"
#include "control/controllinpotmeter.h"
+#include "control/controlpotmeter.h"
+#include "control/controlpushbutton.h"
#include "engine/engine.h"
-#include "mixer/playermanager.h"
#include "mixer/basetrackplayer.h"
-#include "track/track.h"
+#include "mixer/playerinfo.h"
+#include "mixer/playermanager.h"
#include "sources/soundsourceproxy.h"
+#include "test/librarytest.h"
+#include "track/track.h"
using ::testing::_;
using ::testing::Return;
@@ -187,6 +189,7 @@ class AutoDJProcessorTest : public LibraryTest {
}
pPlayerManager.reset(new MockPlayerManager());
+ PlayerInfo::create();
// Setup 4 fake decks.
ON_CALL(*pPlayerManager, getPlayer(QString("[Channel1]")))
@@ -210,6 +213,7 @@ class AutoDJProcessorTest : public LibraryTest {
}
virtual ~AutoDJProcessorTest() {
+ PlayerInfo::destroy();
}
TrackId addTrackToCollection(const QString& trackLocation) {
diff --git a/src/test/signalpathtest.h b/src/test/signalpathtest.h
index d6bd67d070..10d5541651 100644
--- a/src/test/signalpathtest.h
+++ b/src/test/signalpathtest.h
@@ -1,25 +1,25 @@
-#ifndef ENGINEBACKENDTEST_H_
-#define ENGINEBACKENDTEST_H_
+#pragma once
-#include <gtest/gtest.h>
#include <gmock/gmock.h>
+#include <gtest/gtest.h>
-#include <QtDebug>
#include <QTest>
+#include <QtDebug>
-#include "preferences/usersettings.h"
#include "control/controlobject.h"
-#include "mixer/deck.h"
#include "effects/effectsmanager.h"
-#include "engine/enginebuffer.h"
#include "engine/bufferscalers/enginebufferscale.h"
#include "engine/channels/enginechannel.h"
#include "engine/channels/enginedeck.h"
-#include "engine/enginemaster.h"
#include "engine/controls/ratecontrol.h"
+#include "engine/enginebuffer.h"
+#include "engine/enginemaster.h"
#include "engine/sync/enginesync.h"
+#include "mixer/deck.h"
+#include "mixer/playerinfo.h"
#include "mixer/previewdeck.h"
#include "mixer/sampler.h"
+#include "preferences/usersettings.h"
#include "test/mixxxtest.h"
#include "util/defs.h"
#include "util/memory.h"
@@ -94,6 +94,8 @@ class BaseSignalPathTest : public MixxxTest {
m_pEngineSync = m_pEngineMaster->getEngineSync();
ControlObject::set(ConfigKey("[Master]", "enabled"), 1.0);
+
+ PlayerInfo::create();
}
~BaseSignalPathTest() override {
@@ -111,6 +113,7 @@ class BaseSignalPathTest : public MixxxTest {
delete m_pEffectsManager;
delete m_pVisualsManager;
delete m_pNumDecks;
+ PlayerInfo::destroy();
}
void addDeck(EngineDeck* pDeck) {
@@ -234,5 +237,3 @@ class SignalPathTest : public BaseSignalPathTest {
loadTrack(m_pMixerDeck3, pTrack);
}
};
-
-#endif /* ENGINEBACKENDTEST_H_ */