Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 5 files). Show all
Unified · Split
| @@ -1393,6 +1393,16 @@ void ScriptEngine::forwardHandlerCall(const EntityItemID& entityID, const QStrin · 1392 unmodified lines | |||
| 1393 | } | 1393 | } |
| 1394 | } | 1394 | } |
| 1395 | 1395 | ||
| 1396 | int ScriptEngine::getNumRunningEntityScripts() const { | ||
| 1397 | int sum = 0; | ||
| 1398 | for (auto& st : _entityScripts) { | ||
| 1399 | if (st.status == RUNNING) { | ||
| 1400 | ++sum; | ||
| 1401 | } | ||
| 1402 | } | ||
| 1403 | return sum; | ||
| 1404 | } | ||
| 1405 | |||
| 1396 | bool ScriptEngine::getEntityScriptDetails(const EntityItemID& entityID, EntityScriptDetails &details) const { | 1406 | bool ScriptEngine::getEntityScriptDetails(const EntityItemID& entityID, EntityScriptDetails &details) const { |
| 1397 | auto it = _entityScripts.constFind(entityID); | 1407 | auto it = _entityScripts.constFind(entityID); |
| 1398 | if (it == _entityScripts.constEnd()) { | 1408 | if (it == _entityScripts.constEnd()) { |
| @@ -1456,6 +1466,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 57 unmodified lines | |||
| 1456 | newDetails.status = ERROR_LOADING_SCRIPT; | 1466 | newDetails.status = ERROR_LOADING_SCRIPT; |
| 1457 | newDetails.errorInfo = "Failed to load script"; | 1467 | newDetails.errorInfo = "Failed to load script"; |
| 1458 | _entityScripts[entityID] = newDetails; | 1468 | _entityScripts[entityID] = newDetails; |
| 1469 | emit entityScriptDetailsUpdated(); | ||
| 1459 | return; | 1470 | return; |
| 1460 | } | 1471 | } |
| 1461 | 1472 | ||
| @@ -1467,6 +1478,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 5 unmodified lines | |||
| 1467 | newDetails.status = ERROR_RUNNING_SCRIPT; | 1478 | newDetails.status = ERROR_RUNNING_SCRIPT; |
| 1468 | newDetails.errorInfo = "Bad syntax"; | 1479 | newDetails.errorInfo = "Bad syntax"; |
| 1469 | _entityScripts[entityID] = newDetails; | 1480 | _entityScripts[entityID] = newDetails; |
| 1481 | emit entityScriptDetailsUpdated(); | ||
| 1470 | return; // done processing script | 1482 | return; // done processing script |
| 1471 | } | 1483 | } |
| 1472 | 1484 | ||
| @@ -1497,6 +1509,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 24 unmodified lines | |||
| 1497 | newDetails.status = ERROR_RUNNING_SCRIPT; | 1509 | newDetails.status = ERROR_RUNNING_SCRIPT; |
| 1498 | newDetails.errorInfo = exceptionMessage; | 1510 | newDetails.errorInfo = exceptionMessage; |
| 1499 | _entityScripts[entityID] = newDetails; | 1511 | _entityScripts[entityID] = newDetails; |
| 1512 | emit entityScriptDetailsUpdated(); | ||
| 1500 | 1513 | ||
| 1501 | return; | 1514 | return; |
| 1502 | } | 1515 | } |
| @@ -1523,6 +1536,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 20 unmodified lines | |||
| 1523 | newDetails.status = ERROR_RUNNING_SCRIPT; | 1536 | newDetails.status = ERROR_RUNNING_SCRIPT; |
| 1524 | newDetails.errorInfo = "Could not find constructor"; | 1537 | newDetails.errorInfo = "Could not find constructor"; |
| 1525 | _entityScripts[entityID] = newDetails; | 1538 | _entityScripts[entityID] = newDetails; |
| 1539 | emit entityScriptDetailsUpdated(); | ||
| 1526 | 1540 | ||
| 1527 | return; // done processing script | 1541 | return; // done processing script |
| 1528 | } | 1542 | } |
| @@ -1544,6 +1558,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 15 unmodified lines | |||
| 1544 | newDetails.lastModified = lastModified; | 1558 | newDetails.lastModified = lastModified; |
| 1545 | newDetails.definingSandboxURL = sandboxURL; | 1559 | newDetails.definingSandboxURL = sandboxURL; |
| 1546 | _entityScripts[entityID] = newDetails; | 1560 | _entityScripts[entityID] = newDetails; |
| 1561 | emit entityScriptDetailsUpdated(); | ||
| 1547 | 1562 | ||
| 1548 | if (isURL) { | 1563 | if (isURL) { |
| 1549 | setParentURL(""); | 1564 | setParentURL(""); |
| @@ -1575,6 +1590,7 @@ void ScriptEngine::unloadEntityScript(const EntityItemID& entityID) { · 25 unmodified lines | |||
| 1575 | } | 1590 | } |
| 1576 | _entityScripts.remove(entityID); | 1591 | _entityScripts.remove(entityID); |
| 1577 | stopAllTimersForEntityScript(entityID); | 1592 | stopAllTimersForEntityScript(entityID); |
| 1593 | emit entityScriptDetailsUpdated(); | ||
| 1578 | } | 1594 | } |
| 1579 | } | 1595 | } |
| 1580 | 1596 | ||
| @@ -1596,6 +1612,7 @@ void ScriptEngine::unloadAllEntityScripts() { · 15 unmodified lines | |||
| 1596 | } | 1612 | } |
| 1597 | } | 1613 | } |
| 1598 | _entityScripts.clear(); | 1614 | _entityScripts.clear(); |
| 1615 | emit entityScriptDetailsUpdated(); | ||
| 1599 | 1616 | ||
| 1600 | #ifdef DEBUG_ENGINE_STATE | 1617 | #ifdef DEBUG_ENGINE_STATE |
| 1601 | qCDebug(scriptengine) << "---- CURRENT STATE OF ENGINE: --------------------------"; | 1618 | qCDebug(scriptengine) << "---- CURRENT STATE OF ENGINE: --------------------------"; |