Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -683,54 +683,6 @@ bool EntityScriptingInterface::reloadServerScripts(QUuid entityID) { · 682 unmodified lines | ||
| 683 | 683 | return client->reloadServerScript(entityID); |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | −#ifdef DEBUG_ENTITY_METADATA | |
| 687 | −// baseline example -- return parsed userData as a standard CPS callback | |
| 688 | −bool EntityPropertyMetadataRequest::_userData(EntityItemID entityID, QScriptValue handler) { | |
| 689 | − QScriptValue err, result; | |
| 690 | − auto engine = _engine; | |
| 691 | − if (!engine) { | |
| 692 | − qCDebug(entities) << __FUNCTION__ << " -- engine destroyed while inflight" << entityID; | |
| 693 | − return false; | |
| 694 | − } | |
| 695 | − auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | |
| 696 | − auto entityTree = entityScriptingInterface ? entityScriptingInterface->getEntityTree() : nullptr; | |
| 697 | − if (!entityTree) { | |
| 698 | − err = engine->makeError("Entities Tree unavailable", "InternalError"); | |
| 699 | − } else { | |
| 700 | − EntityItemPointer entity = entityTree->findEntityByID(entityID); | |
| 701 | − if (!entity) { | |
| 702 | − err = engine->makeError("entity not found"); | |
| 703 | − } else { | |
| 704 | − auto JSON = engine->globalObject().property("JSON"); | |
| 705 | − auto parsed = JSON.property("parse").call(JSON, QScriptValueList({ entity->getUserData() })); | |
| 706 | − if (engine->hasUncaughtException()) { | |
| 707 | − err = engine->cloneUncaughtException(__FUNCTION__); | |
| 708 | − engine->clearExceptions(); | |
| 709 | − } else { | |
| 710 | − result = parsed; | |
| 711 | − } | |
| 712 | − } | |
| 713 | − } | |
| 714 | − // this one second delay can be used with a Client script to query metadata and immediately Script.stop() | |
| 715 | − // (testing that the signal handler never gets called once the engine is destroyed) | |
| 716 | − // note: we still might want to check engine->isStopping() as an optimization in some places | |
| 717 | − QFutureWatcher<QVariant> *request = new QFutureWatcher<QVariant>; | |
| 718 | − QObject::connect(request, &QFutureWatcher<QVariant>::finished, engine, [=]() mutable { | |
| 719 | − if (!engine) { | |
| 720 | − qCDebug(entities) << "queryPropertyMetadata -- engine destroyed while inflight" << entityID; | |
| 721 | − return; | |
| 722 | − } | |
| 723 | − callScopedHandlerObject(handler, err, result); | |
| 724 | − request->deleteLater(); | |
| 725 | − }); | |
| 726 | − request->setFuture(QtConcurrent::run([]() -> QVariant { | |
| 727 | − QThread::sleep(1); | |
| 728 | − return QVariant(); | |
| 729 | − })); | |
| 730 | − return true; | |
| 731 | −} | |
| 732 | −#endif | |
| 733 | − | |
| 734 | 686 | bool EntityPropertyMetadataRequest::script(EntityItemID entityID, QScriptValue handler) { |
| 735 | 687 | using LocalScriptStatusRequest = QFutureWatcher<QVariant>; |
| 736 | 688 | |
| @@ -842,10 +794,6 @@ bool EntityScriptingInterface::queryPropertyMetadata(QUuid entityID, QScriptValu · 105 unmodified lines | ||
| 842 | 794 | return request.script(entityID, handler); |
| 843 | 795 | } else if (name == "serverScripts") { |
| 844 | 796 | return request.serverScripts(entityID, handler); |
| 845 | −#ifdef DEBUG_ENTITY_METADATA | |
| 846 | − } else if (name == "userData") { | |
| 847 | − return request.userData(entityID, handler); | |
| 848 | −#endif | |
| 849 | 797 | } else { |
| 850 | 798 | engine->raiseException(engine->makeError("metadata for property " + name + " is not yet queryable")); |
| 851 | 799 | engine->maybeEmitUncaughtException(__FUNCTION__); |