diff --git a/xbmc/windows/GUIMediaWindow.cpp b/xbmc/windows/GUIMediaWindow.cpp index b85738261e87c..0b0672a7e65dd 100644 --- a/xbmc/windows/GUIMediaWindow.cpp +++ b/xbmc/windows/GUIMediaWindow.cpp @@ -678,8 +678,7 @@ bool CGUIMediaWindow::GetDirectory(const std::string &strDirectory, CFileItemLis m_history.RemoveParentPath(); } - // update the view state to the currently fetched items - // TODO we should remove the second call m_guiState.reset() in Update() and pass the right file item ref here + // update the view state's reference to the current items m_guiState.reset(CGUIViewState::GetViewState(GetID(), items)); if (m_guiState.get() && !m_guiState->HideParentDirItems() && !items.GetPath().empty()) @@ -752,8 +751,8 @@ bool CGUIMediaWindow::Update(const std::string &strDirectory, bool updateFilterP if (canfilter && url.HasOption("filter")) directory = RemoveParameterFromPath(directory, "filter"); - CFileItemList items; - if (!GetDirectory(directory, items)) + ClearFileItems(); + if (!GetDirectory(directory, *m_vecItems)) { CLog::Log(LOGERROR,"CGUIMediaWindow::GetDirectory(%s) failed", url.GetRedacted().c_str()); // Try to return to the previous directory, if not the same @@ -766,14 +765,11 @@ bool CGUIMediaWindow::Update(const std::string &strDirectory, bool updateFilterP return false; } - if (items.GetLabel().empty()) - items.SetLabel(CUtil::GetTitleFromPath(items.GetPath(), true)); - - ClearFileItems(); - m_vecItems->Copy(items); + if (m_vecItems->GetLabel().empty()) + m_vecItems->SetLabel(CUtil::GetTitleFromPath(m_vecItems->GetPath(), true)); // check the given path for filter data - UpdateFilterPath(strDirectory, items, updateFilterPath); + UpdateFilterPath(strDirectory, *m_vecItems, updateFilterPath); // if we're getting the root source listing // make sure the path history is clean @@ -826,8 +822,6 @@ bool CGUIMediaWindow::Update(const std::string &strDirectory, bool updateFilterP m_vecItems->FillInDefaultIcons(); - m_guiState.reset(CGUIViewState::GetViewState(GetID(), *m_vecItems)); - // remember the original (untouched) list of items (for filtering etc) m_unfilteredItems->SetPath(m_vecItems->GetPath()); // use the original path - it'll likely be relied on for other things later. m_unfilteredItems->Append(*m_vecItems);