From d08a134e8d0668ba3961041b02297d308e2f9f93 Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Thu, 20 Mar 2008 19:49:12 +0100 Subject: fix for #357 and #410 --- pages/searchresults.ecpp | 6 ++++-- tools.cpp | 16 ++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pages/searchresults.ecpp b/pages/searchresults.ecpp index dce7520..0cf1e2c 100644 --- a/pages/searchresults.ecpp +++ b/pages/searchresults.ecpp @@ -61,8 +61,10 @@ bool logged_in(false); string current_day = ""; for (SearchResults::iterator result = results.begin(); result != results.end(); ++result) { - string channelname = Channels.GetByChannelID(result->Channel())->Name(); - int channelnr = Channels.GetByChannelID(result->Channel())->Number(); + cChannel* channel = Channels.GetByChannelID(result->Channel()); + if (!channel) continue; + string channelname = channel->Name(); + int channelnr = channel->Number(); string start(result->StartTime() ? FormatDateTime(tr("%I:%M %p"), result->StartTime()) : ""); string end(result->StopTime() ? FormatDateTime(tr("%I:%M %p"), result->StopTime()) : ""); string day(result->StartTime() ? FormatDateTime(tr("%A, %b %d %Y"), result->StartTime()) : ""); diff --git a/tools.cpp b/tools.cpp index 1839f6b..3a80ff7 100644 --- a/tools.cpp +++ b/tools.cpp @@ -17,12 +17,16 @@ using namespace tnt; istream& operator>>( istream& is, tChannelID& ret ) { - if ( is.rdbuf()->in_avail() > 0 ) { - string line; - if ( !getline( is, line ) || ( !line.empty() && !( ret = tChannelID::FromString( line.c_str() ) ).Valid() ) ) - is.setstate( ios::badbit ); - } - return is; + string line; + if ( !getline( is, line ) ) { + if ( !is.eof() ) + is.setstate( ios::badbit ); + return is; + } + + if ( !line.empty() && !( ret = tChannelID::FromString( line.c_str() ) ).Valid() ) + is.setstate( ios::badbit ); + return is; } namespace vdrlive { -- cgit v1.2.3 From d00342a76f291e9a01548b90ebfe3334959ce7aa Mon Sep 17 00:00:00 2001 From: Dieter Hametner Date: Sat, 22 Mar 2008 00:46:17 +0100 Subject: An other attempt to fix operator>> for tChannelID. --- tools.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tools.cpp b/tools.cpp index 3a80ff7..b8c23ab 100644 --- a/tools.cpp +++ b/tools.cpp @@ -17,16 +17,21 @@ using namespace tnt; istream& operator>>( istream& is, tChannelID& ret ) { - string line; - if ( !getline( is, line ) ) { - if ( !is.eof() ) - is.setstate( ios::badbit ); - return is; - } - - if ( !line.empty() && !( ret = tChannelID::FromString( line.c_str() ) ).Valid() ) - is.setstate( ios::badbit ); - return is; + string line; + if (!getline( is, line ) ) { + if (0 == is.gcount()) { + is.clear(is.rdstate() & ~ios::failbit); + return is; + } + if (!is.eof()) { + is.setstate( ios::badbit ); + return is; + } + } + + if ( !line.empty() && !( ret = tChannelID::FromString( line.c_str() ) ).Valid() ) + is.setstate( ios::badbit ); + return is; } namespace vdrlive { -- cgit v1.2.3 From c9732d7643b30e4414ce5e759019365e08a0ce10 Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Sat, 22 Mar 2008 20:17:31 +0100 Subject: fix for problems with old compilers --- tools.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tools.cpp b/tools.cpp index 3a80ff7..cca1b9d 100644 --- a/tools.cpp +++ b/tools.cpp @@ -17,16 +17,17 @@ using namespace tnt; istream& operator>>( istream& is, tChannelID& ret ) { - string line; - if ( !getline( is, line ) ) { - if ( !is.eof() ) - is.setstate( ios::badbit ); - return is; - } - - if ( !line.empty() && !( ret = tChannelID::FromString( line.c_str() ) ).Valid() ) - is.setstate( ios::badbit ); - return is; + string line; + if ( !getline( is, line ) ) { + if ( !is.eof() ) + is.setstate( ios::badbit ); + else + is.clear(); + return is; + } + if ( !line.empty() && !( ret = tChannelID::FromString( line.c_str() ) ).Valid() ) + is.setstate( ios::badbit ); + return is; } namespace vdrlive { -- cgit v1.2.3