diff --git a/rpcs3/Emu/CPU/CPUThreadManager.cpp b/rpcs3/Emu/CPU/CPUThreadManager.cpp index 5e3c50d4d1..b89c92725d 100644 --- a/rpcs3/Emu/CPU/CPUThreadManager.cpp +++ b/rpcs3/Emu/CPU/CPUThreadManager.cpp @@ -46,6 +46,7 @@ CPUThread& CPUThreadManager::AddThread(CPUThreadType type) return *new_thread; } +//TODO: find out where the thread is actually deleted because it's sure as shit not here void CPUThreadManager::RemoveThread(const u32 id) { std::lock_guard lock(m_mtx_thread); diff --git a/rpcs3/Emu/FS/VFS.h b/rpcs3/Emu/FS/VFS.h index b155f16b9d..1a28c09d11 100644 --- a/rpcs3/Emu/FS/VFS.h +++ b/rpcs3/Emu/FS/VFS.h @@ -41,6 +41,8 @@ struct VFSManagerEntry struct VFS { + //TODO: find out where these are supposed to be deleted or just make it shared_ptr + //and also make GetDevice and GetDeviceLocal return shared_ptr then. std::vector m_devices; void Mount(const std::string& ps3_path, const std::string& local_path, vfsDevice* device); void UnMount(const std::string& ps3_path); diff --git a/rpcs3/Emu/GS/GL/GLGSRender.cpp b/rpcs3/Emu/GS/GL/GLGSRender.cpp index 13078ced0c..4bc955627d 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.cpp +++ b/rpcs3/Emu/GS/GL/GLGSRender.cpp @@ -1201,7 +1201,7 @@ void GLGSRender::Flip() for(uint i=0; iDraw(); + m_post_draw_objs[i].Draw(); } m_frame->Flip(m_context); diff --git a/rpcs3/Emu/GS/GL/GLGSRender.h b/rpcs3/Emu/GS/GL/GLGSRender.h index 2fb189c4b0..2a236448c0 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.h +++ b/rpcs3/Emu/GS/GL/GLGSRender.h @@ -541,7 +541,7 @@ class GLGSRender { private: std::vector m_vdata; - std::vector m_post_draw_objs; + std::vector m_post_draw_objs; GLProgram m_program; int m_fp_buf_num; diff --git a/rpcs3/Emu/GS/GL/GLVertexProgram.cpp b/rpcs3/Emu/GS/GL/GLVertexProgram.cpp index fde8448f8d..de73bda412 100644 --- a/rpcs3/Emu/GS/GL/GLVertexProgram.cpp +++ b/rpcs3/Emu/GS/GL/GLVertexProgram.cpp @@ -250,14 +250,14 @@ std::string GLVertexDecompilerThread::GetFunc() for(uint i=0; iname.compare(name) == 0) + if(m_funcs[i].name.compare(name) == 0) return name + "()"; } - m_funcs.push_back(new FuncInfo()); - uint idx = m_funcs.size()-1; - m_funcs[idx]->offset = offset; - m_funcs[idx]->name = name; + m_funcs.emplace_back(); + FuncInfo &idx = m_funcs.back(); + idx.offset = offset; + idx.name = name; return name + "()"; } @@ -283,7 +283,7 @@ std::string GLVertexDecompilerThread::BuildFuncBody(const FuncInfo& func) uint call_func = -1; for(uint j=0; joffset == i) + if(m_funcs[j].offset == i) { call_func = j; break; @@ -292,7 +292,7 @@ std::string GLVertexDecompilerThread::BuildFuncBody(const FuncInfo& func) if(call_func != -1) { - result += '\t' + m_funcs[call_func]->name + "();\n"; + result += '\t' + m_funcs[call_func].name + "();\n"; break; } } @@ -316,17 +316,17 @@ std::string GLVertexDecompilerThread::BuildCode() for(int i=m_funcs.size() - 1; i>0; --i) { - fp += fmt::Format("void %s();\n", m_funcs[i]->name.c_str()); + fp += fmt::Format("void %s();\n", m_funcs[i].name.c_str()); } std::string f; f += fmt::Format("void %s()\n{\n\tgl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n\t%s();\n\tgl_Position = gl_Position * scaleOffsetMat;\n}\n", - m_funcs[0]->name.c_str(), m_funcs[1]->name.c_str()); + m_funcs[0].name.c_str(), m_funcs[1].name.c_str()); for(uint i=1; iname.c_str(), BuildFuncBody(*m_funcs[i]).c_str()); + f += fmt::Format("\nvoid %s()\n{\n%s}\n", m_funcs[i].name.c_str(), BuildFuncBody(m_funcs[i]).c_str()); } static const std::string& prot = @@ -437,9 +437,9 @@ void GLVertexDecompilerThread::Task() m_shader = BuildCode(); m_body.clear(); - if (m_funcs.size() >= 3) + if (m_funcs.size() > 2) { - m_funcs = std::vector(m_funcs.begin(), m_funcs.begin() + 3); + m_funcs.erase(m_funcs.begin()+2, m_funcs.end()); } } diff --git a/rpcs3/Emu/GS/GL/GLVertexProgram.h b/rpcs3/Emu/GS/GL/GLVertexProgram.h index 38a333461e..117e7f4082 100644 --- a/rpcs3/Emu/GS/GL/GLVertexProgram.h +++ b/rpcs3/Emu/GS/GL/GLVertexProgram.h @@ -135,7 +135,7 @@ struct GLVertexDecompilerThread : public ThreadBase std::vector m_body; - std::vector m_funcs; + std::vector m_funcs; //wxString main; std::string& m_shader; @@ -148,12 +148,12 @@ struct GLVertexDecompilerThread : public ThreadBase , m_shader(shader) , m_parr(parr) { - m_funcs.push_back(new FuncInfo()); - m_funcs[0]->offset = 0; - m_funcs[0]->name = "main"; - m_funcs.push_back(new FuncInfo()); - m_funcs[1]->offset = 0; - m_funcs[1]->name = "func0"; + m_funcs.emplace_back(); + m_funcs[0].offset = 0; + m_funcs[0].name = "main"; + m_funcs.emplace_back(); + m_funcs[1].offset = 0; + m_funcs[1].name = "func0"; //m_cur_func->body = "\tgl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n"; } diff --git a/rpcs3/Emu/SysCalls/Modules.h b/rpcs3/Emu/SysCalls/Modules.h index c09c6d63f8..01eaad4e35 100644 --- a/rpcs3/Emu/SysCalls/Modules.h +++ b/rpcs3/Emu/SysCalls/Modules.h @@ -123,6 +123,7 @@ __forceinline void Module::AddFuncSub(const char group[8], const u64 ops[], char { if (!ops[0]) return; + //TODO: track down where this is supposed to be deleted SFunc* sf = new SFunc; sf->ptr = (void *)func; sf->func = bind_func(func); diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 40507556c1..1ed7dc1148 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -17,7 +17,7 @@ static const u16 bpdb_version = 0x1000; ModuleInitializer::ModuleInitializer() { - Emu.AddModuleInit(this); + Emu.AddModuleInit(std::move(std::unique_ptr(this))); } Emulator::Emulator() diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index b6b5445e17..63755b65f3 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -76,7 +76,7 @@ class Emulator u32 m_ppu_thr_exit; MemoryViewerPanel* m_memory_viewer; //ArrayF m_cpu_threads; - std::vector m_modules_init; + std::vector> m_modules_init; std::vector m_break_points; std::vector m_marked_points; @@ -123,9 +123,9 @@ public: CPUThread& GetCallbackThread() { return *m_ppu_callback_thr; } EventManager& GetEventManager() { return *m_event_manager; } - void AddModuleInit(ModuleInitializer* m) + void AddModuleInit(std::unique_ptr m) { - m_modules_init.push_back(m); + m_modules_init.push_back(std::move(m)); } void SetTLSData(const u64 addr, const u64 filesz, const u64 memsz) diff --git a/rpcs3/Gui/GameViewer.h b/rpcs3/Gui/GameViewer.h index 1076ec3be5..d31fc241fc 100644 --- a/rpcs3/Gui/GameViewer.h +++ b/rpcs3/Gui/GameViewer.h @@ -28,31 +28,31 @@ struct Column struct ColumnsArr { - std::vector m_columns; + std::vector m_columns; ColumnsArr() { Init(); } - std::vector* GetSortedColumnsByPos() + std::vector GetSortedColumnsByPos() { - static std::vector arr; arr.clear(); + std::vector arr; for(u32 pos=0; pospos != pos) continue; - arr.push_back(m_columns[c]); + if(m_columns[c].pos != pos) continue; + arr.push_back(&m_columns[c]); } } - return &arr; + return arr; } Column* GetColumnByPos(u32 pos) { - std::vector& columns = *GetSortedColumnsByPos(); + std::vector columns = GetSortedColumnsByPos(); for(u32 c=0; cshown) @@ -78,15 +78,18 @@ public: void Init() { m_columns.clear(); - - #define ADD_COLUMN(x, w, n) x = new Column(m_columns.size(), w, n); m_columns.push_back(x); - ADD_COLUMN(m_col_name, 160, "Name"); - ADD_COLUMN(m_col_serial, 85, "Serial"); - ADD_COLUMN(m_col_fw, 55, "FW"); - ADD_COLUMN(m_col_app_ver, 55, "App version"); - ADD_COLUMN(m_col_category, 55, "Category"); - ADD_COLUMN(m_col_path, 160, "Path"); - #undef ADD_COLUMN + m_columns.emplace_back(m_columns.size(), 160, "Name"); + m_columns.emplace_back(m_columns.size(), 85, "Serial"); + m_columns.emplace_back(m_columns.size(), 55, "FW"); + m_columns.emplace_back(m_columns.size(), 55, "App version"); + m_columns.emplace_back(m_columns.size(), 55, "Category"); + m_columns.emplace_back(m_columns.size(), 160, "Path"); + m_col_name = &m_columns[0]; + m_col_serial = &m_columns[1]; + m_col_fw = &m_columns[2]; + m_col_app_ver = &m_columns[3]; + m_col_category = &m_columns[4]; + m_col_path = &m_columns[5]; } void Update(std::vector& game_data) @@ -114,7 +117,7 @@ public: void Show(wxListView* list) { list->DeleteAllColumns(); - std::vector& c_col = *GetSortedColumnsByPos(); + std::vector c_col = GetSortedColumnsByPos(); for(u32 i=0, c=0; ishown) continue; @@ -158,19 +161,19 @@ public: #define ADD_COLUMN(v, dv, t, n, isshown) \ { \ IniEntry ini; \ - ini.Init(m_columns[i]->name + "_" + n, path); \ - if(isLoad) m_columns[i]->v = ini.LoadValue(dv); \ - else if(isshown ? m_columns[i]->shown : 1) \ + ini.Init(m_columns[i].name + "_" + n, path); \ + if(isLoad) m_columns[i].v = ini.LoadValue(dv); \ + else if(isshown ? m_columns[i].shown : 1) \ { \ - ini.SetValue(m_columns[i]->v); \ + ini.SetValue(m_columns[i].v); \ ini.Save(); \ } \ } for(u32 i=0; idef_pos, int, "position", 1); - ADD_COLUMN(width, m_columns[i]->def_width, int, "width", 1); + ADD_COLUMN(pos, m_columns[i].def_pos, int, "position", 1); + ADD_COLUMN(width, m_columns[i].def_width, int, "width", 1); ADD_COLUMN(shown, true, bool, "shown", 0); } @@ -181,7 +184,7 @@ public: { for(u32 c2=c1+1; c2pos == m_columns[c2]->pos) + if(m_columns[c1].pos == m_columns[c2].pos) { ConLog.Error("Columns loaded with error!"); Init(); @@ -195,7 +198,7 @@ public: bool ishas = false; for(u32 c=0; cpos != p) continue; + if(m_columns[c].pos != p) continue; ishas = true; break; }