logic: Fixed crashes in CxxSpecifierNameResolver and LogController

This commit is contained in:
Eberhard Graether
2016-11-29 12:46:22 +01:00
parent 46078097d7
commit e1968eaaac
3 changed files with 21 additions and 7 deletions
@@ -31,6 +31,7 @@ LogView* LogController::getView() const
void LogController::clear()
{
std::lock_guard<std::mutex> lock(m_logsMutex);
m_logs.clear();
getView()->clear();
}
@@ -87,7 +88,7 @@ void LogController::handleMessage(MessageClearLogView* message)
void LogController::addLog(Logger::LogLevel type, const LogMessage& message)
{
std::lock_guard<std::mutex> lock(m_logsMutex);
m_logs.push_back(
Log(
type,
@@ -101,7 +102,7 @@ void LogController::addLog(Logger::LogLevel type, const LogMessage& message)
m_waiting = true;
std::thread([&]()
{
std::this_thread::sleep_for( std::chrono::seconds(1) );
std::this_thread::sleep_for(std::chrono::milliseconds(200));
syncLogs();
m_waiting = false;
}
@@ -111,13 +112,16 @@ void LogController::addLog(Logger::LogLevel type, const LogMessage& message)
void LogController::syncLogs()
{
std::lock_guard<std::mutex> lock(m_logsMutex);
int logCount = m_logs.size();
if (logCount > getView()->LogLimit)
{
m_logs.erase(m_logs.begin(),m_logs.begin() + logCount - LogView::LogLimit);
m_logs.erase(m_logs.begin(), m_logs.begin() + logCount - LogView::LogLimit);
}
std::vector<Log> logs;
for( Log log : m_logs )
for (Log log : m_logs)
{
if (log.type & m_logLevel)
{
+7 -2
View File
@@ -1,6 +1,8 @@
#ifndef LOG_CONTROLLER_H
#define LOG_CONTROLLER_H
#include <mutex>
#include "component/controller/Controller.h"
#include "component/view/LogView.h"
@@ -38,12 +40,15 @@ private:
virtual void handleMessage(MessageClearLogView* message);
virtual void handleMessage(MessageLogFilterChanged* message);
std::vector<Log> m_logs;
void addLog(Logger::LogLevel type, const LogMessage& message);
void syncLogs();
bool m_waiting;
std::vector<Log> m_logs;
Logger::LogLevelMask m_logLevel;
std::mutex m_logsMutex;
bool m_waiting;
};
#endif // LOG_CONTROLLER_H
@@ -23,8 +23,13 @@ CxxSpecifierNameResolver::~CxxSpecifierNameResolver()
std::shared_ptr<CxxName> CxxSpecifierNameResolver::getName(const clang::NestedNameSpecifier* nestedNameSpecifier)
{
clang::NestedNameSpecifier::SpecifierKind nnsKind = nestedNameSpecifier->getKind();
std::shared_ptr<CxxName> name;
if (!nestedNameSpecifier)
{
return name;
}
clang::NestedNameSpecifier::SpecifierKind nnsKind = nestedNameSpecifier->getKind();
switch (nnsKind)
{
case clang::NestedNameSpecifier::Identifier: