Showing the changes to interface/src/Application.cpp (1 of 1529 files). Show all
Unified · Split
| @@ -58,6 +58,7 @@ · 57 unmodified lines | ||
| 58 | 58 | |
| 59 | 59 | #include <shared/FileUtils.h> |
| 60 | 60 | #include <shared/QtHelpers.h> |
| 61 | +#include <shared/PlatformHelper.h> | |
| 61 | 62 | #include <shared/GlobalAppProperties.h> |
| 62 | 63 | #include <StatTracker.h> |
| 63 | 64 | #include <Trace.h> |
| @@ -73,6 +74,7 @@ · 9 unmodified lines | ||
| 73 | 74 | #include <Midi.h> |
| 74 | 75 | #include <AudioInjectorManager.h> |
| 75 | 76 | #include <AvatarBookmarks.h> |
| 77 | +#include <CrashHelpers.h> | |
| 76 | 78 | #include <CursorManager.h> |
| 77 | 79 | #include <VirtualPadManager.h> |
| 78 | 80 | #include <DebugDraw.h> |
| @@ -137,6 +139,7 @@ · 58 unmodified lines | ||
| 137 | 139 | #include <SoundCacheScriptingInterface.h> |
| 138 | 140 | #include <ui/TabletScriptingInterface.h> |
| 139 | 141 | #include <ui/ToolbarScriptingInterface.h> |
| 142 | +#include <ui/types/ContextAwareProfile.h> | |
| 140 | 143 | #include <Tooltip.h> |
| 141 | 144 | #include <udt/PacketHeaders.h> |
| 142 | 145 | #include <UserActivityLogger.h> |
| @@ -257,10 +260,6 @@ extern "C" { · 114 unmodified lines | ||
| 257 | 260 | } |
| 258 | 261 | #endif |
| 259 | 262 | |
| 260 | −#ifdef Q_OS_MAC | |
| 261 | −#include "MacHelper.h" | |
| 262 | −#endif | |
| 263 | − | |
| 264 | 263 | #if defined(Q_OS_ANDROID) |
| 265 | 264 | #include <android/log.h> |
| 266 | 265 | #include "AndroidHelper.h" |
| @@ -292,7 +291,7 @@ static const uint32_t MAX_CONCURRENT_RESOURCE_DOWNLOADS = 4; · 25 unmodified lines | ||
| 292 | 291 | // For processing on QThreadPool, we target a number of threads after reserving some |
| 293 | 292 | // based on how many are being consumed by the application and the display plugin. However, |
| 294 | 293 | // we will never drop below the 'min' value |
| 295 | −static const int MIN_PROCESSING_THREAD_POOL_SIZE = 1; | |
| 294 | +static const int MIN_PROCESSING_THREAD_POOL_SIZE = 2; | |
| 296 | 295 | |
| 297 | 296 | static const QString SNAPSHOT_EXTENSION = ".jpg"; |
| 298 | 297 | static const QString JPG_EXTENSION = ".jpg"; |
| @@ -552,13 +551,6 @@ public: · 253 unmodified lines | ||
| 552 | 551 | return true; |
| 553 | 552 | } |
| 554 | 553 | |
| 555 | − if (message->message == WM_POWERBROADCAST) { | |
| 556 | − if (message->wParam == PBT_APMRESUMEAUTOMATIC) { | |
| 557 | − qCInfo(interfaceapp) << "Waking up from sleep or hybernation."; | |
| 558 | − QMetaObject::invokeMethod(DependencyManager::get<NodeList>().data(), "noteAwakening", Qt::QueuedConnection); | |
| 559 | − } | |
| 560 | − } | |
| 561 | − | |
| 562 | 554 | if (message->message == WM_COPYDATA) { |
| 563 | 555 | COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam); |
| 564 | 556 | QUrl url = QUrl((const char*)(pcds->lpData)); |
| @@ -964,9 +956,12 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 399 unmodified lines | ||
| 964 | 956 | DependencyManager::set<KeyboardScriptingInterface>(); |
| 965 | 957 | DependencyManager::set<GrabManager>(); |
| 966 | 958 | DependencyManager::set<AvatarPackager>(); |
| 967 | −#ifdef Q_OS_MAC | |
| 968 | − DependencyManager::set<MacHelper>(); | |
| 969 | −#endif | |
| 959 | + PlatformHelper::setup(); | |
| 960 | + | |
| 961 | + QObject::connect(PlatformHelper::instance(), &PlatformHelper::systemWillWake, [] { | |
| 962 | + QMetaObject::invokeMethod(DependencyManager::get<NodeList>().data(), "noteAwakening", Qt::QueuedConnection); | |
| 963 | + }); | |
| 964 | + | |
| 970 | 965 | |
| 971 | 966 | QString setBookmarkValue = getCmdOption(argc, constArgv, "--setBookmark"); |
| 972 | 967 | if (!setBookmarkValue.isEmpty()) { |
| @@ -1149,7 +1144,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 176 unmodified lines | ||
| 1149 | 1144 | QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Graphik-SemiBold.ttf"); |
| 1150 | 1145 | QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Graphik-Regular.ttf"); |
| 1151 | 1146 | QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Graphik-Medium.ttf"); |
| 1152 | − _window->setWindowTitle("High Fidelity Interface"); | |
| 1147 | + _window->setWindowTitle("High Fidelity"); | |
| 1153 | 1148 | |
| 1154 | 1149 | Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us |
| 1155 | 1150 | |
| @@ -1172,6 +1167,17 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 16 unmodified lines | ||
| 1172 | 1167 | deadlockWatchdogThread->setMainThreadID(QThread::currentThreadId()); |
| 1173 | 1168 | deadlockWatchdogThread->start(); |
| 1174 | 1169 | |
| 1170 | + // Pause the deadlock watchdog when we sleep, or it might | |
| 1171 | + // trigger a false positive when we wake back up | |
| 1172 | + auto platformHelper = PlatformHelper::instance(); | |
| 1173 | + | |
| 1174 | + connect(platformHelper, &PlatformHelper::systemWillSleep, [] { | |
| 1175 | + DeadlockWatchdogThread::pause(); | |
| 1176 | + }); | |
| 1177 | + | |
| 1178 | + connect(platformHelper, &PlatformHelper::systemWillWake, [] { | |
| 1179 | + DeadlockWatchdogThread::resume(); | |
| 1180 | + }); | |
| 1175 | 1181 | |
| 1176 | 1182 | // Main thread timer to keep the watchdog updated |
| 1177 | 1183 | QTimer* watchdogUpdateTimer = new QTimer(this); |
| @@ -1225,8 +1231,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 47 unmodified lines | ||
| 1225 | 1231 | #endif |
| 1226 | 1232 | |
| 1227 | 1233 | bool isStore = property(hifi::properties::OCULUS_STORE).toBool(); |
| 1228 | − | |
| 1229 | − DependencyManager::get<WalletScriptingInterface>()->setLimitedCommerce(isStore); // Or we could make it a separate arg, or if either arg is set, etc. And should this instead by a hifi::properties? | |
| 1234 | + // Or we could make it a separate arg, or if either arg is set, etc. And should this instead by a hifi::properties? | |
| 1235 | + DependencyManager::get<WalletScriptingInterface>()->setLimitedCommerce(isStore || property(hifi::properties::STEAM).toBool()); | |
| 1230 | 1236 | |
| 1231 | 1237 | updateHeartbeat(); |
| 1232 | 1238 | |
| @@ -1659,7 +1665,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 426 unmodified lines | ||
| 1659 | 1665 | // The value will be 0 if the user blew away settings this session, which is both a feature and a bug. |
| 1660 | 1666 | static const QString TESTER = "HIFI_TESTER"; |
| 1661 | 1667 | auto gpuIdent = GPUIdent::getInstance(); |
| 1662 | − auto glContextData = getGLContextData(); | |
| 1668 | + auto glContextData = gl::ContextInfo::get(); | |
| 1663 | 1669 | QJsonObject properties = { |
| 1664 | 1670 | { "version", applicationVersion() }, |
| 1665 | 1671 | { "tester", QProcessEnvironment::systemEnvironment().contains(TESTER) || isTester }, |
| @@ -1676,11 +1682,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 10 unmodified lines | ||
| 1676 | 1682 | { "gpu_name", gpuIdent->getName() }, |
| 1677 | 1683 | { "gpu_driver", gpuIdent->getDriver() }, |
| 1678 | 1684 | { "gpu_memory", static_cast<qint64>(gpuIdent->getMemory()) }, |
| 1679 | − { "gl_version_int", glVersionToInteger(glContextData.value("version").toString()) }, | |
| 1680 | − { "gl_version", glContextData["version"] }, | |
| 1681 | − { "gl_vender", glContextData["vendor"] }, | |
| 1682 | − { "gl_sl_version", glContextData["sl_version"] }, | |
| 1683 | − { "gl_renderer", glContextData["renderer"] }, | |
| 1685 | + { "gl_version_int", glVersionToInteger(glContextData.version.c_str()) }, | |
| 1686 | + { "gl_version", glContextData.version.c_str() }, | |
| 1687 | + { "gl_vender", glContextData.vendor.c_str() }, | |
| 1688 | + { "gl_sl_version", glContextData.shadingLanguageVersion.c_str() }, | |
| 1689 | + { "gl_renderer", glContextData.renderer.c_str() }, | |
| 1684 | 1690 | { "ideal_thread_count", QThread::idealThreadCount() } |
| 1685 | 1691 | }; |
| 1686 | 1692 | auto macVersion = QSysInfo::macVersion(); |
| @@ -2282,8 +2288,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 595 unmodified lines | ||
| 2282 | 2288 | properties["active_display_plugin"] = getActiveDisplayPlugin()->getName(); |
| 2283 | 2289 | properties["using_hmd"] = isHMDMode(); |
| 2284 | 2290 | |
| 2285 | − auto glInfo = getGLContextData(); | |
| 2286 | − properties["gl_info"] = glInfo; | |
| 2291 | + auto contextInfo = gl::ContextInfo::get(); | |
| 2292 | + properties["gl_info"] = QJsonObject{ | |
| 2293 | + { "version", contextInfo.version.c_str() }, | |
| 2294 | + { "sl_version", contextInfo.shadingLanguageVersion.c_str() }, | |
| 2295 | + { "vendor", contextInfo.vendor.c_str() }, | |
| 2296 | + { "renderer", contextInfo.renderer.c_str() }, | |
| 2297 | + }; | |
| 2287 | 2298 | properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemSize()); |
| 2288 | 2299 | properties["gpu_free_memory"] = (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemSize()); |
| 2289 | 2300 | properties["gpu_frame_time"] = (float)(qApp->getGPUContext()->getFrameTimerGPUAverage()); |
| @@ -2670,6 +2681,8 @@ void Application::updateHeartbeat() const { · 380 unmodified lines | ||
| 2670 | 2681 | } |
| 2671 | 2682 | |
| 2672 | 2683 | void Application::onAboutToQuit() { |
| 2684 | + setCrashAnnotation("shutdown", "1"); | |
| 2685 | + | |
| 2673 | 2686 | // quickly save AvatarEntityData before the EntityTree is dismantled |
| 2674 | 2687 | getMyAvatar()->saveAvatarEntityDataToSettings(); |
| 2675 | 2688 | |
| @@ -2708,6 +2721,11 @@ void Application::onAboutToQuit() { · 32 unmodified lines | ||
| 2708 | 2721 | |
| 2709 | 2722 | cleanupBeforeQuit(); |
| 2710 | 2723 | |
| 2724 | + if (_crashOnShutdown) { | |
| 2725 | + // triggered by crash menu | |
| 2726 | + crash::nullDeref(); | |
| 2727 | + } | |
| 2728 | + | |
| 2711 | 2729 | getRefreshRateManager().setRefreshRateRegime(RefreshRateManager::RefreshRateRegime::SHUTDOWN); |
| 2712 | 2730 | } |
| 2713 | 2731 | |
| @@ -2756,7 +2774,6 @@ void Application::cleanupBeforeQuit() { · 42 unmodified lines | ||
| 2756 | 2774 | } |
| 2757 | 2775 | |
| 2758 | 2776 | getEntities()->shutdown(); // tell the entities system we're shutting down, so it will stop running scripts |
| 2759 | − getEntities()->clear(); | |
| 2760 | 2777 | |
| 2761 | 2778 | // Clear any queued processing (I/O, FBX/OBJ/Texture parsing) |
| 2762 | 2779 | QThreadPool::globalInstance()->clear(); |
| @@ -2864,9 +2881,7 @@ Application::~Application() { · 101 unmodified lines | ||
| 2864 | 2881 | _gameWorkload.shutdown(); |
| 2865 | 2882 | |
| 2866 | 2883 | DependencyManager::destroy<Preferences>(); |
| 2867 | −#ifdef Q_OS_MAC | |
| 2868 | − DependencyManager::destroy<MacHelper>(); | |
| 2869 | −#endif | |
| 2884 | + PlatformHelper::shutdown(); | |
| 2870 | 2885 | |
| 2871 | 2886 | _entityClipboard->eraseAllOctreeElements(); |
| 2872 | 2887 | _entityClipboard.reset(); |
| @@ -2996,6 +3011,9 @@ void Application::initializeGL() { · 123 unmodified lines | ||
| 2996 | 3011 | qCWarning(interfaceapp, "Unable to make window context current"); |
| 2997 | 3012 | } |
| 2998 | 3013 | |
| 3014 | + // Populate the global OpenGL context based on the information for the primary window GL context | |
| 3015 | + gl::ContextInfo::get(true); | |
| 3016 | + | |
| 2999 | 3017 | #if !defined(DISABLE_QML) |
| 3000 | 3018 | QStringList chromiumFlags; |
| 3001 | 3019 | // HACK: re-expose mic and camera to prevent crash on domain-change in chromium's media::FakeAudioInputStream::ReadAudioFromSource() |
| @@ -3133,7 +3151,7 @@ void Application::showLoginScreen() { · 131 unmodified lines | ||
| 3133 | 3151 | QJsonObject loginData = {}; |
| 3134 | 3152 | loginData["action"] = "login dialog popped up"; |
| 3135 | 3153 | UserActivityLogger::getInstance().logAction("encourageLoginDialog", loginData); |
| 3136 | − _window->setWindowTitle("High Fidelity Interface"); | |
| 3154 | + _window->setWindowTitle("High Fidelity"); | |
| 3137 | 3155 | } else { |
| 3138 | 3156 | resumeAfterLoginDialogActionTaken(); |
| 3139 | 3157 | } |
| @@ -3268,6 +3286,9 @@ void Application::initializeUi() { · 128 unmodified lines | ||
| 3268 | 3286 | } |
| 3269 | 3287 | return result.toPoint(); |
| 3270 | 3288 | }); |
| 3289 | + | |
| 3290 | + // BUGZ-1365 - the root context should explicitly default to being unable to load local HTML content | |
| 3291 | + ContextAwareProfile::restrictContext(offscreenUi->getSurfaceContext(), true); | |
| 3271 | 3292 | offscreenUi->resume(); |
| 3272 | 3293 | #endif |
| 3273 | 3294 | connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect& r){ |
| @@ -3555,6 +3576,9 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona · 281 unmodified lines | ||
| 3555 | 3576 | surfaceContext->setContextProperty("WalletScriptingInterface", DependencyManager::get<WalletScriptingInterface>().data()); |
| 3556 | 3577 | surfaceContext->setContextProperty("ResourceRequestObserver", DependencyManager::get<ResourceRequestObserver>().data()); |
| 3557 | 3578 | surfaceContext->setContextProperty("PlatformInfo", PlatformInfoScriptingInterface::getInstance()); |
| 3579 | + // This `module` context property is blank for the QML scripting interface so that we don't get log errors when importing | |
| 3580 | + // certain JS files from both scripts (in the JS context) and QML (in the QML context). | |
| 3581 | + surfaceContext->setContextProperty("module", ""); | |
| 3558 | 3582 | } |
| 3559 | 3583 | } |
| 3560 | 3584 | |
| @@ -4228,12 +4252,43 @@ bool Application::event(QEvent* event) { · 667 unmodified lines | ||
| 4228 | 4252 | } |
| 4229 | 4253 | |
| 4230 | 4254 | bool Application::eventFilter(QObject* object, QEvent* event) { |
| 4255 | + auto eventType = event->type(); | |
| 4231 | 4256 | |
| 4232 | − if (_aboutToQuit && event->type() != QEvent::DeferredDelete && event->type() != QEvent::Destroy) { | |
| 4257 | + if (_aboutToQuit && eventType != QEvent::DeferredDelete && eventType != QEvent::Destroy) { | |
| 4233 | 4258 | return true; |
| 4234 | 4259 | } |
| 4235 | 4260 | |
| 4236 | − auto eventType = event->type(); | |
| 4261 | +#if defined(Q_OS_MAC) | |
| 4262 | + // On Mac OS, Cmd+LeftClick is treated as a RightClick (more specifically, it seems to | |
| 4263 | + // be Cmd+RightClick without the modifier being dropped). Starting in Qt 5.12, only | |
| 4264 | + // on Mac, the MouseButtonRelease event for these mouse presses is sent to the top | |
| 4265 | + // level QWidgetWindow, but are not propagated further. This means that the Application | |
| 4266 | + // will see a MouseButtonPress, but no MouseButtonRelease, causing the client to get | |
| 4267 | + // stuck in "mouse-look." The cause of the problem is in the way QWidgetWindow processes | |
| 4268 | + // events where QMouseEvent::button() is not equal to QMouseEvent::buttons(). In this case | |
| 4269 | + // QMouseEvent::button() is Qt::RightButton, while QMouseEvent::buttons() is (correctly?) | |
| 4270 | + // Qt::LeftButton. | |
| 4271 | + // | |
| 4272 | + // The change here gets around this problem by capturing these | |
| 4273 | + // pseudo-RightClicks, and re-emitting them as "pure" RightClicks, where | |
| 4274 | + // QMouseEvent::button() == QMouseEvent::buttons() == Qt::RightButton. | |
| 4275 | + // | |
| 4276 | + if (eventType == QEvent::MouseButtonPress) { | |
| 4277 | + auto mouseEvent = static_cast<QMouseEvent*>(event); | |
| 4278 | + if (mouseEvent->button() == Qt::RightButton | |
| 4279 | + && mouseEvent->buttons() == Qt::LeftButton | |
| 4280 | + && mouseEvent->modifiers() == Qt::MetaModifier) { | |
| 4281 | + | |
| 4282 | + QMouseEvent* newEvent = new QMouseEvent( | |
| 4283 | + QEvent::MouseButtonPress, mouseEvent->localPos(), mouseEvent->windowPos(), | |
| 4284 | + mouseEvent->screenPos(), Qt::RightButton, Qt::MouseButtons(Qt::RightButton), | |
| 4285 | + mouseEvent->modifiers()); | |
| 4286 | + QApplication::postEvent(object, newEvent); | |
| 4287 | + return true; | |
| 4288 | + } | |
| 4289 | + } | |
| 4290 | +#endif | |
| 4291 | + | |
| 4237 | 4292 | if (eventType == QEvent::KeyPress || eventType == QEvent::KeyRelease || eventType == QEvent::MouseMove) { |
| 4238 | 4293 | getRefreshRateManager().resetInactiveTimer(); |
| 4239 | 4294 | } |
| @@ -4410,8 +4465,6 @@ void Application::keyPressEvent(QKeyEvent* event) { · 170 unmodified lines | ||
| 4410 | 4465 | } else if (isMeta) { |
| 4411 | 4466 | auto dialogsManager = DependencyManager::get<DialogsManager>(); |
| 4412 | 4467 | dialogsManager->toggleAddressBar(); |
| 4413 | − } else if (isShifted) { | |
| 4414 | − Menu::getInstance()->triggerOption(MenuOption::LodTools); | |
| 4415 | 4468 | } |
| 4416 | 4469 | break; |
| 4417 | 4470 | |
| @@ -6246,11 +6299,13 @@ void Application::tryToEnablePhysics() { · 1828 unmodified lines | ||
| 6246 | 6299 | // process octree stats packets are sent in between full sends of a scene (this isn't currently true). |
| 6247 | 6300 | // We keep physics disabled until we've received a full scene and everything near the avatar in that |
| 6248 | 6301 | // scene is ready to compute its collision shape. |
| 6249 | − if (getMyAvatar()->isReadyForPhysics()) { | |
| 6302 | + auto myAvatar = getMyAvatar(); | |
| 6303 | + if (myAvatar->isReadyForPhysics()) { | |
| 6304 | + myAvatar->getCharacterController()->setPhysicsEngine(_physicsEngine); | |
| 6250 | 6305 | _octreeProcessor.resetSafeLanding(); |
| 6251 | 6306 | _physicsEnabled = true; |
| 6252 | 6307 | setIsInterstitialMode(false); |
| 6253 | − getMyAvatar()->updateMotionBehaviorFromMenu(); | |
| 6308 | + myAvatar->updateMotionBehaviorFromMenu(); | |
| 6254 | 6309 | } |
| 6255 | 6310 | } |
| 6256 | 6311 | } |
| @@ -6541,7 +6596,7 @@ void Application::update(float deltaTime) { · 284 unmodified lines | ||
| 6541 | 6596 | avatarManager->handleProcessedPhysicsTransaction(transaction); |
| 6542 | 6597 | |
| 6543 | 6598 | myAvatar->prepareForPhysicsSimulation(); |
| 6544 | − _physicsEngine->enableGlobalContactAddedCallback(myAvatar->isFlying()); | |
| 6599 | + myAvatar->getCharacterController()->preSimulation(); | |
| 6545 | 6600 | } |
| 6546 | 6601 | } |
| 6547 | 6602 | |
| @@ -6594,6 +6649,7 @@ void Application::update(float deltaTime) { · 46 unmodified lines | ||
| 6594 | 6649 | |
| 6595 | 6650 | { |
| 6596 | 6651 | PROFILE_RANGE(simulation_physics, "MyAvatar"); |
| 6652 | + myAvatar->getCharacterController()->postSimulation(); | |
| 6597 | 6653 | myAvatar->harvestResultsFromPhysicsSimulation(deltaTime); |
| 6598 | 6654 | } |
| 6599 | 6655 | |
| @@ -6809,8 +6865,8 @@ void Application::updateRenderArgs(float deltaTime) { · 209 unmodified lines | ||
| 6809 | 6865 | _viewFrustum.setProjection(adjustedProjection); |
| 6810 | 6866 | _viewFrustum.calculate(); |
| 6811 | 6867 | } |
| 6812 | − appRenderArgs._renderArgs = RenderArgs(_graphicsEngine.getGPUContext(), lodManager->getOctreeSizeScale(), | |
| 6813 | − lodManager->getBoundaryLevelAdjust(), lodManager->getLODAngleHalfTan(), RenderArgs::DEFAULT_RENDER_MODE, | |
| 6868 | + appRenderArgs._renderArgs = RenderArgs(_graphicsEngine.getGPUContext(), lodManager->getVisibilityDistance(), | |
| 6869 | + lodManager->getBoundaryLevelAdjust(), lodManager->getLODHalfAngleTan(), RenderArgs::DEFAULT_RENDER_MODE, | |
| 6814 | 6870 | RenderArgs::MONO, RenderArgs::DEFERRED, RenderArgs::RENDER_DEBUG_NONE); |
| 6815 | 6871 | appRenderArgs._renderArgs._scene = getMain3DScene(); |
| 6816 | 6872 | |
| @@ -7405,7 +7461,7 @@ void Application::addingEntityWithCertificate(const QString& certificateID, cons · 588 unmodified lines | ||
| 7405 | 7461 | ledger->updateLocation(certificateID, placeName); |
| 7406 | 7462 | } |
| 7407 | 7463 | |
| 7408 | −void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointer scriptEngine) { | |
| 7464 | +void Application::registerScriptEngineWithApplicationServices(const ScriptEnginePointer& scriptEngine) { | |
| 7409 | 7465 | |
| 7410 | 7466 | scriptEngine->setEmitScriptUpdatesFunction([this]() { |
| 7411 | 7467 | SharedNodePointer entityServerNode = DependencyManager::get<NodeList>()->soloNodeOfType(NodeType::EntityServer); |
| @@ -7444,9 +7500,19 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 32 unmodified lines | ||
| 7444 | 7500 | qScriptRegisterMetaType(scriptEngine.data(), RayToOverlayIntersectionResultToScriptValue, |
| 7445 | 7501 | RayToOverlayIntersectionResultFromScriptValue); |
| 7446 | 7502 | |
| 7503 | + bool clientScript = scriptEngine->isClientScript(); | |
| 7504 | + | |
| 7447 | 7505 | #if !defined(DISABLE_QML) |
| 7448 | 7506 | scriptEngine->registerGlobalObject("OffscreenFlags", getOffscreenUI()->getFlags()); |
| 7449 | − scriptEngine->registerGlobalObject("Desktop", DependencyManager::get<DesktopScriptingInterface>().data()); | |
| 7507 | + if (clientScript) { | |
| 7508 | + scriptEngine->registerGlobalObject("Desktop", DependencyManager::get<DesktopScriptingInterface>().data()); | |
| 7509 | + } else { | |
| 7510 | + auto desktopScriptingInterface = new DesktopScriptingInterface(nullptr, true); | |
| 7511 | + scriptEngine->registerGlobalObject("Desktop", desktopScriptingInterface); | |
| 7512 | + if (QThread::currentThread() != thread()) { | |
| 7513 | + desktopScriptingInterface->moveToThread(thread()); | |
| 7514 | + } | |
| 7515 | + } | |
| 7450 | 7516 | #endif |
| 7451 | 7517 | |
| 7452 | 7518 | qScriptRegisterMetaType(scriptEngine.data(), wrapperToScriptValue<ToolbarProxy>, wrapperFromScriptValue<ToolbarProxy>); |
| @@ -7471,7 +7537,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 18 unmodified lines | ||
| 7471 | 7537 | scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter, |
| 7472 | 7538 | LocationScriptingInterface::locationSetter); |
| 7473 | 7539 | |
| 7474 | − bool clientScript = scriptEngine->isClientScript(); | |
| 7475 | 7540 | scriptEngine->registerFunction("OverlayWindow", clientScript ? QmlWindowClass::constructor : QmlWindowClass::restricted_constructor); |
| 7476 | 7541 | #if !defined(Q_OS_ANDROID) && !defined(DISABLE_QML) |
| 7477 | 7542 | scriptEngine->registerFunction("OverlayWebWindow", clientScript ? QmlWebWindowClass::constructor : QmlWebWindowClass::restricted_constructor); |
| @@ -7789,9 +7854,15 @@ bool Application::askToWearAvatarAttachmentUrl(const QString& url) { · 311 unmodified lines | ||
| 7789 | 7854 | return true; |
| 7790 | 7855 | } |
| 7791 | 7856 | |
| 7792 | −void Application::replaceDomainContent(const QString& url) { | |
| 7857 | +static const QString CONTENT_SET_NAME_QUERY_PARAM = "name"; | |
| 7858 | + | |
| 7859 | +void Application::replaceDomainContent(const QString& url, const QString& itemName) { | |
| 7793 | 7860 | qCDebug(interfaceapp) << "Attempting to replace domain content"; |
| 7794 | − QByteArray urlData(url.toUtf8()); | |
| 7861 | + QUrl msgUrl(url); | |
| 7862 | + QUrlQuery urlQuery(msgUrl.query()); | |
| 7863 | + urlQuery.addQueryItem(CONTENT_SET_NAME_QUERY_PARAM, itemName); | |
| 7864 | + msgUrl.setQuery(urlQuery.query(QUrl::QUrl::FullyEncoded)); | |
| 7865 | + QByteArray urlData(msgUrl.toString(QUrl::QUrl::FullyEncoded).toUtf8()); | |
| 7795 | 7866 | auto limitedNodeList = DependencyManager::get<NodeList>(); |
| 7796 | 7867 | const auto& domainHandler = limitedNodeList->getDomainHandler(); |
| 7797 | 7868 | |
| @@ -7825,7 +7896,7 @@ bool Application::askToReplaceDomainContent(const QString& url) { · 27 unmodified lines | ||
| 7825 | 7896 | QString details; |
| 7826 | 7897 | if (static_cast<QMessageBox::StandardButton>(answer.toInt()) == QMessageBox::Yes) { |
| 7827 | 7898 | // Given confirmation, send request to domain server to replace content |
| 7828 | − replaceDomainContent(url); | |
| 7899 | + replaceDomainContent(url, QString()); | |
| 7829 | 7900 | details = "SuccessfulRequestToReplaceContent"; |
| 7830 | 7901 | } else { |
| 7831 | 7902 | details = "UserDeclinedToReplaceContent"; |
| @@ -9477,6 +9548,14 @@ void Application::showUrlHandler(const QUrl& url) { · 1645 unmodified lines | ||
| 9477 | 9548 | } |
| 9478 | 9549 | }); |
| 9479 | 9550 | } |
| 9551 | + | |
| 9552 | +// used to test "shutdown" crash annotation. | |
| 9553 | +void Application::crashOnShutdown() { | |
| 9554 | + qDebug() << "crashOnShutdown(), ON PURPOSE!"; | |
| 9555 | + _crashOnShutdown = true; | |
| 9556 | + quit(); | |
| 9557 | +} | |
| 9558 | + | |
| 9480 | 9559 | void Application::overrideEntry(){ |
| 9481 | 9560 | _overrideEntry = true; |
| 9482 | 9561 | } |