kopia lustrzana https://gitlab.com/Teuniz/DSRemote
Replace QMutex with POSIX threads.
rodzic
33888cfc49
commit
8603a339e7
6
global.h
6
global.h
|
@ -29,13 +29,13 @@
|
||||||
#ifndef DSR_GLOBAL_H
|
#ifndef DSR_GLOBAL_H
|
||||||
#define DSR_GLOBAL_H
|
#define DSR_GLOBAL_H
|
||||||
|
|
||||||
#include <QMutex>
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "third_party/kiss_fft/kiss_fftr.h"
|
#include "third_party/kiss_fft/kiss_fftr.h"
|
||||||
|
|
||||||
|
|
||||||
#define PROGRAM_NAME "DSRemote"
|
#define PROGRAM_NAME "DSRemote"
|
||||||
#define PROGRAM_VERSION "0.35_1707091423"
|
#define PROGRAM_VERSION "0.35_1707091429"
|
||||||
|
|
||||||
#define MAX_PATHLEN 4096
|
#define MAX_PATHLEN 4096
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ struct device_settings
|
||||||
|
|
||||||
int screenupdates_on;
|
int screenupdates_on;
|
||||||
|
|
||||||
QMutex *mutexx;
|
pthread_mutex_t mutexx;
|
||||||
|
|
||||||
int thread_error_stat;
|
int thread_error_stat;
|
||||||
int thread_error_line;
|
int thread_error_line;
|
||||||
|
|
|
@ -461,7 +461,8 @@ void UI_Mainwindow::close_connection()
|
||||||
|
|
||||||
scrn_thread->wait(5000);
|
scrn_thread->wait(5000);
|
||||||
|
|
||||||
devparms.mutexx->unlock();
|
pthread_mutex_trylock(&devparms.mutexx);
|
||||||
|
pthread_mutex_unlock(&devparms.mutexx);
|
||||||
|
|
||||||
scrn_thread->h_busy = 0;
|
scrn_thread->h_busy = 0;
|
||||||
}
|
}
|
||||||
|
@ -2714,21 +2715,21 @@ void UI_Mainwindow::screenUpdate()
|
||||||
|
|
||||||
if(device == NULL)
|
if(device == NULL)
|
||||||
{
|
{
|
||||||
devparms.mutexx->unlock();
|
pthread_mutex_unlock(&devparms.mutexx);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!devparms.connected)
|
if(!devparms.connected)
|
||||||
{
|
{
|
||||||
devparms.mutexx->unlock();
|
pthread_mutex_unlock(&devparms.mutexx);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!devparms.screenupdates_on)
|
if(!devparms.screenupdates_on)
|
||||||
{
|
{
|
||||||
devparms.mutexx->unlock();
|
pthread_mutex_unlock(&devparms.mutexx);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2747,7 +2748,7 @@ void UI_Mainwindow::screenUpdate()
|
||||||
msgBox.setText(str);
|
msgBox.setText(str);
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
|
|
||||||
devparms.mutexx->unlock();
|
pthread_mutex_unlock(&devparms.mutexx);
|
||||||
|
|
||||||
close_connection();
|
close_connection();
|
||||||
|
|
||||||
|
@ -2756,7 +2757,7 @@ void UI_Mainwindow::screenUpdate()
|
||||||
|
|
||||||
if(devparms.thread_result == TMC_THRD_RESULT_NONE)
|
if(devparms.thread_result == TMC_THRD_RESULT_NONE)
|
||||||
{
|
{
|
||||||
devparms.mutexx->unlock();
|
pthread_mutex_unlock(&devparms.mutexx);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2770,14 +2771,14 @@ void UI_Mainwindow::screenUpdate()
|
||||||
// waveForm->setTrigLineVisible();
|
// waveForm->setTrigLineVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
devparms.mutexx->unlock();
|
pthread_mutex_unlock(&devparms.mutexx);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(scrn_timer->isActive() == false)
|
if(scrn_timer->isActive() == false)
|
||||||
{
|
{
|
||||||
devparms.mutexx->unlock();
|
pthread_mutex_unlock(&devparms.mutexx);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2828,7 +2829,7 @@ void UI_Mainwindow::screenUpdate()
|
||||||
|
|
||||||
if(waveForm->hasMoveEvent() == true)
|
if(waveForm->hasMoveEvent() == true)
|
||||||
{
|
{
|
||||||
devparms.mutexx->unlock();
|
pthread_mutex_unlock(&devparms.mutexx);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2847,7 +2848,7 @@ void UI_Mainwindow::screenUpdate()
|
||||||
{
|
{
|
||||||
waveForm->clear();
|
waveForm->clear();
|
||||||
|
|
||||||
devparms.mutexx->unlock();
|
pthread_mutex_unlock(&devparms.mutexx);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2867,7 +2868,7 @@ void UI_Mainwindow::screenUpdate()
|
||||||
waveForm->update();
|
waveForm->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
devparms.mutexx->unlock();
|
pthread_mutex_unlock(&devparms.mutexx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "about_dialog.h"
|
#include "about_dialog.h"
|
||||||
|
|
|
@ -158,7 +158,7 @@ UI_Mainwindow::UI_Mainwindow()
|
||||||
|
|
||||||
strcpy(devparms.modelname, "-----");
|
strcpy(devparms.modelname, "-----");
|
||||||
|
|
||||||
devparms.mutexx = new QMutex();
|
pthread_mutex_init(&devparms.mutexx, NULL);
|
||||||
|
|
||||||
scrn_thread = new screen_thread;
|
scrn_thread = new screen_thread;
|
||||||
scrn_thread->set_device(NULL);
|
scrn_thread->set_device(NULL);
|
||||||
|
@ -632,7 +632,7 @@ UI_Mainwindow::~UI_Mainwindow()
|
||||||
delete scrn_thread;
|
delete scrn_thread;
|
||||||
delete appfont;
|
delete appfont;
|
||||||
delete monofont;
|
delete monofont;
|
||||||
delete devparms.mutexx;
|
pthread_mutex_destroy(&devparms.mutexx);
|
||||||
|
|
||||||
free(devparms.screenshot_buf);
|
free(devparms.screenshot_buf);
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ void UI_Mainwindow::adjdial_timer_handler()
|
||||||
|
|
||||||
void UI_Mainwindow::scrn_timer_handler()
|
void UI_Mainwindow::scrn_timer_handler()
|
||||||
{
|
{
|
||||||
if(devparms.mutexx->tryLock() == false)
|
if(pthread_mutex_trylock(&devparms.mutexx))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue