History

Merge branch 'workload' of https://github.com/highfidelity/hifi into workload

samcake committed 8 years ago

Commit 1dc69882 parents 023941a a689c58146 files · +2945 −4095Browse files

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

Unified · Split

interface/src/Application.cpp+108−3
@@ -252,6 +252,7 @@ extern "C" { · 251 unmodified lines
252252
253253 #if defined(Q_OS_ANDROID)
254254 #include <android/log.h>
255+#include "AndroidHelper.h"
255256 #endif
256257
257258 enum ApplicationEvent {
@@ -1070,6 +1071,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 812 unmodified lines
10701071 if (steamClient) {
10711072 qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << steamClient->getSteamVRBuildID();
10721073 }
1074+ setCrashAnnotation("steam", property(hifi::properties::STEAM).toBool() ? "1" : "0");
1075+
10731076 qCDebug(interfaceapp) << "[VERSION] Build sequence:" << qPrintable(applicationVersion());
10741077 qCDebug(interfaceapp) << "[VERSION] MODIFIED_ORGANIZATION:" << BuildInfo::MODIFIED_ORGANIZATION;
10751078 qCDebug(interfaceapp) << "[VERSION] VERSION:" << BuildInfo::VERSION;
@@ -1155,6 +1158,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 79 unmodified lines
11551158 const DomainHandler& domainHandler = nodeList->getDomainHandler();
11561159
11571160 connect(&domainHandler, SIGNAL(domainURLChanged(QUrl)), SLOT(domainURLChanged(QUrl)));
1161+ connect(&domainHandler, &DomainHandler::domainURLChanged, [](QUrl domainURL){
1162+ setCrashAnnotation("domain", domainURL.toString().toStdString());
1163+ });
11581164 connect(&domainHandler, SIGNAL(resetting()), SLOT(resettingDomain()));
11591165 connect(&domainHandler, SIGNAL(connectedToDomain(QUrl)), SLOT(updateWindowTitle()));
11601166 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle()));
@@ -1200,6 +1206,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 39 unmodified lines
12001206 auto dialogsManager = DependencyManager::get<DialogsManager>();
12011207 connect(accountManager.data(), &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog);
12021208 connect(accountManager.data(), &AccountManager::usernameChanged, this, &Application::updateWindowTitle);
1209+ connect(accountManager.data(), &AccountManager::usernameChanged, [](QString username){
1210+ setCrashAnnotation("username", username.toStdString());
1211+ });
12031212
12041213 // set the account manager's root URL and trigger a login request if we don't have the access token
12051214 accountManager->setIsAgent(true);
@@ -1217,6 +1226,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 11 unmodified lines
12171226 connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateThreadPoolCount);
12181227 connect(this, &Application::activeDisplayPluginChanged, this, [](){
12191228 qApp->setProperty(hifi::properties::HMD, qApp->isHMDMode());
1229+ auto displayPlugin = qApp->getActiveDisplayPlugin();
1230+ setCrashAnnotation("display_plugin", displayPlugin->getName().toStdString());
1231+ setCrashAnnotation("hmd", displayPlugin->isHmd() ? "1" : "0");
12201232 });
12211233 connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateSystemTabletMode);
12221234
@@ -1224,6 +1236,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1 unmodified line
12241236 connect(myAvatar.get(), &MyAvatar::positionGoneTo,
12251237 DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);
12261238
1239+ connect(myAvatar.get(), &MyAvatar::skeletonModelURLChanged, [](){
1240+ QUrl avatarURL = qApp->getMyAvatar()->getSkeletonModelURL();
1241+ setCrashAnnotation("avatar", avatarURL.toString().toStdString());
1242+ });
1243+
1244+
12271245 // Inititalize sample before registering
12281246 _sampleSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/sample.wav"));
12291247
@@ -1241,6 +1259,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 11 unmodified lines
12411259
12421260 connect(scriptEngines, &ScriptEngines::scriptsReloading, scriptEngines, [this] {
12431261 getEntities()->reloadEntityScripts();
1262+ loadAvatarScripts(getMyAvatar()->getScriptUrls());
12441263 }, Qt::QueuedConnection);
12451264
12461265 connect(scriptEngines, &ScriptEngines::scriptLoadError,
@@ -1388,6 +1407,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 141 unmodified lines
13881407 userActivityLogger.disable(false);
13891408 }
13901409
1410+ QString machineFingerPrint = uuidStringWithoutCurlyBraces(FingerprintUtils::getMachineFingerprint());
1411+
13911412 if (userActivityLogger.isEnabled()) {
13921413 // sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value.
13931414 // The value will be 0 if the user blew away settings this session, which is both a feature and a bug.
@@ -1437,11 +1458,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 43 unmodified lines
14371458 properties["first_run"] = firstRun.get();
14381459
14391460 // add the user's machine ID to the launch event
1440− properties["machine_fingerprint"] = uuidStringWithoutCurlyBraces(FingerprintUtils::getMachineFingerprint());
1461+ properties["machine_fingerprint"] = machineFingerPrint;
14411462
14421463 userActivityLogger.logAction("launch", properties);
14431464 }
14441465
1466+ setCrashAnnotation("machine_fingerprint", machineFingerPrint.toStdString());
1467+
14451468 _entityEditSender.setMyAvatar(myAvatar.get());
14461469
14471470 // The entity octree will have to know about MyAvatar for the parentJointName import
@@ -2712,6 +2735,9 @@ void Application::initializeUi() { · 1264 unmodified lines
27122735 offscreenUi->resume();
27132736 connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect& r){
27142737 resizeGL();
2738+ if (_touchscreenVirtualPadDevice) {
2739+ _touchscreenVirtualPadDevice->resize();
2740+ }
27152741 });
27162742
27172743 // This will set up the input plugins UI
@@ -3148,11 +3174,14 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 430 unmodified lines
31483174
31493175 // If this is a first run we short-circuit the address passed in
31503176 if (firstRun.get()) {
3151−#if !defined(Q_OS_ANDROID)
3177+#if defined(Q_OS_ANDROID)
3178+ qCDebug(interfaceapp) << "First run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("default location") : addressLookupString);
3179+ DependencyManager::get<AddressManager>()->loadSettings(addressLookupString);
3180+#else
31523181 showHelp();
3153−#endif
31543182 DependencyManager::get<AddressManager>()->goToEntry();
31553183 sentTo = SENT_TO_ENTRY;
3184+#endif
31563185 firstRun.set(false);
31573186
31583187 } else {
@@ -3722,6 +3751,12 @@ void Application::keyPressEvent(QKeyEvent* event) { · 563 unmodified lines
37223751 void Application::keyReleaseEvent(QKeyEvent* event) {
37233752 _keysPressed.remove(event->key());
37243753
3754+#if defined(Q_OS_ANDROID)
3755+ if (event->key() == Qt::Key_Back) {
3756+ event->accept();
3757+ openAndroidActivity("Home");
3758+ }
3759+#endif
37253760 _controllerScriptingInterface->emitKeyReleaseEvent(event); // send events to any registered scripts
37263761
37273762 // if one of our scripts have asked to capture this event, then stop processing it
@@ -4798,6 +4833,31 @@ void Application::init() { · 1070 unmodified lines
47984833 _entitySimulation->setWorkloadSpace(getEntities()->getWorkloadSpace());
47994834 }
48004835
4836+void Application::loadAvatarScripts(const QVector<QString>& urls) {
4837+ auto scriptEngines = DependencyManager::get<ScriptEngines>();
4838+ auto runningScripts = scriptEngines->getRunningScripts();
4839+ for (auto url : urls) {
4840+ int index = runningScripts.indexOf(url);
4841+ if (index < 0) {
4842+ auto scriptEnginePointer = scriptEngines->loadScript(url, false);
4843+ if (scriptEnginePointer) {
4844+ scriptEnginePointer->setType(ScriptEngine::Type::AVATAR);
4845+ }
4846+ }
4847+ }
4848+}
4849+
4850+void Application::unloadAvatarScripts() {
4851+ auto scriptEngines = DependencyManager::get<ScriptEngines>();
4852+ auto urls = scriptEngines->getRunningScripts();
4853+ for (auto url : urls) {
4854+ auto scriptEngine = scriptEngines->getScriptEngine(url);
4855+ if (scriptEngine->getType() == ScriptEngine::Type::AVATAR) {
4856+ scriptEngines->stopScript(url, false);
4857+ }
4858+ }
4859+}
4860+
48014861 void Application::updateLOD(float deltaTime) const {
48024862 PerformanceTimer perfTimer("LOD");
48034863 // adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode
@@ -7843,6 +7903,26 @@ void Application::switchDisplayMode() { · 3039 unmodified lines
78437903 _previousHMDWornStatus = currentHMDWornStatus;
78447904 }
78457905
7906+void Application::setShowBulletWireframe(bool value) {
7907+ _physicsEngine->setShowBulletWireframe(value);
7908+}
7909+
7910+void Application::setShowBulletAABBs(bool value) {
7911+ _physicsEngine->setShowBulletAABBs(value);
7912+}
7913+
7914+void Application::setShowBulletContactPoints(bool value) {
7915+ _physicsEngine->setShowBulletContactPoints(value);
7916+}
7917+
7918+void Application::setShowBulletConstraints(bool value) {
7919+ _physicsEngine->setShowBulletConstraints(value);
7920+}
7921+
7922+void Application::setShowBulletConstraintLimits(bool value) {
7923+ _physicsEngine->setShowBulletConstraintLimits(value);
7924+}
7925+
78467926 void Application::startHMDStandBySession() {
78477927 _autoSwitchDisplayModeSupportedHMDPlugin->startStandBySession();
78487928 }
@@ -8024,4 +8104,29 @@ void Application::saveNextPhysicsStats(QString filename) { · 175 unmodified lines
80248104 _physicsEngine->saveNextPhysicsStats(filename);
80258105 }
80268106
8107+void Application::openAndroidActivity(const QString& activityName) {
8108+#if defined(Q_OS_ANDROID)
8109+ AndroidHelper::instance().requestActivity(activityName);
8110+#endif
8111+}
8112+
8113+#if defined(Q_OS_ANDROID)
8114+void Application::enterBackground() {
8115+ QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
8116+ "stop", Qt::BlockingQueuedConnection);
8117+ //GC: commenting it out until we fix it
8118+ //getActiveDisplayPlugin()->deactivate();
8119+}
8120+void Application::enterForeground() {
8121+ QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
8122+ "start", Qt::BlockingQueuedConnection);
8123+ //GC: commenting it out until we fix it
8124+ /*if (!getActiveDisplayPlugin() || !getActiveDisplayPlugin()->activate()) {
8125+ qWarning() << "Could not re-activate display plugin";
8126+ }*/
8127+
8128+}
8129+#endif
8130+
8131+#include "Application_jni.cpp"
80278132 #include "Application.moc"

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