mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 19:30:21 +02:00
Avoid crash when propagating dbcmd_ShareTrack.
This commit is contained in:
@@ -73,11 +73,16 @@ DatabaseCommand_ShareTrack::postCommitHook()
|
||||
QString myDbid = SourceList::instance()->getLocal()->nodeId();
|
||||
QString sourceDbid = source()->nodeId();
|
||||
|
||||
if ( source()->isLocal() || sourceDbid != m_recipient ) //if I just sent a track
|
||||
qRegisterMetaType< InboxJobItem::Side >("InboxJobItem::Side");
|
||||
qRegisterMetaType< Tomahawk::trackdata_ptr >("Tomahawk::trackdata_ptr");
|
||||
if ( source()->isLocal() && sourceDbid != m_recipient ) //if I just sent a track
|
||||
{
|
||||
JobStatusView::instance()->model()->addJob( new InboxJobItem( InboxJobItem::Sending,
|
||||
SourceList::instance()->get( m_recipient )->friendlyName(),
|
||||
m_track ) );
|
||||
QMetaObject::invokeMethod( ViewManager::instance()->inboxModel(),
|
||||
"showNotification",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG( InboxJobItem::Side, InboxJobItem::Sending ),
|
||||
Q_ARG( const QString&, m_recipient ),
|
||||
Q_ARG( const Tomahawk::trackdata_ptr&, m_track ) );
|
||||
}
|
||||
|
||||
if ( m_track )
|
||||
@@ -107,11 +112,15 @@ DatabaseCommand_ShareTrack::postCommitHook()
|
||||
Q_ARG( const Tomahawk::query_ptr&, m_track->toQuery() ),
|
||||
Q_ARG( int, 0 ) /*row*/ );
|
||||
|
||||
QString friendlyName = source()->friendlyName();
|
||||
if ( ViewManager::instance()->currentPage() != ViewManager::instance()->inboxWidget() )
|
||||
JobStatusView::instance()->model()->addJob( new InboxJobItem( InboxJobItem::Receiving,
|
||||
friendlyName,
|
||||
m_track ) );
|
||||
{
|
||||
QMetaObject::invokeMethod( ViewManager::instance()->inboxModel(),
|
||||
"showNotification",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG( InboxJobItem::Side, InboxJobItem::Receiving ),
|
||||
Q_ARG( const Tomahawk::source_ptr&, source() ),
|
||||
Q_ARG( const Tomahawk::trackdata_ptr&, m_track ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "SourceList.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Closure.h"
|
||||
#include "jobview/JobStatusModel.h"
|
||||
|
||||
|
||||
InboxModel::InboxModel( QObject* parent )
|
||||
@@ -129,6 +130,28 @@ InboxModel::clear()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InboxModel::showNotification( InboxJobItem::Side side,
|
||||
const Tomahawk::source_ptr& src,
|
||||
const Tomahawk::trackdata_ptr& track )
|
||||
{
|
||||
JobStatusView::instance()->model()->addJob( new InboxJobItem( side,
|
||||
src->friendlyName(),
|
||||
track ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InboxModel::showNotification( InboxJobItem::Side side,
|
||||
const QString& dbid,
|
||||
const Tomahawk::trackdata_ptr& track )
|
||||
{
|
||||
Tomahawk::source_ptr src = SourceList::instance()->get( dbid );
|
||||
if ( !src.isNull() )
|
||||
showNotification( side, src, track );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InboxModel::loadTracks()
|
||||
{
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include "PlaylistModel.h"
|
||||
#include "Typedefs.h"
|
||||
#include "DllMacro.h"
|
||||
#include "jobview/InboxJobItem.h"
|
||||
|
||||
|
||||
class DLLEXPORT InboxModel : public PlaylistModel
|
||||
@@ -45,6 +46,14 @@ public slots:
|
||||
|
||||
virtual void clear();
|
||||
|
||||
virtual void showNotification( InboxJobItem::Side side,
|
||||
const Tomahawk::source_ptr& src,
|
||||
const Tomahawk::trackdata_ptr& track ); //for lack of a better place to put this
|
||||
virtual void showNotification( InboxJobItem::Side side,
|
||||
const QString& dbid,
|
||||
const Tomahawk::trackdata_ptr& track );
|
||||
|
||||
|
||||
private slots:
|
||||
void loadTracks();
|
||||
|
||||
|
Reference in New Issue
Block a user