mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +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 myDbid = SourceList::instance()->getLocal()->nodeId();
|
||||||
QString sourceDbid = source()->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,
|
QMetaObject::invokeMethod( ViewManager::instance()->inboxModel(),
|
||||||
SourceList::instance()->get( m_recipient )->friendlyName(),
|
"showNotification",
|
||||||
m_track ) );
|
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 )
|
if ( m_track )
|
||||||
@@ -107,11 +112,15 @@ DatabaseCommand_ShareTrack::postCommitHook()
|
|||||||
Q_ARG( const Tomahawk::query_ptr&, m_track->toQuery() ),
|
Q_ARG( const Tomahawk::query_ptr&, m_track->toQuery() ),
|
||||||
Q_ARG( int, 0 ) /*row*/ );
|
Q_ARG( int, 0 ) /*row*/ );
|
||||||
|
|
||||||
QString friendlyName = source()->friendlyName();
|
|
||||||
if ( ViewManager::instance()->currentPage() != ViewManager::instance()->inboxWidget() )
|
if ( ViewManager::instance()->currentPage() != ViewManager::instance()->inboxWidget() )
|
||||||
JobStatusView::instance()->model()->addJob( new InboxJobItem( InboxJobItem::Receiving,
|
{
|
||||||
friendlyName,
|
QMetaObject::invokeMethod( ViewManager::instance()->inboxModel(),
|
||||||
m_track ) );
|
"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 "SourceList.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Closure.h"
|
#include "utils/Closure.h"
|
||||||
|
#include "jobview/JobStatusModel.h"
|
||||||
|
|
||||||
|
|
||||||
InboxModel::InboxModel( QObject* parent )
|
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
|
void
|
||||||
InboxModel::loadTracks()
|
InboxModel::loadTracks()
|
||||||
{
|
{
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include "PlaylistModel.h"
|
#include "PlaylistModel.h"
|
||||||
#include "Typedefs.h"
|
#include "Typedefs.h"
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
#include "jobview/InboxJobItem.h"
|
||||||
|
|
||||||
|
|
||||||
class DLLEXPORT InboxModel : public PlaylistModel
|
class DLLEXPORT InboxModel : public PlaylistModel
|
||||||
@@ -45,6 +46,14 @@ public slots:
|
|||||||
|
|
||||||
virtual void clear();
|
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:
|
private slots:
|
||||||
void loadTracks();
|
void loadTracks();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user