History

Merge remote-tracking branch 'hifi/master' into android_places_goto

Cristian Luis Duarte committed 8 years ago

Commit 401bf2f2 parents e47173a 1e25d48168 files · +5803 −1664Browse files

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

Unified · Split

interface/src/Application.cpp+111−42
@@ -145,6 +145,16 @@ · 144 unmodified lines
145145 #include <avatars-renderer/ScriptAvatar.h>
146146 #include <RenderableEntityItem.h>
147147
148+#include <AnimationLogging.h>
149+#include <AvatarLogging.h>
150+#include <ScriptEngineLogging.h>
151+#include <ModelFormatLogging.h>
152+#include <controllers/Logging.h>
153+#include <NetworkLogging.h>
154+#include <shared/StorageLogging.h>
155+#include <ScriptEngineLogging.h>
156+#include <ui/Logging.h>
157+
148158 #include "AudioClient.h"
149159 #include "audio/AudioScope.h"
150160 #include "avatar/AvatarManager.h"
@@ -1307,6 +1317,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1156 unmodified lines
13071317 // Needs to happen AFTER the render engine initialization to access its configuration
13081318 initializeUi();
13091319
1320+ updateVerboseLogging();
1321+
13101322 init();
13111323 qCDebug(interfaceapp, "init() complete.");
13121324
@@ -1323,49 +1335,48 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 10 unmodified lines
13231335 // Make sure we don't time out during slow operations at startup
13241336 updateHeartbeat();
13251337
1326− // sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value.
1327− // The value will be 0 if the user blew away settings this session, which is both a feature and a bug.
1328− static const QString TESTER = "HIFI_TESTER";
1329− auto gpuIdent = GPUIdent::getInstance();
1330− auto glContextData = getGLContextData();
1331− QJsonObject properties = {
1332− { "version", applicationVersion() },
1333− { "tester", QProcessEnvironment::systemEnvironment().contains(TESTER) },
1334− { "previousSessionCrashed", _previousSessionCrashed },
1335− { "previousSessionRuntime", sessionRunTime.get() },
1336− { "cpu_architecture", QSysInfo::currentCpuArchitecture() },
1337− { "kernel_type", QSysInfo::kernelType() },
1338− { "kernel_version", QSysInfo::kernelVersion() },
1339− { "os_type", QSysInfo::productType() },
1340− { "os_version", QSysInfo::productVersion() },
1341− { "gpu_name", gpuIdent->getName() },
1342− { "gpu_driver", gpuIdent->getDriver() },
1343− { "gpu_memory", static_cast<qint64>(gpuIdent->getMemory()) },
1344− { "gl_version_int", glVersionToInteger(glContextData.value("version").toString()) },
1345− { "gl_version", glContextData["version"] },
1346− { "gl_vender", glContextData["vendor"] },
1347− { "gl_sl_version", glContextData["sl_version"] },
1348− { "gl_renderer", glContextData["renderer"] },
1349− { "ideal_thread_count", QThread::idealThreadCount() }
1350− };
1351− auto macVersion = QSysInfo::macVersion();
1352− if (macVersion != QSysInfo::MV_None) {
1353− properties["os_osx_version"] = QSysInfo::macVersion();
1354− }
1355− auto windowsVersion = QSysInfo::windowsVersion();
1356− if (windowsVersion != QSysInfo::WV_None) {
1357− properties["os_win_version"] = QSysInfo::windowsVersion();
1338+ constexpr auto INSTALLER_INI_NAME = "installer.ini";
1339+ auto iniPath = QDir(applicationDirPath()).filePath(INSTALLER_INI_NAME);
1340+ QFile installerFile { iniPath };
1341+ std::unordered_map<QString, QString> installerKeyValues;
1342+ if (installerFile.open(QIODevice::ReadOnly)) {
1343+ while (!installerFile.atEnd()) {
1344+ auto line = installerFile.readLine();
1345+ if (!line.isEmpty()) {
1346+ auto index = line.indexOf("=");
1347+ if (index >= 0) {
1348+ installerKeyValues[line.mid(0, index).trimmed()] = line.mid(index + 1).trimmed();
1349+ }
1350+ }
1351+ }
13581352 }
13591353
1360− ProcessorInfo procInfo;
1361− if (getProcessorInfo(procInfo)) {
1362− properties["processor_core_count"] = procInfo.numProcessorCores;
1363− properties["logical_processor_count"] = procInfo.numLogicalProcessors;
1364− properties["processor_l1_cache_count"] = procInfo.numProcessorCachesL1;
1365− properties["processor_l2_cache_count"] = procInfo.numProcessorCachesL2;
1366− properties["processor_l3_cache_count"] = procInfo.numProcessorCachesL3;
1354+ // In practice we shouldn't run across installs that don't have a known installer type.
1355+ // Client or Client+Server installs should always have the installer.ini next to their
1356+ // respective interface.exe, and Steam installs will be detected as such. If a user were
1357+ // to delete the installer.ini, though, and as an example, we won't know the context of the
1358+ // original install.
1359+ constexpr auto INSTALLER_KEY_TYPE = "type";
1360+ constexpr auto INSTALLER_KEY_CAMPAIGN = "campaign";
1361+ constexpr auto INSTALLER_TYPE_UNKNOWN = "unknown";
1362+ constexpr auto INSTALLER_TYPE_STEAM = "steam";
1363+
1364+ auto typeIt = installerKeyValues.find(INSTALLER_KEY_TYPE);
1365+ QString installerType = INSTALLER_TYPE_UNKNOWN;
1366+ if (typeIt == installerKeyValues.end()) {
1367+ if (property(hifi::properties::STEAM).toBool()) {
1368+ installerType = INSTALLER_TYPE_STEAM;
1369+ }
1370+ } else {
1371+ installerType = typeIt->second;
13671372 }
13681373
1374+ auto campaignIt = installerKeyValues.find(INSTALLER_KEY_CAMPAIGN);
1375+ QString installerCampaign = campaignIt != installerKeyValues.end() ? campaignIt->second : "";
1376+
1377+ qDebug() << "Detected installer type:" << installerType;
1378+ qDebug() << "Detected installer campaign:" << installerCampaign;
1379+
13691380 // add firstRun flag from settings to launch event
13701381 Setting::Handle<bool> firstRun { Settings::firstRun, true };
13711382
@@ -1387,6 +1398,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 15 unmodified lines
13871398 QJsonObject properties = {
13881399 { "version", applicationVersion() },
13891400 { "tester", QProcessEnvironment::systemEnvironment().contains(TESTER) },
1401+ { "installer_campaign", installerCampaign },
1402+ { "installer_type", installerType },
13901403 { "previousSessionCrashed", _previousSessionCrashed },
13911404 { "previousSessionRuntime", sessionRunTime.get() },
13921405 { "cpu_architecture", QSysInfo::currentCpuArchitecture() },
@@ -1706,7 +1719,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 313 unmodified lines
17061719 const QString HIFI_NO_UPDATER_COMMAND_LINE_KEY = "--no-updater";
17071720 bool noUpdater = arguments().indexOf(HIFI_NO_UPDATER_COMMAND_LINE_KEY) != -1;
17081721 if (!noUpdater) {
1722+ constexpr auto INSTALLER_TYPE_CLIENT_ONLY = "client_only";
1723+
17091724 auto applicationUpdater = DependencyManager::get<AutoUpdater>();
1725+
1726+ AutoUpdater::InstallerType type = installerType == INSTALLER_TYPE_CLIENT_ONLY
1727+ ? AutoUpdater::InstallerType::CLIENT_ONLY : AutoUpdater::InstallerType::FULL;
1728+
1729+ applicationUpdater->setInstallerType(type);
1730+ applicationUpdater->setInstallerCampaign(installerCampaign);
17101731 connect(applicationUpdater.data(), &AutoUpdater::newVersionIsAvailable, dialogsManager.data(), &DialogsManager::showUpdateDialog);
17111732 applicationUpdater->checkForUpdate();
17121733 }
@@ -2170,6 +2191,46 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 457 unmodified lines
21702191 #endif
21712192 }
21722193
2194+void Application::updateVerboseLogging() {
2195+ bool enable = Menu::getInstance()->isOptionChecked(MenuOption::VerboseLogging);
2196+
2197+ const_cast<QLoggingCategory*>(&animation())->setEnabled(QtDebugMsg, enable);
2198+ const_cast<QLoggingCategory*>(&animation())->setEnabled(QtInfoMsg, enable);
2199+
2200+ const_cast<QLoggingCategory*>(&avatars())->setEnabled(QtDebugMsg, enable);
2201+ const_cast<QLoggingCategory*>(&avatars())->setEnabled(QtInfoMsg, enable);
2202+
2203+ const_cast<QLoggingCategory*>(&scriptengine())->setEnabled(QtDebugMsg, enable);
2204+ const_cast<QLoggingCategory*>(&scriptengine())->setEnabled(QtInfoMsg, enable);
2205+
2206+ const_cast<QLoggingCategory*>(&modelformat())->setEnabled(QtDebugMsg, enable);
2207+ const_cast<QLoggingCategory*>(&modelformat())->setEnabled(QtInfoMsg, enable);
2208+
2209+ const_cast<QLoggingCategory*>(&controllers())->setEnabled(QtDebugMsg, enable);
2210+ const_cast<QLoggingCategory*>(&controllers())->setEnabled(QtInfoMsg, enable);
2211+
2212+ const_cast<QLoggingCategory*>(&resourceLog())->setEnabled(QtDebugMsg, enable);
2213+ const_cast<QLoggingCategory*>(&resourceLog())->setEnabled(QtInfoMsg, enable);
2214+
2215+ const_cast<QLoggingCategory*>(&networking())->setEnabled(QtDebugMsg, enable);
2216+ const_cast<QLoggingCategory*>(&networking())->setEnabled(QtInfoMsg, enable);
2217+
2218+ const_cast<QLoggingCategory*>(&asset_client())->setEnabled(QtDebugMsg, enable);
2219+ const_cast<QLoggingCategory*>(&asset_client())->setEnabled(QtInfoMsg, enable);
2220+
2221+ const_cast<QLoggingCategory*>(&messages_client())->setEnabled(QtDebugMsg, enable);
2222+ const_cast<QLoggingCategory*>(&messages_client())->setEnabled(QtInfoMsg, enable);
2223+
2224+ const_cast<QLoggingCategory*>(&storagelogging())->setEnabled(QtDebugMsg, enable);
2225+ const_cast<QLoggingCategory*>(&storagelogging())->setEnabled(QtInfoMsg, enable);
2226+
2227+ const_cast<QLoggingCategory*>(&uiLogging())->setEnabled(QtDebugMsg, enable);
2228+ const_cast<QLoggingCategory*>(&uiLogging())->setEnabled(QtInfoMsg, enable);
2229+
2230+ const_cast<QLoggingCategory*>(&glLogging())->setEnabled(QtDebugMsg, enable);
2231+ const_cast<QLoggingCategory*>(&glLogging())->setEnabled(QtInfoMsg, enable);
2232+}
2233+
21732234 void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) {
21742235 DomainHandler::ConnectionRefusedReason reasonCode = static_cast<DomainHandler::ConnectionRefusedReason>(reasonCodeInt);
21752236
@@ -3041,7 +3102,6 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 865 unmodified lines
30413102 PROFILE_RANGE(render, __FUNCTION__);
30423103
30433104 bool sandboxIsRunning = SandboxUtils::readStatus(reply->readAll());
3044− qDebug() << "HandleSandboxStatus" << sandboxIsRunning;
30453105
30463106 enum HandControllerType {
30473107 Vive,
@@ -4758,7 +4818,7 @@ void Application::updateLOD(float deltaTime) const { · 1710 unmodified lines
47584818 }
47594819 }
47604820
4761−void Application::pushPostUpdateLambda(void* key, std::function<void()> func) {
4821+void Application::pushPostUpdateLambda(void* key, const std::function<void()>& func) {
47624822 std::unique_lock<std::mutex> guard(_postUpdateLambdasLock);
47634823 _postUpdateLambdas[key] = func;
47644824 }
@@ -7368,7 +7428,7 @@ void Application::windowMinimizedChanged(bool minimized) { · 2603 unmodified lines
73687428 }
73697429 }
73707430
7371−void Application::postLambdaEvent(std::function<void()> f) {
7431+void Application::postLambdaEvent(const std::function<void()>& f) {
73727432 if (this->thread() == QThread::currentThread()) {
73737433 f();
73747434 } else {
@@ -7376,6 +7436,15 @@ void Application::postLambdaEvent(std::function<void()> f) { · 1 unmodified line
73767436 }
73777437 }
73787438
7439+void Application::sendLambdaEvent(const std::function<void()>& f) {
7440+ if (this->thread() == QThread::currentThread()) {
7441+ f();
7442+ } else {
7443+ LambdaEvent event(f);
7444+ QCoreApplication::sendEvent(this, &event);
7445+ }
7446+}
7447+
73797448 void Application::initPlugins(const QStringList& arguments) {
73807449 QCommandLineOption display("display", "Preferred displays", "displays");
73817450 QCommandLineOption disableDisplays("disable-displays", "Displays to disable", "displays");