Skip to content

Commit

Permalink
Fix a problem where the fingerprinter was not shutting down.
Browse files Browse the repository at this point in the history
  • Loading branch information
eartle committed Sep 3, 2013
1 parent 784b8df commit c5589a9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions app/fingerprinter/Fingerprinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <QNetworkReply>
#include <QEventLoop>
#include <QDebug>
#include <QTimer>

#include <lastfm/Fingerprint.h>
#include <lastfm/FingerprintableSource.h>
Expand All @@ -50,7 +51,7 @@ Fingerprinter::Fingerprinter( const lastfm::Track& track, QObject* parent )
catch ( const lastfm::Fingerprint::Error& error )
{
qWarning() << "Fingerprint error: " << error;
qApp->quit();
QTimer::singleShot(250, qApp, SLOT(quit()));
}
}
}
Expand All @@ -63,7 +64,7 @@ Fingerprinter::Fingerprinter( const lastfm::Track& track, QObject* parent )
// day we might do something with this info, like offer corrections
connect( m_fp.id().getSuggestions(), SIGNAL(finished()), SLOT(onGotSuggestions()) );
#else
qApp->quit();
QTimer::singleShot(250, qApp, SLOT(quit()));
#endif
}
}
Expand All @@ -76,15 +77,24 @@ Fingerprinter::~Fingerprinter()
void
Fingerprinter::onFingerprintSubmitted()
{
m_fp.decode( static_cast<QNetworkReply*>( sender() ) );
qDebug() << "Fingerprint success: " << m_fp.id();
try
{
m_fp.decode( static_cast<QNetworkReply*>( sender() ) );
qDebug() << "Fingerprint success: " << m_fp.id();
}
catch ( const lastfm::Fingerprint::Error& error )
{
qWarning() << "Fingerprint error: " << error;
QTimer::singleShot(250, qApp, SLOT(quit()));
return;
}

#ifndef NDEBUG
// This code will fetch the suggestions from the fingerprint id, one
// day we might do something with this info, like offer corrections
connect( m_fp.id().getSuggestions(), SIGNAL(finished()), SLOT(onGotSuggestions()) );
#else
qApp->quit();
QTimer::singleShot(250, qApp, SLOT(quit()));
#endif

}
Expand All @@ -94,5 +104,5 @@ Fingerprinter::onGotSuggestions()
{
QMap<float, Track> suggestions = lastfm::FingerprintId::getSuggestions( static_cast<QNetworkReply*>( sender() ) );
qDebug() << suggestions;
qApp->quit();
QTimer::singleShot(250, qApp, SLOT(quit()));
}

1 comment on commit c5589a9

@darkmorpher
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #49 fixed?

Please sign in to comment.