History

Setup DependencyManager before any member of Application

Atlante45 committed 11 years ago

Commit 36db5471 parent 27cc3d22 files · +43 −11Browse files

Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all

Unified · Split

interface/src/Application.cpp+42−11
@@ -85,6 +85,8 @@ · 84 unmodified lines
8585 #include "Util.h"
8686
8787 #include "audio/AudioToolBox.h"
88+#include "audio/AudioIOStatsRenderer.h"
89+#include "audio/AudioScope.h"
8890
8991 #include "devices/DdeFaceTracker.h"
9092 #include "devices/Faceshift.h"
@@ -142,8 +144,43 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 51 unmodified lines
142144 }
143145 }
144146
147+bool setupEssentials(int& argc, char** argv) {
148+ unsigned int listenPort = 0; // bind to an ephemeral port by default
149+ const char** constArgv = const_cast<const char**>(argv);
150+ const char* portStr = getCmdOption(argc, constArgv, "--listenPort");
151+ if (portStr) {
152+ listenPort = atoi(portStr);
153+ }
154+
155+ DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
156+
157+ // Set dependencies
158+ DependencyManager::get<GLCanvas>();
159+ auto glCanvas = DependencyManager::set<GLCanvas>();
160+ auto addressManager = DependencyManager::set<AddressManager>();
161+ auto nodeList = DependencyManager::set<NodeList>(NodeType::Agent, listenPort);
162+ auto geometryCache = DependencyManager::set<GeometryCache>();
163+ auto glowEffect = DependencyManager::set<GlowEffect>();
164+ auto faceshift = DependencyManager::set<Faceshift>();
165+ auto audio = DependencyManager::set<Audio>();
166+ auto audioScope = DependencyManager::set<AudioScope>();
167+ auto audioIOStatsRenderer = DependencyManager::set<AudioIOStatsRenderer>();
168+ auto deferredLightingEffect = DependencyManager::set<DeferredLightingEffect>();
169+ auto ambientOcclusionEffect = DependencyManager::set<AmbientOcclusionEffect>();
170+ auto textureCache = DependencyManager::set<TextureCache>();
171+ auto animationCache = DependencyManager::set<AnimationCache>();
172+ auto visage = DependencyManager::set<Visage>();
173+ auto ddeFaceTracker = DependencyManager::set<DdeFaceTracker>();
174+ auto modelBlender = DependencyManager::set<ModelBlender>();
175+ auto audioToolBox = DependencyManager::set<AudioToolBox>();
176+
177+ return true;
178+}
179+
180+
145181 Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
146182 QApplication(argc, argv),
183+ _dependencyManagerIsSetup(setupEssentials(argc, argv)),
147184 _window(new MainWindow(desktop())),
148185 _toolWindow(NULL),
149186 _nodeThread(new QThread(this)),
@@ -189,7 +226,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 39 unmodified lines
189226 _isVSyncOn(true),
190227 _aboutToQuit(false)
191228 {
192− auto glCanvas = DependencyManager::set<GLCanvas>();
229+ auto glCanvas = DependencyManager::get<GLCanvas>();
230+ auto nodeList = DependencyManager::get<NodeList>();
193231 Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
194232
195233
@@ -223,23 +261,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 27 unmodified lines
223261 _window->setMenuBar(Menu::getInstance());
224262
225263 _runningScriptsWidget = new RunningScriptsWidget(_window);
226−
227− unsigned int listenPort = 0; // bind to an ephemeral port by default
228− const char** constArgv = const_cast<const char**>(argv);
229− const char* portStr = getCmdOption(argc, constArgv, "--listenPort");
230− if (portStr) {
231− listenPort = atoi(portStr);
232− }
233264
234265 // start the nodeThread so its event loop is running
235266 _nodeThread->start();
236267
237268 // make sure the node thread is given highest priority
238269 _nodeThread->setPriority(QThread::TimeCriticalPriority);
239−
240− // put the NodeList and datagram processing on the node thread
241− auto nodeList = DependencyManager::set<NodeList>(NodeType::Agent, listenPort);
242270
271+ // put the NodeList and datagram processing on the node thread
243272 nodeList->moveToThread(_nodeThread);
244273 _datagramProcessor.moveToThread(_nodeThread);
245274
@@ -460,6 +489,8 @@ Application::~Application() { · 214 unmodified lines
460489 Menu::getInstance()->deleteLater();
461490
462491 _myAvatar = NULL;
492+
493+ DependencyManager::destroy<GLCanvas>();
463494 }
464495
465496 void Application::saveSettings() {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t