From 16601218e01283d3817720d40ca8e4e3f2997106 Mon Sep 17 00:00:00 2001 From: DaveTBlake Date: Wed, 19 Sep 2018 16:51:11 +0100 Subject: [JSON]Fix Player.GetItem to avoid seg fault when request and track change coincide --- xbmc/interfaces/json-rpc/PlayerOperations.cpp | 18 ++++++++++++++---- xbmc/interfaces/json-rpc/schema/version.txt | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/xbmc/interfaces/json-rpc/PlayerOperations.cpp b/xbmc/interfaces/json-rpc/PlayerOperations.cpp index 619d7a107c..816d4fd120 100644 --- a/xbmc/interfaces/json-rpc/PlayerOperations.cpp +++ b/xbmc/interfaces/json-rpc/PlayerOperations.cpp @@ -153,32 +153,42 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const std::string &method, ITransportL } else if (player == Video) { - if (!CVideoLibrary::FillFileItem(g_application.CurrentFile(), fileItem, parameterObject)) + if (!CVideoLibrary::FillFileItem(fileItem->GetPath(), fileItem, parameterObject)) { + // Fallback to item details held by GUI but ensure path unchanged + //! @todo remove this once there is no route to playback that updates + // GUI item without also updating app item e.g. start playback of a + // non-library item via JSON const CVideoInfoTag *currentVideoTag = CServiceBroker::GetGUI()->GetInfoManager().GetCurrentMovieTag(); if (currentVideoTag != NULL) { std::string originalLabel = fileItem->GetLabel(); + std::string originalPath = fileItem->GetPath(); fileItem->SetFromVideoInfoTag(*currentVideoTag); if (fileItem->GetLabel().empty()) fileItem->SetLabel(originalLabel); + fileItem->SetPath(originalPath); // Ensure path unchanged } - fileItem->SetPath(g_application.CurrentFileItem().GetPath()); } } else { - if (!CAudioLibrary::FillFileItem(g_application.CurrentFile(), fileItem, parameterObject)) + if (!CAudioLibrary::FillFileItem(fileItem->GetPath(), fileItem, parameterObject)) { + // Fallback to item details held by GUI but ensure path unchanged + //! @todo remove this once there is no route to playback that updates + // GUI item without also updating app item e.g. start playback of a + // non-library item via JSON const MUSIC_INFO::CMusicInfoTag *currentMusicTag = CServiceBroker::GetGUI()->GetInfoManager().GetCurrentSongTag(); if (currentMusicTag != NULL) { std::string originalLabel = fileItem->GetLabel(); + std::string originalPath = fileItem->GetPath(); fileItem->SetFromMusicInfoTag(*currentMusicTag); if (fileItem->GetLabel().empty()) fileItem->SetLabel(originalLabel); + fileItem->SetPath(originalPath); // Ensure path unchanged } - fileItem->SetPath(g_application.CurrentFileItem().GetPath()); } } diff --git a/xbmc/interfaces/json-rpc/schema/version.txt b/xbmc/interfaces/json-rpc/schema/version.txt index 94db005adc..e32fb7aaff 100644 --- a/xbmc/interfaces/json-rpc/schema/version.txt +++ b/xbmc/interfaces/json-rpc/schema/version.txt @@ -1 +1 @@ -JSONRPC_VERSION 9.6.0 +JSONRPC_VERSION 9.6.1 -- cgit v1.2.3