0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-28 01:04:41 +08:00

(EasyTreeWidgetLoader) Destructor will delete items in the same thread

This commit is contained in:
Victor Zarubkin 2016-09-17 15:38:41 +03:00
parent b81779eaf6
commit 9ccb0499a5
2 changed files with 17 additions and 9 deletions

View File

@ -54,7 +54,7 @@ EasyTreeWidgetLoader::EasyTreeWidgetLoader() : m_bDone(ATOMIC_VAR_INIT(false)),
EasyTreeWidgetLoader::~EasyTreeWidgetLoader()
{
interrupt();
interrupt(true);
}
bool EasyTreeWidgetLoader::done() const
@ -101,7 +101,7 @@ void EasyTreeWidgetLoader::takeItems(Items& _output)
}
}
void EasyTreeWidgetLoader::interrupt()
void EasyTreeWidgetLoader::interrupt(bool _wait)
{
m_bInterrupt.store(true);
if (m_thread.joinable())
@ -111,6 +111,8 @@ void EasyTreeWidgetLoader::interrupt()
m_bDone.store(false);
m_progress.store(0);
if (!_wait)
{
auto deleter_thread = ::std::thread([](decltype(m_topLevelItems) _items) {
for (auto item : _items)
delete item.second;
@ -121,6 +123,12 @@ void EasyTreeWidgetLoader::interrupt()
#endif
deleter_thread.detach();
}
else
{
for (auto item : m_topLevelItems)
delete item.second;
}
m_items.clear();
m_topLevelItems.clear();

View File

@ -70,7 +70,7 @@ public:
void takeTopLevelItems(ThreadedItems& _output);
void takeItems(Items& _output);
void interrupt();
void interrupt(bool _wait = false);
void fillTree(::profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, bool _colorizeRows);
void fillTreeBlocks(const::profiler_gui::TreeBlocks& _blocks, ::profiler::timestamp_t _beginTime, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, bool _colorizeRows);