src: crash fixes

* fixed crash when snippet has no code.
* fixed crash when saving a filenode with special characters in its name
* fixed crash when aborting the parsing
This commit is contained in:
malte_langkabel
2016-05-20 13:52:37 +02:00
parent 946be38fa2
commit 4a6f8cf420
4 changed files with 36 additions and 5 deletions
@@ -23,7 +23,7 @@ Task::TaskState TaskGroupParallel::update()
{
for (size_t i = 0; i < m_tasks.size(); i++)
{
std::thread(&TaskGroupParallel::processTask, this, m_tasks[i]).detach();
m_threads.push_back(std::thread(&TaskGroupParallel::processTask, this, m_tasks[i]));
std::lock_guard<std::mutex> lock(m_activeTaskCountMutex);
m_activeTaskCount++;
@@ -47,6 +47,11 @@ Task::TaskState TaskGroupParallel::update()
void TaskGroupParallel::exit()
{
for (size_t i = 0; i < m_threads.size(); i++)
{
m_threads[i].join();
}
m_threads.clear();
}
void TaskGroupParallel::interrupt()
@@ -23,6 +23,9 @@ private:
volatile bool m_interrupt;
bool m_running;
std::vector<std::thread> m_threads;
volatile int m_activeTaskCount;
std::mutex m_activeTaskCountMutex;
};