mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 03:10:02 +02:00
gui crash qtimer (#551)
* locks when qtimer runs out same time as acquisitionfinished * fix for newer gcc
This commit is contained in:
parent
1df4aba8ec
commit
e385618d09
@ -4,6 +4,8 @@
|
|||||||
#include "sls/Detector.h"
|
#include "sls/Detector.h"
|
||||||
#include "ui_form_tab_measurement.h"
|
#include "ui_form_tab_measurement.h"
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
class QStandardItemModel;
|
class QStandardItemModel;
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
@ -100,6 +102,8 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
|
|||||||
bool isAcquisitionStopped{false};
|
bool isAcquisitionStopped{false};
|
||||||
int numMeasurements{1};
|
int numMeasurements{1};
|
||||||
int currentMeasurement{0};
|
int currentMeasurement{0};
|
||||||
|
mutable std::mutex mProgress;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "SlsQt1DZoomer.h"
|
#include "SlsQt1DZoomer.h"
|
||||||
#include "sls/ansi.h"
|
#include "sls/ansi.h"
|
||||||
|
#include <array>
|
||||||
#include <qwt_plot.h>
|
#include <qwt_plot.h>
|
||||||
#include <qwt_plot_curve.h>
|
#include <qwt_plot_curve.h>
|
||||||
#include <qwt_plot_marker.h>
|
#include <qwt_plot_marker.h>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "SlsQt2DHist.h"
|
#include "SlsQt2DHist.h"
|
||||||
#include "SlsQt2DZoomer.h"
|
#include "SlsQt2DZoomer.h"
|
||||||
|
#include <array>
|
||||||
#include <qlist.h>
|
#include <qlist.h>
|
||||||
#include <qwt_plot.h>
|
#include <qwt_plot.h>
|
||||||
#include <qwt_plot_shapeitem.h>
|
#include <qwt_plot_shapeitem.h>
|
||||||
|
@ -254,13 +254,17 @@ void qDrawPlot::resizeEvent(QResizeEvent *event) {
|
|||||||
|
|
||||||
bool qDrawPlot::GetIsRunning() { return isRunning; }
|
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; }
|
double qDrawPlot::GetProgress() { return progress; }
|
||||||
|
|
||||||
int64_t qDrawPlot::GetCurrentFrameIndex() { return currentFrame; }
|
int64_t qDrawPlot::GetCurrentFrameIndex() { return currentFrame; }
|
||||||
|
|
||||||
void qDrawPlot::Select1dPlot(bool enable) {
|
void qDrawPlot::Select1dPlot(bool enable) {
|
||||||
|
std::lock_guard<std::mutex> lock(mPlots);
|
||||||
if (enable) {
|
if (enable) {
|
||||||
is1d = true;
|
is1d = true;
|
||||||
// DetachHists(); it clears the last measurement
|
// DetachHists(); it clears the last measurement
|
||||||
@ -487,6 +491,7 @@ void qDrawPlot::EnableGainPlot(bool enable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void qDrawPlot::SetSaveFileName(QString val) {
|
void qDrawPlot::SetSaveFileName(QString val) {
|
||||||
|
std::lock_guard<std::mutex> lock(mPlots);
|
||||||
LOG(logDEBUG) << "Setting Clone/Save File Name to "
|
LOG(logDEBUG) << "Setting Clone/Save File Name to "
|
||||||
<< val.toAscii().constData();
|
<< val.toAscii().constData();
|
||||||
fileSaveName = val;
|
fileSaveName = val;
|
||||||
@ -592,6 +597,7 @@ void qDrawPlot::ClonePlot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void qDrawPlot::SavePlot() {
|
void qDrawPlot::SavePlot() {
|
||||||
|
std::lock_guard<std::mutex> lock(mPlots);
|
||||||
// render image
|
// render image
|
||||||
QImage savedImage(size().width(), size().height(), QImage::Format_RGB32);
|
QImage savedImage(size().width(), size().height(), QImage::Format_RGB32);
|
||||||
QPainter painter(&savedImage);
|
QPainter painter(&savedImage);
|
||||||
|
@ -865,6 +865,7 @@ void qTabMeasurement::SetNextFrameNumber(int val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void qTabMeasurement::ResetProgress() {
|
void qTabMeasurement::ResetProgress() {
|
||||||
|
std::lock_guard<std::mutex> lock(mProgress);
|
||||||
LOG(logDEBUG) << "Resetting progress";
|
LOG(logDEBUG) << "Resetting progress";
|
||||||
lblCurrentFrame->setText("0");
|
lblCurrentFrame->setText("0");
|
||||||
lblCurrentMeasurement->setText("0");
|
lblCurrentMeasurement->setText("0");
|
||||||
@ -873,6 +874,7 @@ void qTabMeasurement::ResetProgress() {
|
|||||||
|
|
||||||
void qTabMeasurement::UpdateProgress() {
|
void qTabMeasurement::UpdateProgress() {
|
||||||
LOG(logDEBUG) << "Updating progress";
|
LOG(logDEBUG) << "Updating progress";
|
||||||
|
std::lock_guard<std::mutex> lock(mProgress);
|
||||||
progressBar->setValue(plot->GetProgress());
|
progressBar->setValue(plot->GetProgress());
|
||||||
lblCurrentFrame->setText(QString::number(plot->GetCurrentFrameIndex()));
|
lblCurrentFrame->setText(QString::number(plot->GetCurrentFrameIndex()));
|
||||||
lblCurrentMeasurement->setText(QString::number(currentMeasurement));
|
lblCurrentMeasurement->setText(QString::number(currentMeasurement));
|
||||||
@ -920,7 +922,6 @@ void qTabMeasurement::StartAcquisition() {
|
|||||||
currentMeasurement = 0;
|
currentMeasurement = 0;
|
||||||
ResetProgress();
|
ResetProgress();
|
||||||
Enable(0);
|
Enable(0);
|
||||||
progressBar->setValue(0);
|
|
||||||
progressTimer->start(100);
|
progressTimer->start(100);
|
||||||
emit EnableTabsSignal(false);
|
emit EnableTabsSignal(false);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user