Actually, I've gone ahead with this change in r12222. It fixes a tonne of -Wcast-align warnings. If it seems like a bad idea, we can easily revert.
On 18 March 2013 12:20, Alex Valavanis <valavanisalex@...400...> wrote:
Hi All,
I'm a bit confused about the way that SPItemCtx is implemented. I have a few questions:
SPItemCtx is defined in src/sp-item.h as follows:
/// Contains transformations to document/viewport and the viewport size. class SPItemCtx { public: SPCtx ctx; /** Item to document transformation */ Geom::Affine i2doc; /** Viewport size */ Geom::Rect viewport; /** Item to viewport transformation */ Geom::Affine i2vp; };
As far as I can tell, the only place where an SPItemCtx object is created is in the SPDocument::_updateDocument() function. It is then cast to SPCtx object and sent to the updateDisplay function. Various "update" handlers then retrieve the SPItemCtx data by casting back:
SPItemCtx *ictx = (SPItemCtx *) ctx; double const aw = 1.0 / ictx->i2vp.descrim();
This seems a bit weird to me... why not make SPItemCtx a subclass of SPCtx? That way, we wouldn't need to do risky reinterpret_cast<> operations.
Any thoughts?
AV