Browse Source

Add MUTEX

Haobin Luo 2 years ago
parent
commit
1043471442
2 changed files with 5 additions and 3 deletions
  1. 3 2
      radarsiggen.cpp
  2. 2 1
      radarsiggen.h

+ 3 - 2
radarsiggen.cpp

@@ -2,6 +2,7 @@
 
 RadarSigGen::RadarSigGen(QObject *parent) : QObject(parent)
 {
+    SigMutex = new QMutex();
     sig = new double();
     fs = new double();
     PRF = new double();
@@ -10,7 +11,7 @@ RadarSigGen::RadarSigGen(QObject *parent) : QObject(parent)
 void RadarSigGen::SlotRadarGen(int order)
 {
     qDebug() << QString::fromLocal8Bit("生成信号")<<order;
-
+    SigMutex->lock();
     if (nullptr != sig)
     {
         delete sig;
@@ -31,5 +32,5 @@ void RadarSigGen::SlotRadarGen(int order)
     }
     std::cout << *fs << std::endl;
     std::cout << *PRF << std::endl;
-
+    SigMutex->unlock();
 }

+ 2 - 1
radarsiggen.h

@@ -4,6 +4,7 @@
 #include <QObject>
 #include <iostream>
 #include <QDebug>
+#include <QMutex>
 #include <QString>
 #include "SigGen/Radar001/RadarSignalGenerator.h"
 
@@ -11,7 +12,7 @@ class RadarSigGen : public QObject
 {
     Q_OBJECT
 public:
-
+    QMutex *SigMutex;
     double *fs;
     double *PRF;
     double *sig;