summaryrefslogtreecommitdiff
path: root/src/actions
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
parentf2849928b3eca83581ba77be8bf3b002085fdc9a (diff)
downloadplus-76fd633b0042f2ab3a161460ee03c1978e7c0db9.tar.gz
plus-76fd633b0042f2ab3a161460ee03c1978e7c0db9.tar.bz2
plus-76fd633b0042f2ab3a161460ee03c1978e7c0db9.tar.xz
plus-76fd633b0042f2ab3a161460ee03c1978e7c0db9.zip
Move chat command /dump into actions.
Diffstat (limited to 'src/actions')
-rw-r--r--src/actions/actions.cpp83
-rw-r--r--src/actions/actions.h1
2 files changed, 84 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
diff --git a/src/actions/actions.h b/src/actions/actions.h
index 9258a289b..5a60e83f9 100644
--- a/src/actions/actions.h
+++ b/src/actions/actions.h
@@ -68,6 +68,7 @@ namespace Actions
decHandler(undress);
decHandler(dirs);
decHandler(uptime);
+ decHandler(dump);
} // namespace Actions
#undef decHandler