Fixed font handling to be thread-safe.

This commit is contained in:
Rolf Ahrenberg 2009-06-18 12:16:11 +03:00
parent 0a162a9a8c
commit afd72642e9
3 changed files with 21 additions and 9 deletions

View File

@ -339,6 +339,10 @@ VDR Plugin 'femon' Revision History
- Backported from 1.7.1. - Backported from 1.7.1.
2009-06-18: Version 1.6.7
- Backported from 1.7.2.
=================================== ===================================
VDR Plugin 'femon' Revision History VDR Plugin 'femon' Revision History
=================================== ===================================
@ -356,6 +360,7 @@ VDR Plugin 'femon' Revision History
- Fixed closing of frontend file handles (Thanks to Brendon Higgins for - Fixed closing of frontend file handles (Thanks to Brendon Higgins for
reporting this one). reporting this one).
2009-xx-xx: Version 1.7.2 2009-06-18: Version 1.7.2
- Cleaned up compilation warnings. - Cleaned up compilation warnings.
- Fixed font handling to be thread-safe.

View File

@ -116,6 +116,14 @@
#define OSDCLEARINFO() \ #define OSDCLEARINFO() \
m_Osd->DrawRectangle(0, OSDINFOWIN_Y(0), OSDWIDTH, OSDINFOWIN_Y(OSDINFOHEIGHT) - 1, clrTransparent) m_Osd->DrawRectangle(0, OSDINFOWIN_Y(0), OSDWIDTH, OSDINFOWIN_Y(OSDINFOHEIGHT) - 1, clrTransparent)
class cFemonDummyFont : public cFont {
public:
virtual int Width(uint c) const { return 10; }
virtual int Width(const char *s) const { return 50; }
virtual int Height(void) const { return 20; }
virtual void DrawText(cBitmap *Bitmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const {}
};
cFemonOsd *cFemonOsd::pInstance = NULL; cFemonOsd *cFemonOsd::pInstance = NULL;
cFemonOsd *cFemonOsd::Instance(bool create) cFemonOsd *cFemonOsd::Instance(bool create)
@ -150,14 +158,11 @@ cFemonOsd::cFemonOsd()
{ {
Dprintf("%s()\n", __PRETTY_FUNCTION__); Dprintf("%s()\n", __PRETTY_FUNCTION__);
m_SvdrpConnection.handle = -1; m_SvdrpConnection.handle = -1;
if (Setup.UseSmallFont == 0) { m_Font = cFont::CreateFont(Setup.FontSml, min(max(Setup.FontSmlSize, MINFONTSIZE), MAXFONTSIZE));
// Dirty hack to force the small fonts... if (!m_Font || !m_Font->Height()) {
Setup.UseSmallFont = 1; m_Font = new cFemonDummyFont;
m_Font = cFont::GetFont(fontSml); esyslog("ERROR: cFemonOsd::cFemonOsd() cannot create required font.");
Setup.UseSmallFont = 0;
} }
else
m_Font = cFont::GetFont(fontSml);
if (OSDHEIGHT < (OSDINFOHEIGHT + OSDROWHEIGHT + OSDSTATUSHEIGHT)) if (OSDHEIGHT < (OSDINFOHEIGHT + OSDROWHEIGHT + OSDSTATUSHEIGHT))
OSDHEIGHT = (OSDINFOHEIGHT + OSDROWHEIGHT + OSDSTATUSHEIGHT); OSDHEIGHT = (OSDINFOHEIGHT + OSDROWHEIGHT + OSDSTATUSHEIGHT);
} }
@ -179,6 +184,8 @@ cFemonOsd::~cFemonOsd(void)
} }
if (m_Osd) if (m_Osd)
DELETENULL(m_Osd); DELETENULL(m_Osd);
if (m_Font)
DELETENULL(m_Font);
if (m_Frontend >= 0) { if (m_Frontend >= 0) {
close(m_Frontend); close(m_Frontend);
m_Frontend = -1; m_Frontend = -1;

View File

@ -43,7 +43,7 @@ private:
uint32_t m_UNC; uint32_t m_UNC;
fe_status_t m_FrontendStatus; fe_status_t m_FrontendStatus;
int m_DisplayMode; int m_DisplayMode;
const cFont *m_Font; cFont *m_Font;
cTimeMs m_InputTime; cTimeMs m_InputTime;
cCondWait m_Sleep; cCondWait m_Sleep;
cMutex m_Mutex; cMutex m_Mutex;