Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Bugfix-patch for the show replay mode -crash



Hi,
 
On Wed, 28 Jul 2004, Achim Tuffentsammer wrote:
> Kimmo Tykkala wrote:
>
> >Press fast-forward/rewind/pause button while the menu is on.
> >VDR crashes immediately and writes the following line to the
> >/var/log/messages -file:
> >Jul 27 21:16:42 tiivitaavi vdr[2684]: ERROR: attempt to open OSD
while
> >it is already open!
> >
> >If the "show replay mode" is turned off, the crash won't happen.
> >
> >
> I can confirm this crash. When this error occurs cOsdProvider::NewOsd
> returns NULL. There are several places in the source code where this
is
> not checked for NULL.
>

attached is a small fix for the bug described above.

The fix is a couple of NULL-checkings before the skins try 
to show the replay mode -indicator on screen. With the fix the 
replay mode will change, but VDR does not try to show the changed 
replay mode if the screen is already occupied by the menu. 
 
The patch is written for 1.3.12 and it fixes both the classic and new
VDR-skin.
                                                                                
- Kimmo
                                                                                
--
.

diff -Naur ../v1/skinclassic.c ./skinclassic.c
--- ../v1/skinclassic.c	2004-07-28 23:13:59.333987200 +0300
+++ ./skinclassic.c	2004-07-28 23:14:08.736557792 +0300
@@ -379,6 +379,8 @@
   y2 = 2 * lineHeight;
   y3 = 3 * lineHeight;
   osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + Setup.OSDHeight - y3);
+  if ( osd == NULL) return;
+
   tArea Areas[] = { { x0, y0, x1 - 1, y3 - 1, 4 } };
   osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
   osd->DrawRectangle(x0, y0, x1 - 1, y3 - 1, ModeOnly ? clrTransparent : Theme.Color(clrBackground));
@@ -386,12 +388,14 @@
 
 cSkinClassicDisplayReplay::~cSkinClassicDisplayReplay()
 {
-  delete osd;
+  if ( osd != NULL) 
+    delete osd;
 }
 
 void cSkinClassicDisplayReplay::SetTitle(const char *Title)
 {
-  osd->DrawText(x0, y0, Title, Theme.Color(clrReplayTitle), Theme.Color(clrBackground), cFont::GetFont(fontOsd), x1 - x0);
+  if ( osd != NULL) 
+    osd->DrawText(x0, y0, Title, Theme.Color(clrReplayTitle), Theme.Color(clrBackground), cFont::GetFont(fontOsd), x1 - x0);
 }
 
 void cSkinClassicDisplayReplay::SetMode(bool Play, bool Forward, int Speed)
