1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-31 11:35:24 +01:00

There are no gotos in this code

This commit is contained in:
David Sansome 2010-09-13 23:44:11 +00:00
parent d08389bb9d
commit 89c873f9ef
2 changed files with 37 additions and 0 deletions

View File

@ -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<lastfm::XmlQuery> 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

View File

@ -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...