summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorMarkus Wick <degasus@users.noreply.github.com>2016-09-30 13:23:43 +0200
committerGitHub <noreply@github.com>2016-09-30 13:23:43 +0200
commit025dce86d5db756dd6a30a02ca372a2a064413cb (patch)
treea58bfbd5851c1597ee8bf2c3985a2d8173be3676 /Source
parentebaaebf967bf1d7acb81f3ca409b9faf3ca680f3 (diff)
parentd8e4d5f0358e4098547f0ddea18f13f055b2e810 (diff)
Merge pull request #4261 from lioncash/gamelist
GameListCtrl: Use unique_ptr for underlying GameListItems
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/DolphinWX/GameListCtrl.cpp41
-rw-r--r--Source/Core/DolphinWX/GameListCtrl.h13
2 files changed, 21 insertions, 33 deletions
diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp
index cbbd4ad6b7..39ed2d4e9d 100644
--- a/Source/Core/DolphinWX/GameListCtrl.cpp
+++ b/Source/Core/DolphinWX/GameListCtrl.cpp
@@ -177,7 +177,6 @@ CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoin
CGameListCtrl::~CGameListCtrl()
{
- ClearIsoFiles();
}
template <typename T>
@@ -648,7 +647,7 @@ void CGameListCtrl::ScanForISOs()
}
if (list)
- m_ISOFiles.push_back(iso_file.release());
+ m_ISOFiles.push_back(std::move(iso_file));
}
}
}
@@ -662,7 +661,7 @@ void CGameListCtrl::ScanForISOs()
auto gli = std::make_unique<GameListItem>(drive, custom_title_map);
if (gli->IsValid())
- m_ISOFiles.push_back(gli.release());
+ m_ISOFiles.push_back(std::move(gli));
}
}
@@ -715,9 +714,9 @@ void CGameListCtrl::OnColBeginDrag(wxListEvent& event)
const GameListItem* CGameListCtrl::GetISO(size_t index) const
{
if (index < m_ISOFiles.size())
- return m_ISOFiles[index];
- else
- return nullptr;
+ return m_ISOFiles[index].get();
+
+ return nullptr;
}
static CGameListCtrl* caller;
@@ -850,10 +849,10 @@ void CGameListCtrl::OnMouseMotion(wxMouseEvent& event)
// Emulation status
static const char* const emuState[] = {"Broken", "Intro", "In-Game", "Playable", "Perfect"};
- const GameListItem& rISO = *m_ISOFiles[GetItemData(item)];
+ const GameListItem* iso = m_ISOFiles[GetItemData(item)].get();
- const int emu_state = rISO.GetEmuState();
- const std::string& issues = rISO.GetIssues();
+ const int emu_state = iso->GetEmuState();
+ const std::string& issues = iso->GetIssues();
// Show a tooltip containing the EmuState and the state description
if (emu_state > 0 && emu_state < 6)
@@ -984,21 +983,17 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event)
const GameListItem* CGameListCtrl::GetSelectedISO() const
{
- if (m_ISOFiles.size() == 0)
- {
+ if (m_ISOFiles.empty())
return nullptr;
- }
- else if (GetSelectedItemCount() == 0)
- {
+
+ if (GetSelectedItemCount() == 0)
return nullptr;
- }
- else
- {
- long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
- if (item == wxNOT_FOUND)
- return nullptr;
- return m_ISOFiles[GetItemData(item)];
- }
+
+ long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ if (item == wxNOT_FOUND)
+ return nullptr;
+
+ return m_ISOFiles[GetItemData(item)].get();
}
std::vector<const GameListItem*> CGameListCtrl::GetAllSelectedISOs() const
@@ -1010,7 +1005,7 @@ std::vector<const GameListItem*> CGameListCtrl::GetAllSelectedISOs() const
item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (item == wxNOT_FOUND)
return result;
- result.push_back(m_ISOFiles[GetItemData(item)]);
+ result.push_back(m_ISOFiles[GetItemData(item)].get());
}
}
diff --git a/Source/Core/DolphinWX/GameListCtrl.h b/Source/Core/DolphinWX/GameListCtrl.h
index 4c23aa5941..09f91eca99 100644
--- a/Source/Core/DolphinWX/GameListCtrl.h
+++ b/Source/Core/DolphinWX/GameListCtrl.h
@@ -5,6 +5,7 @@
#pragma once
#include <cstddef>
+#include <memory>
#include <string>
#include <vector>
@@ -65,17 +66,9 @@ private:
std::vector<int> m_FlagImageIndex;
std::vector<int> m_PlatformImageIndex;
std::vector<int> m_EmuStateImageIndex;
- std::vector<GameListItem*> m_ISOFiles;
-
- void ClearIsoFiles()
- {
- while (!m_ISOFiles.empty()) // so lazy
- {
- delete m_ISOFiles.back();
- m_ISOFiles.pop_back();
- }
- }
+ std::vector<std::unique_ptr<GameListItem>> m_ISOFiles;
+ void ClearIsoFiles() { m_ISOFiles.clear(); }
int last_column;
int last_sort;
wxSize lastpos;