Protect epi/gpi_storeHW/SWVer() by a mutex (guard)

This commit is contained in:
Gerhard Hoffmann 2024-10-09 12:51:38 +02:00
parent bab771cece
commit fbe53ea845

View File

@ -6,6 +6,11 @@
#include "shared_mem_buffer.h"
#include "datei.h"
#include <QMutex>
#include <QMutexLocker>
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;