diff --git a/src/image/propellerimage.cpp b/src/image/propellerimage.cpp index 3f40ba2..82ebe11 100644 --- a/src/image/propellerimage.cpp +++ b/src/image/propellerimage.cpp @@ -2,7 +2,7 @@ #include "../util/logging.h" -PropellerImage::PropellerImage(QByteArray image, QString filename) +PropellerImage::PropellerImage(const QByteArray & image, const QString & filename) { _image = image; _filename = filename; @@ -31,9 +31,11 @@ quint8 PropellerImage::checksum() { quint8 sum = 0; foreach (quint8 c, _image) + { sum += c; + } - if (_type == Binary) + if (imageSize() <= programSize()) sum += 2 * (0xff + 0xff + 0xff + 0xf9); return sum; @@ -75,8 +77,10 @@ QByteArray PropellerImage::data() Sets the raw binary data of the image. */ -void PropellerImage::setData(QByteArray data) { +void PropellerImage::setData(QByteArray data) +{ _image = data; + _image.detach(); } /** diff --git a/src/image/propellerimage.h b/src/image/propellerimage.h index 29c992a..093e7cd 100644 --- a/src/image/propellerimage.h +++ b/src/image/propellerimage.h @@ -95,8 +95,8 @@ class PropellerImage public: - PropellerImage( QByteArray image = QByteArray(), - QString filename = ""); + PropellerImage( const QByteArray & image = QByteArray(), + const QString & filename = ""); /** @name Image Validation