<div dir="ltr">Hello,<div><br></div><div>I have a stupid mistake in my code. This is the problem (very simplified):</div><div><br></div><div>postgisrasterdataset.cpp</div><div><br></div><div>PostGISRasterDataset::IRasterIO(....)</div>
<div>{</div><div> // Two attributes of my class, that inherits from GDALDataset</div><div> pszAttribute = CPLStrdup("foo");</div><div> pszAttribute2 = CPLStrdup("bar");</div><div><br></div><div>
// Just delegates in default implementation</div><div> return GDALDataset::IRasterIO(...);</div><div>}</div><div><br></div><div><br></div><div>postgisrasterrasterband.cpp</div><div><br></div><div>PostGISRasterRasterBand::IRasterIO(....)</div>
<div>{</div><div> // Get pointer to dataset this rasterband belongs to</div><div> PostGISRasterDataset * poRDS = (PostGISRasterDataset *)poDS;</div><div><br></div><div> // Do some stuff with poRDS->pszAttribute and poRDS->pszAttribute2</div>
<div> // They're private vars, but PostGISRasterRasterBand and </div><div> // PostGISRasterDataset are friends. No problem here.</div><div><br></div><div> // Delegates in default implementation. So, this will result, at the end, in calls</div>
<div> // to my implementation of IReadBlock / IWriteBlock</div><div> return GDALRasterBand::IRasterIO(...);</div><div>}</div><div><br></div><div><br></div><div>PostGISRasterRasterBand::IWriteBlock(...)</div><div>{</div>
<div> // Get pointer to dataset this rasterband belongs to</div><div> PostGISRasterDataset * poRDS = (PostGISRasterDataset *)poDS;</div><div><br></div><div> // Try to work with poRDS->pszAttribute and poRDS->pszAttribute2, but</div>
<div> // fails because they are NULL. Why??</div><div>}</div><div><br></div><div>Weirdest thing is the rest of cuestom attributes of my PostGISRasterDataset class are accessible. And, of course, the poRDS pointer is always the same (same mem address). Only problem is with those char * attributes. Looks like they're freed at some point (or I'm doing something really wrong from the point of view of C++, and I deserve a severe punishment for that).</div>
<div><br></div><div>Any clues?</div><div><br></div><div>Best regards,</div><div><div><br></div>-- <br>Jorge Arevalo<br><br><a href="http://about.me/jorgeas80" target="_blank">http://about.me/jorgeas80</a>
</div></div>