Skip to content

Commit 91c702f

Browse files
committed
fix(chunking): chunk bug seg fault due to #16 fix
added (commented out) debugging to find a spot where the "+1" I deleted for fixing #16 was being compensated for with a "-1". Leaving the commented debug output in place due to not being certain that this is completely resolved.
1 parent 5f3f5fb commit 91c702f

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

GIP/gip/geometry.h

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace gip {
7070
template<typename T=int> class Rect {
7171
public:
7272
//! Default Constructor
73-
Rect() : _p0(0,0), _p1(-1,-1), _padding(0) {}
73+
Rect() : _p0(0,0), _p1(0,0), _padding(0) {}
7474
//! Constructor takes in top left coordinate and width/height
7575
Rect(T x, T y, T width, T height)
7676
: _p0(x,y), _p1(x+width,y+height), _padding(0) {
@@ -237,27 +237,40 @@ namespace gip {
237237
public:
238238
//! Default constructor
239239
ChunkSet()
240-
: _xsize(0), _ysize(0), _padding(0) {}
240+
: _xsize(0), _ysize(0), _padding(0) {
241+
// std::cerr << "ChunkSet DefaultConstructor (x, y, pad) = (0, 0, 0)" << std::endl ;
242+
// std::cerr << "ChunkSet._Chunks.size() = " << _Chunks.size() << std::endl ;
243+
}
241244

242245
//! Constructor taking in image size
243246
ChunkSet(unsigned int xsize, unsigned int ysize, unsigned int padding=0, unsigned int numchunks=0)
244247
: _xsize(xsize), _ysize(ysize), _padding(padding) {
248+
// std::cerr << "ChunkSet SpecificConstructor (x, y, pad, numchunks) = ("
249+
// << _xsize << ", " << _ysize << ", " << _padding << ", " << numchunks << ")" << std::endl ;
245250
ChunkUp(numchunks);
246251
}
247252

248253
//! Copy constructor
249254
ChunkSet(const ChunkSet& chunks)
250255
: _xsize(chunks._xsize), _ysize(chunks._ysize), _padding(chunks._padding) {
256+
// std::cerr << "ChunkSet CopyConstructor (x, y, pad) = ("
257+
// << _xsize << ", " << _ysize << ", " << _padding << ")" << std::endl ;
251258
_Chunks = chunks._Chunks ;
252259
}
253260

254261
//! Assignment copy
255262
ChunkSet& operator=(const ChunkSet& chunks) {
256-
if (this == & chunks) return *this;
263+
if (this == & chunks) {
264+
// std::cerr << "ChunkSet assign to self" << std::endl ;
265+
return *this;
266+
}
257267
_xsize = chunks._xsize;
258268
_ysize = chunks._ysize;
259269
_padding = chunks._padding;
260270
_Chunks = chunks._Chunks ;
271+
int size(_Chunks.size()) ;
272+
// std::cerr << "ChunkSet CopyConstructor (x, y, pad, _chunks.size()) = ("
273+
// << _xsize << ", " << _ysize << ", " << _padding << ", " << size << ")" << std::endl ;
261274
return *this;
262275
}
263276
~ChunkSet() {}
@@ -270,7 +283,9 @@ namespace gip {
270283

271284
//! Determine if region is valid
272285
bool Valid() const {
273-
return (((_xsize * _ysize) == 0) || (Size() == 0)) ? false : true;
286+
bool valid = (((_xsize * _ysize) == 0) || (Size() == 0)) ? false : true;
287+
// std::cerr << "ChunkSet Valid? " << valid << std::endl ;
288+
return valid ;
274289
}
275290

276291
//! Get number of chunks

0 commit comments

Comments
 (0)