From 3288bff963b2bdb12da93717504c3b3cd0fc1718 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 13 Apr 2016 09:47:07 -0700 Subject: [PATCH] don't flood log with messages about expired actions. also, try to remove such actions --- interface/src/InterfaceActionFactory.cpp | 3 +++ libraries/entities/src/EntityItem.cpp | 24 +++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/interface/src/InterfaceActionFactory.cpp b/interface/src/InterfaceActionFactory.cpp index 8ace11c0a0..1869980270 100644 --- a/interface/src/InterfaceActionFactory.cpp +++ b/interface/src/InterfaceActionFactory.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include "InterfaceActionFactory.h" @@ -66,6 +67,8 @@ EntityActionPointer InterfaceActionFactory::factoryBA(EntityItemPointer ownerEnt if (action) { action->deserialize(data); if (action->lifetimeIsOver()) { + static QString repeatedMessage = + LogHandler::getInstance().addRepeatedMessageRegex(".*factoryBA lifetimeIsOver during action creation.*"); qDebug() << "InterfaceActionFactory::factoryBA lifetimeIsOver during action creation --" << action->getExpires() << "<" << usecTimestampNow(); return nullptr; diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 6731bcc9fb..1f5db65089 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -24,6 +24,7 @@ #include #include // usecTimestampNow() #include +#include #include "EntityScriptingInterface.h" #include "EntitiesLogging.h" @@ -516,8 +517,8 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef EntityTreePointer tree = getTree(); if (tree && tree->isDeletedEntity(_id)) { #ifdef WANT_DEBUG - qDebug() << "Received packet for previously deleted entity [" << _id << "] ignoring. " - "(inside " << __FUNCTION__ << ")"; + qCDebug(entities) << "Received packet for previously deleted entity [" << _id << "] ignoring. " + "(inside " << __FUNCTION__ << ")"; #endif ignoreServerPacket = true; } @@ -1685,7 +1686,7 @@ bool EntityItem::addActionInternal(EntitySimulation* simulation, EntityActionPoi _allActionsDataCache = newDataCache; _dirtyFlags |= Simulation::DIRTY_PHYSICS_ACTIVATION; } else { - qDebug() << "EntityItem::addActionInternal -- serializeActions failed"; + qCDebug(entities) << "EntityItem::addActionInternal -- serializeActions failed"; } return success; } @@ -1706,7 +1707,7 @@ bool EntityItem::updateAction(EntitySimulation* simulation, const QUuid& actionI serializeActions(success, _allActionsDataCache); _dirtyFlags |= Simulation::DIRTY_PHYSICS_ACTIVATION; } else { - qDebug() << "EntityItem::updateAction failed"; + qCDebug(entities) << "EntityItem::updateAction failed"; } }); return success; @@ -1777,7 +1778,7 @@ void EntityItem::deserializeActionsInternal() { quint64 now = usecTimestampNow(); if (!_element) { - qDebug() << "EntityItem::deserializeActionsInternal -- no _element"; + qCDebug(entities) << "EntityItem::deserializeActionsInternal -- no _element"; return; } @@ -1805,14 +1806,13 @@ void EntityItem::deserializeActionsInternal() { continue; } - updated << actionID; - if (_objectActions.contains(actionID)) { EntityActionPointer action = _objectActions[actionID]; // TODO: make sure types match? there isn't currently a way to // change the type of an existing action. action->deserialize(serializedAction); action->locallyAddedButNotYetReceived = false; + updated << actionID; } else { auto actionFactory = DependencyManager::get(); EntityItemPointer entity = getThisPointer(); @@ -1820,8 +1820,13 @@ void EntityItem::deserializeActionsInternal() { if (action) { entity->addActionInternal(simulation, action); action->locallyAddedButNotYetReceived = false; + updated << actionID; } else { - qDebug() << "EntityItem::deserializeActionsInternal -- action creation failed"; + static QString repeatedMessage = + LogHandler::getInstance().addRepeatedMessageRegex(".*action creation failed for.*"); + qCDebug(entities) << "EntityItem::deserializeActionsInternal -- action creation failed for" + << getID() << getName(); + removeActionInternal(actionID, nullptr); } } } @@ -1897,7 +1902,8 @@ void EntityItem::serializeActions(bool& success, QByteArray& result) const { serializedActionsStream << serializedActions; if (result.size() >= _maxActionsDataSize) { - qDebug() << "EntityItem::serializeActions size is too large -- " << result.size() << ">=" << _maxActionsDataSize; + qCDebug(entities) << "EntityItem::serializeActions size is too large -- " + << result.size() << ">=" << _maxActionsDataSize; success = false; return; }