mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
Fix nullpointer crash, set resulthint
This commit is contained in:
@@ -22,10 +22,9 @@
|
|||||||
#include "utils/TomahawkUtils.h"
|
#include "utils/TomahawkUtils.h"
|
||||||
#include "Query.h"
|
#include "Query.h"
|
||||||
#include "SourceList.h"
|
#include "SourceList.h"
|
||||||
|
|
||||||
#include "Playlist.h"
|
#include "Playlist.h"
|
||||||
#include "DropJob.h"
|
#include "DropJob.h"
|
||||||
|
#include "ViewManager.h"
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
@@ -76,8 +75,11 @@ M3uLoader::getTags( const QFileInfo& info )
|
|||||||
const char *encodedName = fileName.constData();
|
const char *encodedName = fileName.constData();
|
||||||
|
|
||||||
TagLib::FileRef f( encodedName );
|
TagLib::FileRef f( encodedName );
|
||||||
|
if( f.isNull() )
|
||||||
|
return;
|
||||||
TagLib::Tag *tag = f.tag();
|
TagLib::Tag *tag = f.tag();
|
||||||
|
if( !tag )
|
||||||
|
return;
|
||||||
QString artist = TStringToQString( tag->artist() ).trimmed();
|
QString artist = TStringToQString( tag->artist() ).trimmed();
|
||||||
QString album = TStringToQString( tag->album() ).trimmed();
|
QString album = TStringToQString( tag->album() ).trimmed();
|
||||||
QString track = TStringToQString( tag->title() ).trimmed();
|
QString track = TStringToQString( tag->title() ).trimmed();
|
||||||
@@ -92,9 +94,14 @@ M3uLoader::getTags( const QFileInfo& info )
|
|||||||
qDebug() << Q_FUNC_INFO << artist << track << album;
|
qDebug() << Q_FUNC_INFO << artist << track << album;
|
||||||
Tomahawk::query_ptr q = Tomahawk::Query::get( artist, track, album, uuid(), !m_createNewPlaylist );
|
Tomahawk::query_ptr q = Tomahawk::Query::get( artist, track, album, uuid(), !m_createNewPlaylist );
|
||||||
if ( !q.isNull() )
|
if ( !q.isNull() )
|
||||||
|
{
|
||||||
|
q->setResultHint( "file://" + info.absoluteFilePath() );
|
||||||
|
q->setSaveHTTPResultHint( true );
|
||||||
|
qDebug() << "ADding resulthint" << q->resultHint();
|
||||||
m_tracks << q;
|
m_tracks << q;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -110,6 +117,7 @@ M3uLoader::parseM3u( const QString& fileLink )
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_title = fileInfo.baseName();
|
m_title = fileInfo.baseName();
|
||||||
|
|
||||||
while ( !file.atEnd() )
|
while ( !file.atEnd() )
|
||||||
{
|
{
|
||||||
QByteArray line = file.readLine();
|
QByteArray line = file.readLine();
|
||||||
@@ -122,16 +130,21 @@ M3uLoader::parseM3u( const QString& fileLink )
|
|||||||
QFileInfo tmpFile( QUrl::fromUserInput( QString( line.simplified() ) ).toLocalFile() );
|
QFileInfo tmpFile( QUrl::fromUserInput( QString( line.simplified() ) ).toLocalFile() );
|
||||||
|
|
||||||
if( tmpFile.exists() )
|
if( tmpFile.exists() )
|
||||||
|
{
|
||||||
getTags( tmpFile );
|
getTags( tmpFile );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QUrl fileUrl = QUrl::fromUserInput( QString( QFileInfo(file).canonicalPath() + "/" + line.simplified() ) );
|
QUrl fileUrl = QUrl::fromUserInput( QString( QFileInfo(file).canonicalPath() + "/" + line.simplified() ) );
|
||||||
QFileInfo tmpFile( fileUrl.toLocalFile() );
|
QFileInfo tmpFile( fileUrl.toLocalFile() );
|
||||||
if ( tmpFile.exists() )
|
if ( tmpFile.exists() )
|
||||||
|
{
|
||||||
getTags( tmpFile );
|
getTags( tmpFile );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if ( m_tracks.isEmpty() )
|
if ( m_tracks.isEmpty() )
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO << "Could not parse M3U!";
|
tDebug() << Q_FUNC_INFO << "Could not parse M3U!";
|
||||||
@@ -155,3 +168,11 @@ M3uLoader::parseM3u( const QString& fileLink )
|
|||||||
|
|
||||||
m_tracks.clear();
|
m_tracks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
M3uLoader::playlistCreated()
|
||||||
|
{
|
||||||
|
ViewManager::instance()->show( m_playlist );
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -46,6 +46,8 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void parse();
|
void parse();
|
||||||
|
private slots:
|
||||||
|
void playlistCreated();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void track( const Tomahawk::query_ptr& track );
|
void track( const Tomahawk::query_ptr& track );
|
||||||
|
Reference in New Issue
Block a user