From fbe53ea845a267af639b5f7695ab4e21ef6e7065 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 9 Oct 2024 12:51:38 +0200 Subject: [PATCH] Protect epi/gpi_storeHW/SWVer() by a mutex (guard) --- src/storeINdata.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/storeINdata.cpp b/src/storeINdata.cpp index 50b6094..77c85e7 100755 --- a/src/storeINdata.cpp +++ b/src/storeINdata.cpp @@ -6,6 +6,11 @@ #include "shared_mem_buffer.h" #include "datei.h" +#include +#include + +static QMutex SWHD_mutex; + // gpi: grafical access to PI: access from external devices over device controller FOR GUI // epi: external access from GUI to PI: FOR external devices (DC) @@ -64,6 +69,7 @@ bool indat_isMdbOn() void gpi_storeHWver(QString text) { + QMutexLocker locker(&SWHD_mutex); // change Qstring to array of chars, because shared mem allowes no QString! int nn, LL = text.length(); if (LL >= versionBufferLen) @@ -79,6 +85,7 @@ void gpi_storeHWver(QString text) QString epi_loadHWver(void) { + QMutexLocker locker(&SWHD_mutex); // load array of chars from SM and change to QString int nn, LL = versionBufferLen; char cc; @@ -96,6 +103,7 @@ QString epi_loadHWver(void) void gpi_storeSWver(QString text) { + QMutexLocker locker(&SWHD_mutex); int nn, LL = text.length(); if (LL >= versionBufferLen) LL=versionBufferLen-1; // leave place for termination @@ -111,6 +119,7 @@ void gpi_storeSWver(QString text) QString epi_loadSWver(void) { + QMutexLocker locker(&SWHD_mutex); int nn, LL = versionBufferLen; char cc; QString myStr;