Skip to content

Commit e20faef

Browse files
committed
checksum calculation no longer depends on imageType (PROPMAN-36)
1 parent dc444cb commit e20faef

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/image/propellerimage.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "../util/logging.h"
44

5-
PropellerImage::PropellerImage(QByteArray image, QString filename)
5+
PropellerImage::PropellerImage(const QByteArray & image, const QString & filename)
66
{
77
_image = image;
88
_filename = filename;
@@ -31,9 +31,11 @@ quint8 PropellerImage::checksum()
3131
{
3232
quint8 sum = 0;
3333
foreach (quint8 c, _image)
34+
{
3435
sum += c;
36+
}
3537

36-
if (_type == Binary)
38+
if (imageSize() <= programSize())
3739
sum += 2 * (0xff + 0xff + 0xff + 0xf9);
3840

3941
return sum;
@@ -75,8 +77,10 @@ QByteArray PropellerImage::data()
7577
Sets the raw binary data of the image.
7678
*/
7779

78-
void PropellerImage::setData(QByteArray data) {
80+
void PropellerImage::setData(QByteArray data)
81+
{
7982
_image = data;
83+
_image.detach();
8084
}
8185

8286
/**

src/image/propellerimage.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ class PropellerImage
9595

9696
public:
9797

98-
PropellerImage( QByteArray image = QByteArray(),
99-
QString filename = "");
98+
PropellerImage( const QByteArray & image = QByteArray(),
99+
const QString & filename = "");
100100

101101
/**
102102
@name Image Validation

0 commit comments

Comments
 (0)