From e509f193610e972e2d255a5e9fe2003bccdb14bd Mon Sep 17 00:00:00 2001 From: satbaby Date: Wed, 30 Jan 2013 23:37:11 +0100 Subject: [PATCH] src/gui/channellist.cpp: fix minitv gui & segfault --- src/gui/channellist.cpp | 42 ++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index fb95ad6ec..f58e96ec3 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -465,11 +465,13 @@ void CChannelList::calcSize() int fw = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getWidth(); width = w_max (((g_settings.channellist_extended)?(frameBuffer->getScreenWidth() / 20 * (fw+6)):(frameBuffer->getScreenWidth() / 20 * (fw+5))), 100); widthDetails = width; - if (g_settings.channellist_minitv) + if (g_settings.channellist_minitv){ widthDetails = frameBuffer->getScreenWidth() - frameBuffer->getScreenX(); + infozone_width = widthDetails - width; + } height = h_max ((frameBuffer->getScreenHeight() / 20 * 16), (frameBuffer->getScreenHeight() / 20 * 2)); if (g_settings.channellist_minitv) - height = h_max ((frameBuffer->getScreenHeight() / 20 * 18), 0); + height = h_max ((frameBuffer->getScreenHeight() / 20 * 17), 0); CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, name.c_str()); @@ -503,19 +505,18 @@ void CChannelList::calcSize() if (g_settings.channellist_minitv) { - width = frameBuffer->getScreenWidth() / 3 * 2; - x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - widthDetails) / 2; - y = frameBuffer->getScreenY(); - pig_width = widthDetails / 3 - 16; - pig_height = pig_width / 16 * 9; + width = frameBuffer->getScreenWidth() / 3 * 2; + x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - widthDetails) / 2; + y = frameBuffer->getScreenY(); + pig_width = widthDetails / 3 - 16; + pig_height = pig_width / 16 * 9; - infozone_width = pig_width - 8; - infozone_height = height - theight - pig_height; + infozone_height = height - theight - pig_height; } else { - x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - width) / 2; - y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - (height+ info_height)) / 2; + x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - width) / 2; + y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - (height+ info_height)) / 2; } } @@ -906,7 +907,7 @@ void CChannelList::hide() { if (g_settings.channellist_minitv) { - widthDetails = frameBuffer->getScreenWidth() - frameBuffer->getScreenX(); +// widthDetails = frameBuffer->getScreenWidth() - frameBuffer->getScreenX(); videoDecoder->Pig(-1, -1, -1, -1); } frameBuffer->paintBackgroundBoxRel(x, y, widthDetails, height+ info_height+ 5); @@ -1983,10 +1984,10 @@ void CChannelList::paintHead() if (gotTime) { int iw3x = (g_settings.channellist_new_zap_mode) ? iw3 : -4; if (g_settings.channellist_minitv) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x + widthDetails - 16 -timestr_len, + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x + widthDetails - 16 -timestr_len, y+theight, timestr_len, timestr, COL_MENUHEAD, 0, true); // UTF-8 else - g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x + width - iw1 - iw2 - iw3x - 16 -timestr_len, + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x + width - iw1 - iw2 - iw3x - 16 -timestr_len, y+theight, timestr_len, timestr, COL_MENUHEAD, 0, true); // UTF-8 timestr_len += 4; } @@ -2100,13 +2101,14 @@ void CChannelList::paint_events(int index) { readEvents(chanlist[index]->channel_id); frameBuffer->paintBoxRel(x+ width,y+ theight+pig_height, infozone_width, infozone_height,COL_MENUHEAD_PLUS_0); + char text1[10]; CChannelEventList::iterator e; time_t azeit; time(&azeit); int ffheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->getHeight(); - if ( evtlist.size() == 0 ) + if ( evtlist.empty() ) { CChannelEvent evt; @@ -2125,11 +2127,12 @@ void CChannelList::paint_events(int index) do { //printf("%d seconds in the past - deleted %s\n", dif, e->description.c_str()); - e = evtlist.erase(e); + if(!evtlist.empty()) + e = evtlist.erase(e); dif = azeit - e->startTime; } - while ( dif > 0 ); - } + while (!evtlist.empty() && dif > 0 ); + } //Display the remaining events struct tm *tmStartZeit = localtime(&e->startTime); strftime(text1, sizeof(text1), "%H:%M", tmStartZeit ); @@ -2146,7 +2149,8 @@ void CChannelList::paint_events(int index) } i++; } - evtlist.clear(); + if ( !evtlist.empty() ) + evtlist.clear(); } static bool sortByDateTime (const CChannelEvent& a, const CChannelEvent& b)