gui crash qtimer (#551)

* locks when qtimer runs out same time as acquisitionfinished

* fix for newer gcc
This commit is contained in:
Dhanya Thattil 2022-09-16 17:02:03 +02:00 committed by GitHub
parent 1df4aba8ec
commit e385618d09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 2 deletions

View File

@ -4,6 +4,8 @@
#include "sls/Detector.h"
#include "ui_form_tab_measurement.h"
#include <mutex>
class QStandardItemModel;
namespace sls {
@ -100,6 +102,8 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
bool isAcquisitionStopped{false};
int numMeasurements{1};
int currentMeasurement{0};
mutable std::mutex mProgress;
};
} // namespace sls

View File

@ -5,6 +5,7 @@
#include "SlsQt1DZoomer.h"
#include "sls/ansi.h"
#include <array>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_marker.h>

View File

@ -3,6 +3,7 @@
#pragma once
#include "SlsQt2DHist.h"
#include "SlsQt2DZoomer.h"
#include <array>
#include <qlist.h>
#include <qwt_plot.h>
#include <qwt_plot_shapeitem.h>

View File

@ -254,13 +254,17 @@ void qDrawPlot::resizeEvent(QResizeEvent *event) {
bool qDrawPlot::GetIsRunning() { return isRunning; }
void qDrawPlot::SetRunning(bool enable) { isRunning = enable; }
void qDrawPlot::SetRunning(bool enable) {
std::lock_guard<std::mutex> lock(mPlots);
isRunning = enable;
}
double qDrawPlot::GetProgress() { return progress; }
int64_t qDrawPlot::GetCurrentFrameIndex() { return currentFrame; }
void qDrawPlot::Select1dPlot(bool enable) {
std::lock_guard<std::mutex> lock(mPlots);
if (enable) {
is1d = true;
// DetachHists(); it clears the last measurement
@ -487,6 +491,7 @@ void qDrawPlot::EnableGainPlot(bool enable) {
}
void qDrawPlot::SetSaveFileName(QString val) {
std::lock_guard<std::mutex> lock(mPlots);
LOG(logDEBUG) << "Setting Clone/Save File Name to "
<< val.toAscii().constData();
fileSaveName = val;
@ -592,6 +597,7 @@ void qDrawPlot::ClonePlot() {
}
void qDrawPlot::SavePlot() {
std::lock_guard<std::mutex> lock(mPlots);
// render image
QImage savedImage(size().width(), size().height(), QImage::Format_RGB32);
QPainter painter(&savedImage);

View File

@ -865,6 +865,7 @@ void qTabMeasurement::SetNextFrameNumber(int val) {
}
void qTabMeasurement::ResetProgress() {
std::lock_guard<std::mutex> lock(mProgress);
LOG(logDEBUG) << "Resetting progress";
lblCurrentFrame->setText("0");
lblCurrentMeasurement->setText("0");
@ -873,6 +874,7 @@ void qTabMeasurement::ResetProgress() {
void qTabMeasurement::UpdateProgress() {
LOG(logDEBUG) << "Updating progress";
std::lock_guard<std::mutex> lock(mProgress);
progressBar->setValue(plot->GetProgress());
lblCurrentFrame->setText(QString::number(plot->GetCurrentFrameIndex()));
lblCurrentMeasurement->setText(QString::number(currentMeasurement));
@ -920,7 +922,6 @@ void qTabMeasurement::StartAcquisition() {
currentMeasurement = 0;
ResetProgress();
Enable(0);
progressBar->setValue(0);
progressTimer->start(100);
emit EnableTabsSignal(false);
}