Skip to content

Commit

Permalink
Fix #10 (XP crash)
Browse files Browse the repository at this point in the history
After rev. 3bf43e7 behavior of `Worker::finish()` was changed a bit: it begins with `if (started) { stop(); }`
After that using `finish()` in constructor just to initialize fields is incorrect: it would read `started` before actually initializing it.
So initializing fields was separated into another method, `setInitial()`.
  • Loading branch information
NIA committed Mar 31, 2015
1 parent 0f24f7e commit e0edd8a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Worker::Worker(QObject *parent)
: QObject(parent), protocolADC_(NULL), protocolGPS_(NULL)
{
// Set all params to initial values
finish();
setInitial();
}

void Worker::reset(ProtocolCreator *protADC, ProtocolCreator *protGPS) {
Expand Down Expand Up @@ -120,6 +120,13 @@ void Worker::onCheckedGPS(bool success) {
}
}

void Worker::setInitial()
{
autostart = false;
prepared = false;
started = false;
}

void Worker::setPrepared(PrepareResult res) {
prepared = (res == PrepareSuccess);
emit prepareFinished(res);
Expand Down Expand Up @@ -184,9 +191,7 @@ void Worker::finish() {
if (protocolADC_ != protocolGPS_) {
finalizeProtocol(protocolGPS_);
}
autostart = false;
prepared = false;
started = false;
setInitial();
emit finished();
}

Expand Down
12 changes: 12 additions & 0 deletions src/worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ private slots:
void onCheckedADC(bool);
void onCheckedGPS(bool);
private:
/*! Initializes all fields */
void setInitial();
/*!
* \brief Clever setter for \a prepared
* \param res the result of preparing (\see PrepareResult)
*
* Does three things:
*
* 1. Sets \a prepared to either true or false
* 2. Emits Worker::prepareFinished() passing \a res to it
* 3. If \a autostart enabled, starts worker
*/
void setPrepared(PrepareResult res);

void assignProtocol(Protocol *& lvalue, ProtocolCreator * rvalue);
Expand Down

0 comments on commit e0edd8a

Please sign in to comment.