Skip to content

Commit

Permalink
Qt covers BC break in Symbian
Browse files Browse the repository at this point in the history
Workaround: fntstore.h has an inlined function
'COpenFont* CBitmapFont::OpenFont()' that returns a private data member.
The header will change between minor SDK versions, thus break BC. But
Qt has to build on any SDK version and run on other versions of Symbian
OS. Also Qt does not want to deliver that BC to Qt based apps.

This hack performs the needed pointer arithmetic to get the right
COpenFont* pointer, no matter if the 'Flexible Memory Model' is already
supported or not.

The author is not proud of this commit.

Task-number: QT-2250
Reviewed-by: Iain
Reviewed-by: Shane Kearns

	modified:   src/gui/text/qfontdatabase_s60.cpp
  • Loading branch information
Alessandro Portale committed Nov 10, 2009
1 parent d752092 commit 7005ca9
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/gui/text/qfontdatabase_s60.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,23 @@ QFontDatabaseS60StoreImplementation::~QFontDatabaseS60StoreImplementation()
m_heap->Close();
}

#ifndef FNTSTORE_H_INLINES_SUPPORT_FMM
/*
Workaround: fntstore.h has an inlined function 'COpenFont* CBitmapFont::OpenFont()'
that returns a private data member. The header will change between SDKs. But Qt has
to build on any SDK version and run on other versions of Symbian OS.
This function performs the needed pointer arithmetic to get the right COpenFont*
*/
COpenFont* OpenFontFromBitmapFont(const CBitmapFont* aBitmapFont)
{
const TInt offsetIOpenFont = 92; // '_FOFF(CBitmapFont, iOpenFont)' ..if iOpenFont weren't private
const TUint valueIOpenFont = *(TUint*)PtrAdd(aBitmapFont, offsetIOpenFont);
return (valueIOpenFont & 1) ?
(COpenFont*)PtrAdd(aBitmapFont, valueIOpenFont & ~1) : // New behavior: iOpenFont is offset
(COpenFont*)valueIOpenFont; // Old behavior: iOpenFont is pointer
}
#endif // FNTSTORE_H_INLINES_SUPPORT_FMM

const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(const QString &typeface) const
{
if (!m_extensions.contains(typeface)) {
Expand All @@ -144,8 +161,14 @@ const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(c
spec.iHeight = 1;
const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, spec);
Q_ASSERT(err == KErrNone && font);
CBitmapFont *bitmapFont = static_cast<CBitmapFont*>(font);
m_extensions.insert(typeface, new QFontEngineS60Extensions(font, bitmapFont->OpenFont()));
const CBitmapFont *bitmapFont = static_cast<CBitmapFont*>(font);
COpenFont *openFont =
#ifdef FNTSTORE_H_INLINES_SUPPORT_FMM
bitmapFont->openFont();
#else
OpenFontFromBitmapFont(bitmapFont);
#endif // FNTSTORE_H_INLINES_SUPPORT_FMM
m_extensions.insert(typeface, new QFontEngineS60Extensions(font, openFont));
}
return m_extensions.value(typeface);
}
Expand Down

0 comments on commit 7005ca9

Please sign in to comment.