From 89c873f9ef8e3adb95b7b513238ce08001b0f9f6 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Mon, 13 Sep 2010 23:44:11 +0000 Subject: [PATCH] There are no gotos in this code --- src/core/albumcoverfetcher.cpp | 7 +++++++ src/radio/lastfmservice.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/core/albumcoverfetcher.cpp b/src/core/albumcoverfetcher.cpp index 07eaf72d9..2038bc0b2 100644 --- a/src/core/albumcoverfetcher.cpp +++ b/src/core/albumcoverfetcher.cpp @@ -104,6 +104,10 @@ void AlbumCoverFetcher::AlbumSearchFinished() { try { lastfm::XmlQuery query(lastfm::ws::parse(reply)); +#ifdef Q_OS_WIN32 + if (lastfm::ws::last_parse_error != lastfm::ws::NoError) + goto lastfm_error; +#endif // Parse the list of search results QList elements = query["results"]["albummatches"].children("album"); @@ -134,6 +138,9 @@ void AlbumCoverFetcher::AlbumSearchFinished() { active_requests_[image_reply] = request; } catch (std::runtime_error&) { +#ifdef Q_OS_WIN32 + lastfm_error: +#endif if (request.search) emit SearchFinished(request.id, AlbumCoverFetcher::SearchResults()); else diff --git a/src/radio/lastfmservice.cpp b/src/radio/lastfmservice.cpp index b2ad30666..8490ee0b2 100644 --- a/src/radio/lastfmservice.cpp +++ b/src/radio/lastfmservice.cpp @@ -210,10 +210,17 @@ void LastFMService::AuthenticateReplyFinished() { // Parse the reply try { lastfm::XmlQuery const lfm = lastfm::ws::parse(reply); +#ifdef Q_OS_WIN32 + if (lastfm::ws::last_parse_error != lastfm::ws::NoError) + goto lastfm_error; +#endif lastfm::ws::Username = lfm["session"]["name"].text(); lastfm::ws::SessionKey = lfm["session"]["key"].text(); } catch (std::runtime_error& e) { +#ifdef Q_OS_WIN32 + lastfm_error: +#endif qDebug() << e.what(); emit AuthenticationComplete(false); return; @@ -494,7 +501,14 @@ void LastFMService::RefreshFriendsFinished() { try { friends = lastfm::User::list(reply); +#ifdef Q_OS_WIN32 + if (lastfm::ws::last_parse_error != lastfm::ws::NoError) + goto lastfm_error; +#endif } catch (std::runtime_error& e) { +#ifdef Q_OS_WIN32 + lastfm_error: +#endif qDebug() << e.what(); return; } @@ -516,7 +530,14 @@ void LastFMService::RefreshNeighboursFinished() { try { neighbours = lastfm::User::list(reply); +#ifdef Q_OS_WIN32 + if (lastfm::ws::last_parse_error != lastfm::ws::NoError) + goto lastfm_error; +#endif } catch (std::runtime_error& e) { +#ifdef Q_OS_WIN32 + lastfm_error: +#endif qDebug() << e.what(); return; } @@ -625,6 +646,11 @@ void LastFMService::FetchMoreTracksFinished() { try { const XmlQuery& query = lastfm::ws::parse(reply); +#ifdef Q_OS_WIN32 + if (lastfm::ws::last_parse_error != lastfm::ws::NoError) + goto lastfm_error; +#endif + const XmlQuery& playlist = query["playlist"]; foreach (const XmlQuery& q, playlist["trackList"].children("track")) { lastfm::MutableTrack t; @@ -640,6 +666,10 @@ void LastFMService::FetchMoreTracksFinished() { playlist_ << t; } } catch (std::runtime_error& e) { +#ifdef Q_OS_WIN32 + lastfm_error: +#endif + // For some reason a catch block that takes a lastfm::ws::ParseError& // doesn't get called, even when a lastfm::ws::ParseError is thrown... // Hacks like this remind me of Java...