@@ -412,12 +416,16 @@
 
 void cSkinClassicDisplayReplay::SetProgress(int Current, int Total)
 {
+  if ( osd == NULL) return;
+
   cProgressBar pb(x1 - x0, y2 - y1, Current, Total, marks, Theme.Color(clrReplayProgressSeen), Theme.Color(clrReplayProgressRest), Theme.Color(clrReplayProgressSelected), Theme.Color(clrReplayProgressMark), Theme.Color(clrReplayProgressCurrent));
   osd->DrawBitmap(x0, y1, pb);
 }
 
 void cSkinClassicDisplayReplay::SetCurrent(const char *Current)
 {
+  if ( osd == NULL) return;
+
   const cFont *font = cFont::GetFont(fontOsd);
   int w = font->Width(Current);
   osd->DrawText(x0, y2, Current, Theme.Color(clrReplayCurrent), Theme.Color(clrBackground), font, lastCurrentWidth > w ? lastCurrentWidth : 0);
@@ -426,17 +434,22 @@
 
 void cSkinClassicDisplayReplay::SetTotal(const char *Total)
 {
+  if ( osd == NULL) return;
+
   const cFont *font = cFont::GetFont(fontOsd);
   osd->DrawText(x1 - font->Width(Total), y2, Total, Theme.Color(clrReplayTotal), Theme.Color(clrBackground), font);
 }
 
 void cSkinClassicDisplayReplay::SetJump(const char *Jump)
 {
-  osd->DrawText(x0 + (x1 - x0) / 4, y2, Jump, Theme.Color(clrReplayModeJump), Theme.Color(clrBackground), cFont::GetFont(fontOsd), (x1 - x0) / 2, 0, taCenter);
+  if ( osd != NULL) 
+    osd->DrawText(x0 + (x1 - x0) / 4, y2, Jump, Theme.Color(clrReplayModeJump), Theme.Color(clrBackground), cFont::GetFont(fontOsd), (x1 - x0) / 2, 0, taCenter);
 }
 
 void cSkinClassicDisplayReplay::SetMessage(eMessageType Type, const char *Text)
 {
+  if ( osd == NULL) return;
+
   const cFont *font = cFont::GetFont(fontOsd);
   if (Text) {
      osd->SaveRegion(x0, y2, x1 - 1, y3 - 1);
@@ -451,7 +464,8 @@
 
 void cSkinClassicDisplayReplay::Flush(void)
 {
-  osd->Flush();
+  if ( osd != NULL ) 
+    osd->Flush();
 }
 
 // --- cSkinClassicDisplayVolume ---------------------------------------------
diff -Naur ../v1/skinsttng.c ./skinsttng.c
--- ../v1/skinsttng.c	2004-07-28 23:15:37.598048792 +0300
+++ ./skinsttng.c	2004-07-28 22:59:28.307842400 +0300
@@ -643,6 +643,10 @@
   int yt = (y0 + y1) / 2;
   int yb = (y6 + y7) / 2;
   osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + Setup.OSDHeight - y7);
+  if ( osd == NULL ) {
+	return;
+  }
+
   tArea Areas[] = { { 0, 0, x7 - 1, y7 - 1, 4 } };
   osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
   osd->DrawRectangle(x0, y0, x7 - 1, y7 - 1, ModeOnly ? clrTransparent : Theme.Color(clrBackground));
@@ -671,12 +675,14 @@
 
 cSkinSTTNGDisplayReplay::~cSkinSTTNGDisplayReplay()
 {
-  delete osd;
+  if ( osd != NULL)
+    delete osd;
 }
 
 void cSkinSTTNGDisplayReplay::SetTitle(const char *Title)
 {
-  osd->DrawText(x3 + 5, y0, Title, Theme.Color(clrReplayTitle), frameColor, cFont::GetFont(fontSml), x4 - x3 - 5);
+  if ( osd != NULL) 
+    osd->DrawText(x3 + 5, y0, Title, Theme.Color(clrReplayTitle), frameColor, cFont::GetFont(fontSml), x4 - x3 - 5);
 }
 
 static char **ReplaySymbols[2][2][5] = {
@@ -688,6 +694,8 @@
 
 void cSkinSTTNGDisplayReplay::SetMode(bool Play, bool Forward, int Speed)
 {
+  if ( osd == NULL) return;
+
   if (Speed < -1)
      Speed = -1;
   if (Speed > 3)
@@ -698,12 +706,16 @@
 
 void cSkinSTTNGDisplayReplay::SetProgress(int Current, int Total)
 {
+  if ( osd == NULL) return;
+
   cProgressBar pb(x4 - x3, y4 - y3, Current, Total, marks, Theme.Color(clrReplayProgressSeen), Theme.Color(clrReplayProgressRest), Theme.Color(clrReplayProgressSelected), Theme.Color(clrReplayProgressMark), Theme.Color(clrReplayProgressCurrent));
   osd->DrawBitmap(x3, y3, pb);
 }
 
 void cSkinSTTNGDisplayReplay::SetCurrent(const char *Current)
 {
+  if ( osd == NULL) return;
+
   const cFont *font = cFont::GetFont(fontSml);
   int w = font->Width(Current);
   osd->DrawText(x3, y6, Current, Theme.Color(clrReplayCurrent), frameColor, font, lastCurrentWidth > w ? lastCurrentWidth : 0);
@@ -712,17 +724,21 @@
 
 void cSkinSTTNGDisplayReplay::SetTotal(const char *Total)
 {
+  if ( osd == NULL) return;
+
   const cFont *font = cFont::GetFont(fontSml);
   osd->DrawText(x4 - font->Width(Total) - 5, y6, Total, Theme.Color(clrReplayTotal), frameColor, font);
 }
 
 void cSkinSTTNGDisplayReplay::SetJump(const char *Jump)
 {
-  osd->DrawText(x0 + (x4 - x0) / 4, y6, Jump, Theme.Color(clrReplayJump), frameColor, cFont::GetFont(fontSml), (x4 - x3) / 2, 0, taCenter);
+  if ( osd != NULL) 
+    osd->DrawText(x0 + (x4 - x0) / 4, y6, Jump, Theme.Color(clrReplayJump), frameColor, cFont::GetFont(fontSml), (x4 - x3) / 2, 0, taCenter);
 }
 
 void cSkinSTTNGDisplayReplay::SetMessage(eMessageType Type, const char *Text)
 {
+  if ( osd == NULL) return;
   const cFont *font = cFont::GetFont(fontSml);
   if (Text) {
      osd->SaveRegion(x2, y6, x4 - 1, y7 - 1);
@@ -738,7 +754,8 @@
 
 void cSkinSTTNGDisplayReplay::Flush(void)
 {
-  osd->Flush();
+  if ( osd != NULL) 
+    osd->Flush();
 }
 
 // --- cSkinSTTNGDisplayVolume -----------------------------------------------

Home | Main Index | Thread Index