Skip to content
Snippets Groups Projects
Commit b94a5984 authored by am0ebe's avatar am0ebe
Browse files

cam: add timer member. fix double stoprecord error (when user cancels recording)

parent c8c605fc
No related branches found
No related tags found
No related merge requests found
......@@ -22,8 +22,11 @@ _id(""),
_state(closed),
_frames(FramePtrVector(threadsPerCam())),
_payloadSize(0LL),
_pixelFormat("")
_pixelFormat(""),
_timer(new QTimer(this))
{
_timer->setSingleShot(true);
connect(_timer, SIGNAL(timeout()), this, SLOT(stopRecording()));
name();
}
......@@ -143,7 +146,7 @@ void Cam::startRecording(seconds dur)
// Convert to milliseconds
auto dur_ms = duration_cast<milliseconds>(dur).count();
QTimer::singleShot(dur_ms, this, SLOT(stopRecording()));
_timer->start(dur_ms);
}
void Cam::startRecording(minutes dur)
......@@ -151,6 +154,7 @@ void Cam::startRecording(minutes dur)
// Convert to seconds
auto dur_s = duration_cast<seconds>(dur);
startRecording(dur_s);
}
/* Does:
......@@ -161,6 +165,8 @@ void Cam::startRecording(minutes dur)
*/
void Cam::stopRecording()
{
_timer->stop();
FeaturePtr pFeature;
try
{
......
......@@ -19,6 +19,7 @@ using VmbCPP::FramePtrVector;
using std::chrono::minutes;
using std::chrono::seconds;
class QTimer;
class Cam;
using CamPtr = std::shared_ptr<Cam>;
using CamPtrVector = std::vector<CamPtr>;
......@@ -65,5 +66,6 @@ private:
FramePtrVector _frames;
VmbInt64_t _payloadSize;
std::string _pixelFormat;
QTimer* _timer;
};
......@@ -25,7 +25,7 @@ Core::Core() : IPrinter(),
_apiStarted( false ),
_sys( VmbSystem::GetInstance() ), // create and get Vimba singleton
_cameras( CamPtrVector() ),
_recDuration( 6s ) //default
_recDuration( 16s ) //default
{
QTimer::singleShot(0, this, SLOT(init())); //delayed init to allow connections to be established -> print/error signals!
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment