Otherwise, we crash when two threads try to add entries to the log
at the same time.
+using std::lock_guard;
+
namespace pv {
Logging logging;
namespace pv {
Logging logging;
void Logging::log(const QString &text, int source)
{
void Logging::log(const QString &text, int source)
{
+ lock_guard<mutex> log_lock(log_mutex_);
+
if (buffer_.size() >= buffer_size_)
buffer_.removeFirst();
if (buffer_.size() >= buffer_size_)
buffer_.removeFirst();
#include "globalsettings.hpp"
#include "globalsettings.hpp"
#include <QtGlobal>
#include <QObject>
#include <QString>
#include <QStringList>
#include <QtGlobal>
#include <QObject>
#include <QString>
#include <QStringList>
namespace pv {
class Logging : public QObject, public GlobalSettingsInterface
namespace pv {
class Logging : public QObject, public GlobalSettingsInterface
private:
int buffer_size_;
QStringList buffer_;
private:
int buffer_size_;
QStringList buffer_;
+ mutable mutex log_mutex_;
};
extern Logging logging;
};
extern Logging logging;