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:
parent
b81779eaf6
commit
9ccb0499a5
@ -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();
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user