Browse files

OSD: Fix subtitle window painting order.

The order of iterating over a QHash is arbitrary and the fact that
subtitle and interactive screens have (mostly) been drawn in the correct
order since the OSD re-write is pure luck.

So switch to a QMap which, while marginally slower, will order on the
basis of the key (QString) and force the subtitle/interactive screens to
be painted first by adding some numerics to their identifiers.

Should fix the ordering issue seen in #9822 and occasionally in the yet
to be enabled blu-ray HDMV navigation mode.

Cherry picked from master be25039

Fixes #9822
  • Loading branch information...
1 parent 18ab626 commit 1be38ea4edbbf251f0a06d8e44fec27cfa1b12af Mark Kendall committed Jun 13, 2011
Showing with 16 additions and 8 deletions.
  1. +8 −4 mythtv/libs/libmythtv/osd.cpp
  2. +8 −4 mythtv/libs/libmythtv/osd.h
View
12 mythtv/libs/libmythtv/osd.cpp
@@ -200,7 +200,7 @@ void OSD::SetPainter(MythPainter *painter)
return;
m_CurrentPainter = painter;
- QHashIterator<QString, MythScreenType*> it(m_Children);
+ QMapIterator<QString, MythScreenType*> it(m_Children);
while (it.hasNext())
{
it.next();
@@ -275,7 +275,7 @@ bool OSD::IsVisible(void)
void OSD::HideAll(bool keepsubs, MythScreenType* except)
{
- QMutableHashIterator<QString, MythScreenType*> it(m_Children);
+ QMutableMapIterator<QString, MythScreenType*> it(m_Children);
while (it.hasNext())
{
it.next();
@@ -538,7 +538,7 @@ bool OSD::DrawDirect(MythPainter* painter, QSize size, bool repaint)
QTime now = QTime::currentTime();
CheckExpiry();
- QHash<QString,MythScreenType*>::iterator it;
+ QMap<QString,MythScreenType*>::const_iterator it;
for (it = m_Children.begin(); it != m_Children.end(); ++it)
{
if (it.value()->IsVisible())
@@ -594,7 +594,7 @@ QRegion OSD::Draw(MythPainter* painter, QPaintDevice *device, QSize size,
CheckExpiry();
// first update for alpha pulse and fade
- QHash<QString,MythScreenType*>::iterator it;
+ QMap<QString,MythScreenType*>::const_iterator it;
for (it = m_Children.begin(); it != m_Children.end(); ++it)
{
if (it.value()->IsVisible())
@@ -990,6 +990,8 @@ TeletextScreen* OSD::InitTeletext(void)
if (tt->Create())
{
m_Children.insert(OSD_WIN_TELETEXT, tt);
+ VERBOSE(VB_PLAYBACK, LOC + QString("Created window %1")
+ .arg(OSD_WIN_TELETEXT));
}
else
{
@@ -1096,6 +1098,8 @@ SubtitleScreen* OSD::InitSubtitles(void)
if (sub->Create())
{
m_Children.insert(OSD_WIN_SUBTITLE, sub);
+ VERBOSE(VB_PLAYBACK, LOC + QString("Created window %1")
+ .arg(OSD_WIN_SUBTITLE));
}
else
{
View
12 mythtv/libs/libmythtv/osd.h
@@ -19,9 +19,13 @@ struct AVSubtitle;
#define OSD_DLG_EDITOR "OSD_EDITOR"
#define OSD_DLG_CUTPOINT "OSD_CUTPOINT"
#define OSD_DLG_DELETE "OSD_DELETE"
-#define OSD_WIN_TELETEXT "OSD_TELETEXT"
-#define OSD_WIN_SUBTITLE "OSD_SUBTITLES"
-#define OSD_WIN_INTERACT "OSD_INTERACTIVE"
+// Force subtitle/interactive screens to be drawn first (i.e. at the back) by
+// prepending their identifiers with a low numeric (may not always work as
+// QMap/QString ordering is based on unicode values)
+#define OSD_WIN_TELETEXT "00_OSD_TELETEXT"
+#define OSD_WIN_SUBTITLE "00_OSD_SUBTITLES"
+// MHEG should cover subtitles
+#define OSD_WIN_INTERACT "01_OSD_INTERACTIVE"
#define kOSDFadeTime 1000
@@ -210,7 +214,7 @@ class OSD
enum OSDFunctionalType m_FunctionalType;
QString m_FunctionalWindow;
- QHash<QString, MythScreenType*> m_Children;
+ QMap<QString, MythScreenType*> m_Children;
QHash<MythScreenType*, QDateTime> m_ExpireTimes;
};

0 comments on commit 1be38ea

Please sign in to comment.