src/gui/channellist.cpp: fix minitv gui & segfault

This commit is contained in:
satbaby
2013-01-30 23:37:11 +01:00
parent deeed028d4
commit e509f19361

View File

@@ -465,11 +465,13 @@ void CChannelList::calcSize()
int fw = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getWidth(); 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); width = w_max (((g_settings.channellist_extended)?(frameBuffer->getScreenWidth() / 20 * (fw+6)):(frameBuffer->getScreenWidth() / 20 * (fw+5))), 100);
widthDetails = width; widthDetails = width;
if (g_settings.channellist_minitv) if (g_settings.channellist_minitv){
widthDetails = frameBuffer->getScreenWidth() - frameBuffer->getScreenX(); widthDetails = frameBuffer->getScreenWidth() - frameBuffer->getScreenX();
infozone_width = widthDetails - width;
}
height = h_max ((frameBuffer->getScreenHeight() / 20 * 16), (frameBuffer->getScreenHeight() / 20 * 2)); height = h_max ((frameBuffer->getScreenHeight() / 20 * 16), (frameBuffer->getScreenHeight() / 20 * 2));
if (g_settings.channellist_minitv) 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()); CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, name.c_str());
@@ -503,19 +505,18 @@ void CChannelList::calcSize()
if (g_settings.channellist_minitv) if (g_settings.channellist_minitv)
{ {
width = frameBuffer->getScreenWidth() / 3 * 2; width = frameBuffer->getScreenWidth() / 3 * 2;
x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - widthDetails) / 2; x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - widthDetails) / 2;
y = frameBuffer->getScreenY(); y = frameBuffer->getScreenY();
pig_width = widthDetails / 3 - 16; pig_width = widthDetails / 3 - 16;
pig_height = pig_width / 16 * 9; pig_height = pig_width / 16 * 9;
infozone_width = pig_width - 8; infozone_height = height - theight - pig_height;
infozone_height = height - theight - pig_height;
} }
else else
{ {
x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - width) / 2; x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - width) / 2;
y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - (height+ info_height)) / 2; y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - (height+ info_height)) / 2;
} }
} }
@@ -906,7 +907,7 @@ void CChannelList::hide()
{ {
if (g_settings.channellist_minitv) if (g_settings.channellist_minitv)
{ {
widthDetails = frameBuffer->getScreenWidth() - frameBuffer->getScreenX(); // widthDetails = frameBuffer->getScreenWidth() - frameBuffer->getScreenX();
videoDecoder->Pig(-1, -1, -1, -1); videoDecoder->Pig(-1, -1, -1, -1);
} }
frameBuffer->paintBackgroundBoxRel(x, y, widthDetails, height+ info_height+ 5); frameBuffer->paintBackgroundBoxRel(x, y, widthDetails, height+ info_height+ 5);
@@ -1983,10 +1984,10 @@ void CChannelList::paintHead()
if (gotTime) { if (gotTime) {
int iw3x = (g_settings.channellist_new_zap_mode) ? iw3 : -4; int iw3x = (g_settings.channellist_new_zap_mode) ? iw3 : -4;
if (g_settings.channellist_minitv) 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 y+theight, timestr_len, timestr, COL_MENUHEAD, 0, true); // UTF-8
else 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 y+theight, timestr_len, timestr, COL_MENUHEAD, 0, true); // UTF-8
timestr_len += 4; timestr_len += 4;
} }
@@ -2100,13 +2101,14 @@ void CChannelList::paint_events(int index)
{ {
readEvents(chanlist[index]->channel_id); readEvents(chanlist[index]->channel_id);
frameBuffer->paintBoxRel(x+ width,y+ theight+pig_height, infozone_width, infozone_height,COL_MENUHEAD_PLUS_0); frameBuffer->paintBoxRel(x+ width,y+ theight+pig_height, infozone_width, infozone_height,COL_MENUHEAD_PLUS_0);
char text1[10]; char text1[10];
CChannelEventList::iterator e; CChannelEventList::iterator e;
time_t azeit; time_t azeit;
time(&azeit); time(&azeit);
int ffheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->getHeight(); int ffheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->getHeight();
if ( evtlist.size() == 0 ) if ( evtlist.empty() )
{ {
CChannelEvent evt; CChannelEvent evt;
@@ -2125,11 +2127,12 @@ void CChannelList::paint_events(int index)
do do
{ {
//printf("%d seconds in the past - deleted %s\n", dif, e->description.c_str()); //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; dif = azeit - e->startTime;
} }
while ( dif > 0 ); while (!evtlist.empty() && dif > 0 );
} }
//Display the remaining events //Display the remaining events
struct tm *tmStartZeit = localtime(&e->startTime); struct tm *tmStartZeit = localtime(&e->startTime);
strftime(text1, sizeof(text1), "%H:%M", tmStartZeit ); strftime(text1, sizeof(text1), "%H:%M", tmStartZeit );
@@ -2146,7 +2149,8 @@ void CChannelList::paint_events(int index)
} }
i++; i++;
} }
evtlist.clear(); if ( !evtlist.empty() )
evtlist.clear();
} }
static bool sortByDateTime (const CChannelEvent& a, const CChannelEvent& b) static bool sortByDateTime (const CChannelEvent& a, const CChannelEvent& b)