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