Re: Question for C++ guru's..

From: Omer Zak <omerz_at_actcom.co.il>
Date: Tue Dec 26 2006 - 06:32:52 CET

One thing is not clear to me in the following explanation:
How does it happen that XAP_UnixGnomePrintGraphics also contonstructs
GR_UnixPangoGraphics.
Does GR_Graphics inherit from GR_UnixPangoGraphics?

Anyway, you may want to check into the following:
1. Is there multiple inheritance somewhere? (I consider it to be topic
which is prone to trip you on compiler bugs, unless you inherit data
members only from one class, and the other ancestor classes are
interfaces with only virtual functions.)
2. Create a class with the three problematic functions declared as pure
virtuals, and have both GR_UnixGraphics and GR_Graphics inherit from it.
If anyone multiply-inherits from them, then this class can be declared
as virtual public class.
3. Review the entire inheritance tree and restructure it - maybe split
off the three functions to another interface (class which declares only
pure virtual functions), which everyone will inherit separately from the
other functions.
                                     --- Omer

On Tue, 2006-12-26 at 14:21 +1100, msevior@physics.unimelb.edu.au wrote:
> Hi everyone,
> After a little investigating I found that the reason printing
> on unix is not working right is because the virtual methods
> are called.
> GR_UnixPangoGraphics is defined with this inheritence..
>
> class ABI_EXPORT GR_UnixPangoGraphics : public GR_UnixGraphics
>
> and has these methods..
>
>
> virtual UT_uint32 getFontAscent(GR_Font *);
> virtual UT_uint32 getFontDescent(GR_Font *);
> virtual UT_uint32 getFontHeight(GR_Font *);
>
> XAP_UnixGnomePrintGraphics is defined this way
>
> class XAP_UnixGnomePrintGraphics : public GR_Graphics
>
> has the same virtual methods..
>
>
>
> virtual UT_uint32 getFontAscent(GR_Font *);
> virtual UT_uint32 getFontDescent(GR_Font *);
> virtual UT_uint32 getFontHeight(GR_Font *);
>
> Now the constructor of XAP_UnixGnomePrintGraphics also contonstructs
> GR_UnixPangoGraphics, then in fp_Run.cpp::_inheritProperties we calculate
> the height of the run with this call...
>
> _setHeight(getGraphics()->getFontHeight(pFont));
>
> Which resolves to
>
> GR_UnixPangoGraphics::getFontHeight(GR_Font *)
>
> and not to
>
> XAP_UnixGnomePrintGraphics::getFontHeight(GR_Font *)
>
> Which is why the line spacing when printing is wrong.
>
> Do any of our C++ guru's know what is going on and how to fix it?
>
> Cheers
>
> Martin

-- 
Delay is the deadliest form of denial.    C. Northcote Parkinson
My own blog is at http://tddpirate.livejournal.com/
My opinions, as expressed in this E-mail message, are mine alone.
They do not represent the official policy of any organization with which
I may be affiliated in any way.
WARNING TO SPAMMERS:  at http://www.zak.co.il/spamwarning.html
Received on Tue Dec 26 06:29:53 2006

This archive was generated by hypermail 2.1.8 : Tue Dec 26 2006 - 06:29:54 CET