summaryrefslogtreecommitdiff
path: root/src/actions/actions.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-08-26 22:34:19 +0300
committerAndrei Karas <akaras@inbox.ru>2014-08-26 22:34:19 +0300
commit76fd633b0042f2ab3a161460ee03c1978e7c0db9 (patch)
tree49ac22bd396af6329bfdffe69a775de7dedaa553 /src/actions/actions.cpp
parentf2849928b3eca83581ba77be8bf3b002085fdc9a (diff)
downloadmv-76fd633b0042f2ab3a161460ee03c1978e7c0db9.tar.gz
mv-76fd633b0042f2ab3a161460ee03c1978e7c0db9.tar.bz2
mv-76fd633b0042f2ab3a161460ee03c1978e7c0db9.tar.xz
mv-76fd633b0042f2ab3a161460ee03c1978e7c0db9.zip
Move chat command /dump into actions.
Diffstat (limited to 'src/actions/actions.cpp')
-rw-r--r--src/actions/actions.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index fd71b5bf5..3111c551f 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -789,4 +789,87 @@ impHandler0(uptime)
return true;
}
+#ifdef DEBUG_DUMP_LEAKS1
+static void showRes(std::string str, ResourceManager::Resources *res)
+{
+ if (!res)
+ return;
+
+ str.append(toString(res->size()));
+ if (debugChatTab)
+ debugChatTab->chatLog(str);
+ logger->log(str);
+ ResourceManager::ResourceIterator iter = res->begin();
+ const ResourceManager::ResourceIterator iter_end = res->end();
+ while (iter != iter_end)
+ {
+ if (iter->second && iter->second->getRefCount())
+ {
+ char type = ' ';
+ char isNew = 'N';
+ if (iter->second->getDumped())
+ isNew = 'O';
+ else
+ iter->second->setDumped(true);
+
+ SubImage *const subImage = dynamic_cast<SubImage *const>(
+ iter->second);
+ Image *const image = dynamic_cast<Image *const>(iter->second);
+ int id = 0;
+ if (subImage)
+ type = 'S';
+ else if (image)
+ type = 'I';
+ if (image)
+ id = image->getGLImage();
+ logger->log("Resource %c%c: %s (%d) id=%d", type,
+ isNew, iter->second->getIdPath().c_str(),
+ iter->second->getRefCount(), id);
+ }
+ ++ iter;
+ }
+}
+
+impHandler(dump)
+{
+ if (!debugChatTab)
+ return false;
+
+ ResourceManager *const resman = ResourceManager::getInstance();
+
+ if (!event.args.empty())
+ {
+ ResourceManager::Resources *res = resman->getResources();
+ // TRANSLATORS: dump command
+ showRes(_("Resource images:"), res);
+ res = resman->getOrphanedResources();
+ // TRANSLATORS: dump command
+ showRes(_("Resource orphaned images:"), res);
+ }
+ else
+ {
+ ResourceManager::Resources *res = resman->getResources();
+ // TRANSLATORS: dump command
+ debugChatTab->chatLog(_("Resource images:") + toString(res->size()));
+ res = resman->getOrphanedResources();
+ // TRANSLATORS: dump command
+ debugChatTab->chatLog(_("Resource orphaned images:")
+ + toString(res->size()));
+ }
+ return true;
+}
+
+#elif defined ENABLE_MEM_DEBUG
+impHandler0(dump)
+{
+ check_leaks();
+ return true;
+}
+#else
+impHandler0(dump)
+{
+ return true;
+}
+#endif
+
} // namespace Actions