History

Moved GLCanvas in DM and DM to QSharedPointers

Atlante45 committed 11 years ago

Commit e5e2eb41 parent 68430e124 files · +143 −146Browse files

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

Unified · Split

interface/src/Application.cpp+28−26
@@ -194,7 +194,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 193 unmodified lines
194194 _isVSyncOn(true),
195195 _aboutToQuit(false)
196196 {
197− GLCanvas* glCanvas = DependencyManager::get<GLCanvas>();
197+ QSharedPointer<GLCanvas> glCanvas = DependencyManager::get<GLCanvas>();
198198
199199 // read the ApplicationInfo.ini file for Name/Version/Domain information
200200 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
@@ -365,7 +365,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 164 unmodified lines
365365
366366 ResourceCache::setRequestLimit(3);
367367
368− _window->setCentralWidget(glCanvas);
368+ _window->setCentralWidget(glCanvas.data());
369369
370370 restoreSizeAndPosition();
371371
@@ -393,7 +393,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 21 unmodified lines
393393
394394 checkVersion();
395395
396− _overlays.init(glCanvas); // do this before scripts load
396+ _overlays.init(glCanvas.data()); // do this before scripts load
397397
398398 LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree());
399399 LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard);
@@ -442,6 +442,8 @@ void Application::aboutToQuit() { · 42 unmodified lines
442442 }
443443
444444 Application::~Application() {
445+ DependencyManager::get<GLCanvas>()->setParent(NULL);
446+
445447 _entities.getTree()->setSimulation(NULL);
446448 qInstallMessageHandler(NULL);
447449
@@ -1046,7 +1048,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 598 unmodified lines
10461048 if (isShifted) {
10471049 _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f);
10481050 if (TV3DManager::isConnected()) {
1049− GLCanvas* glCanvas = DependencyManager::get<GLCanvas>();
1051+ QSharedPointer<GLCanvas> glCanvas = DependencyManager::get<GLCanvas>();
10501052 TV3DManager::configureCamera(_myCamera, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
10511053 }
10521054 } else {
@@ -1059,7 +1061,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 6 unmodified lines
10591061 if (isShifted) {
10601062 _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f);
10611063 if (TV3DManager::isConnected()) {
1062− GLCanvas* glCanvas = DependencyManager::get<GLCanvas>();
1064+ QSharedPointer<GLCanvas> glCanvas = DependencyManager::get<GLCanvas>();
10631065 TV3DManager::configureCamera(_myCamera, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
10641066 }
10651067
@@ -1532,7 +1534,7 @@ void Application::idle() { · 466 unmodified lines
15321534
15331535 void Application::checkBandwidthMeterClick() {
15341536 // ... to be called upon button release
1535− GLCanvas* glCanvas = DependencyManager::get<GLCanvas>();
1537+ QSharedPointer<GLCanvas> glCanvas = DependencyManager::get<GLCanvas>();
15361538 if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) &&
15371539 Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
15381540 Menu::getInstance()->isOptionChecked(MenuOption::UserInterface) &&
@@ -1568,7 +1570,7 @@ void Application::setFullscreen(bool fullscreen) { · 29 unmodified lines
15681570 }
15691571
15701572 void Application::setEnable3DTVMode(bool enable3DTVMode) {
1571− GLCanvas* glCanvas = DependencyManager::get<GLCanvas>();
1573+ QSharedPointer<GLCanvas> glCanvas = DependencyManager::get<GLCanvas>();
15721574 resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
15731575 }
15741576
@@ -1594,7 +1596,7 @@ void Application::setEnableVRMode(bool enableVRMode) { · 19 unmodified lines
15941596 _myCamera.setHmdRotation(glm::quat());
15951597 }
15961598
1597− GLCanvas* glCanvas = DependencyManager::get<GLCanvas>();
1599+ QSharedPointer<GLCanvas> glCanvas = DependencyManager::get<GLCanvas>();
15981600 resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
15991601 }
16001602
@@ -1657,7 +1659,7 @@ glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVox · 56 unmodified lines
16571659
16581660 bool Application::mouseOnScreen() const {
16591661 if (OculusManager::isConnected()) {
1660− GLCanvas* glCanvas = DependencyManager::get<GLCanvas>();
1662+ QSharedPointer<GLCanvas> glCanvas = DependencyManager::get<GLCanvas>();
16611663 return getMouseX() >= 0 && getMouseX() <= glCanvas->getDeviceWidth() &&
16621664 getMouseY() >= 0 && getMouseY() <= glCanvas->getDeviceHeight();
16631665 }
@@ -1699,13 +1701,13 @@ int Application::getMouseDragStartedY() const { · 35 unmodified lines
16991701 }
17001702
17011703 FaceTracker* Application::getActiveFaceTracker() {
1702− Faceshift* faceshift = DependencyManager::get<Faceshift>();
1703− Visage* visage = DependencyManager::get<Visage>();
1704− DdeFaceTracker* dde = DependencyManager::get<DdeFaceTracker>();
1704+ QSharedPointer<Faceshift> faceshift = DependencyManager::get<Faceshift>();
1705+ QSharedPointer<Visage> visage = DependencyManager::get<Visage>();
1706+ QSharedPointer<DdeFaceTracker> dde = DependencyManager::get<DdeFaceTracker>();
17051707
1706− return (dde->isActive() ? static_cast<FaceTracker*>(dde) :
1707− (faceshift->isActive() ? static_cast<FaceTracker*>(faceshift) :
1708− (visage->isActive() ? static_cast<FaceTracker*>(visage) : NULL)));
1708+ return (dde->isActive() ? static_cast<FaceTracker*>(dde.data()) :
1709+ (faceshift->isActive() ? static_cast<FaceTracker*>(faceshift.data()) :
1710+ (visage->isActive() ? static_cast<FaceTracker*>(visage.data()) : NULL)));
17091711 }
17101712
17111713 struct SendVoxelsOperationArgs {
@@ -1778,7 +1780,7 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 66 unmodified lines
17781780 QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
17791781 QString suggestedName = desktopLocation.append("/voxels.svo");
17801782
1781− QString fileNameString = QFileDialog::getSaveFileName(DependencyManager::get<GLCanvas>(),
1783+ QString fileNameString = QFileDialog::getSaveFileName(DependencyManager::get<GLCanvas>().data(),
17821784 tr("Export Voxels"), suggestedName,
17831785 tr("Sparse Voxel Octree Files (*.svo)"));
17841786 QByteArray fileNameAscii = fileNameString.toLocal8Bit();
@@ -2034,9 +2036,9 @@ void Application::init() { · 249 unmodified lines
20342036
20352037 _metavoxels.init();
20362038
2037− GLCanvas* glCanvas = DependencyManager::get<GLCanvas>();
2038− _audio.init(glCanvas);
2039− _rearMirrorTools = new RearMirrorTools(glCanvas, _mirrorViewRect, _settings);
2039+ QSharedPointer<GLCanvas> glCanvas = DependencyManager::get<GLCanvas>();
2040+ _audio.init(glCanvas.data());
2041+ _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect, _settings);
20402042
20412043 connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
20422044 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
@@ -2115,7 +2117,7 @@ void Application::updateMouseRay() { · 72 unmodified lines
21152117 void Application::updateFaceshift() {
21162118 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
21172119 PerformanceWarning warn(showWarnings, "Application::updateFaceshift()");
2118− Faceshift* faceshift = DependencyManager::get<Faceshift>();
2120+ Faceshift* faceshift = DependencyManager::get<Faceshift>().data();
21192121 // Update faceshift
21202122 faceshift->update();
21212123
@@ -2919,7 +2921,7 @@ void Application::updateShadowMap() { · 797 unmodified lines
29192921
29202922 fbo->release();
29212923
2922− GLCanvas* glCanvas = DependencyManager::get<GLCanvas>();
2924+ QSharedPointer<GLCanvas> glCanvas = DependencyManager::get<GLCanvas>();
29232925 glViewport(0, 0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
29242926 }
29252927
@@ -3247,7 +3249,7 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 321 unmodified lines
32473249 }
32483250
32493251 glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
3250− GLCanvas* glCanvas = DependencyManager::get<GLCanvas>();
3252+ QSharedPointer<GLCanvas> glCanvas = DependencyManager::get<GLCanvas>();
32513253 float horizontalScale = glCanvas->getDeviceWidth() / 2.0f;
32523254 float verticalScale = glCanvas->getDeviceHeight() / 2.0f;
32533255
@@ -4260,7 +4262,7 @@ void Application::setPreviousScriptLocation(const QString& previousScriptLocatio · 1006 unmodified lines
42604262
42614263 void Application::loadDialog() {
42624264
4263− QString fileNameString = QFileDialog::getOpenFileName(DependencyManager::get<GLCanvas>(),
4265+ QString fileNameString = QFileDialog::getOpenFileName(DependencyManager::get<GLCanvas>().data(),
42644266 tr("Open Script"),
42654267 getPreviousScriptLocation(),
42664268 tr("JavaScript Files (*.js)"));
@@ -4297,7 +4299,7 @@ void Application::loadScriptURLDialog() { · 30 unmodified lines
42974299
42984300 void Application::toggleLogDialog() {
42994301 if (! _logDialog) {
4300− _logDialog = new LogDialog(DependencyManager::get<GLCanvas>(), getLogger());
4302+ _logDialog = new LogDialog(DependencyManager::get<GLCanvas>().data(), getLogger());
43014303 }
43024304
43034305 if (_logDialog->isVisible()) {
@@ -4357,7 +4359,7 @@ void Application::parseVersionXml() { · 53 unmodified lines
43574359 }
43584360
43594361 if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) {
4360− new UpdateDialog(DependencyManager::get<GLCanvas>(), releaseNotes, latestVersion, downloadUrl);
4362+ new UpdateDialog(DependencyManager::get<GLCanvas>().data(), releaseNotes, latestVersion, downloadUrl);
43614363 }
43624364 sender->deleteLater();
43634365 }
@@ -4390,7 +4392,7 @@ void Application::takeSnapshot() { · 26 unmodified lines
43904392 }
43914393
43924394 if (!_snapshotShareDialog) {
4393− _snapshotShareDialog = new SnapshotShareDialog(fileName, DependencyManager::get<GLCanvas>());
4395+ _snapshotShareDialog = new SnapshotShareDialog(fileName, DependencyManager::get<GLCanvas>().data());
43944396 }
43954397 _snapshotShareDialog->show();
43964398 }

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