mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-25 15:31:17 +01:00
Fixed a few memory leaks. Made Init and Shutdown functions for some core systems.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5064 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
666a33eeed
commit
9254a2ddb5
@ -139,6 +139,7 @@ char ** cdio_get_devices_win32() {
|
|||||||
const char *drive_str=is_cdrom_win32(drive_letter);
|
const char *drive_str=is_cdrom_win32(drive_letter);
|
||||||
if (drive_str != NULL) {
|
if (drive_str != NULL) {
|
||||||
cdio_add_device_list(&drives, drive_str, &num_drives);
|
cdio_add_device_list(&drives, drive_str, &num_drives);
|
||||||
|
delete drive_str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cdio_add_device_list(&drives, NULL, &num_drives);
|
cdio_add_device_list(&drives, NULL, &num_drives);
|
||||||
|
@ -26,7 +26,8 @@ void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
|
|||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
LogManager::GetInstance()->Log(level, type, file, line, fmt, args);
|
if (LogManager::GetInstance())
|
||||||
|
LogManager::GetInstance()->Log(level, type, file, line, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,11 +92,14 @@ LogManager::LogManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogManager::~LogManager() {
|
LogManager::~LogManager() {
|
||||||
delete [] &m_Log; // iffy :P
|
|
||||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) {
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) {
|
||||||
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog);
|
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog);
|
||||||
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_consoleLog);
|
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_consoleLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||||
|
delete m_Log[i];
|
||||||
|
|
||||||
delete m_fileLog;
|
delete m_fileLog;
|
||||||
delete m_consoleLog;
|
delete m_consoleLog;
|
||||||
delete logMutex;
|
delete logMutex;
|
||||||
@ -131,6 +135,17 @@ void LogManager::removeListener(LogTypes::LOG_TYPE type, LogListener *listener)
|
|||||||
logMutex->Leave();
|
logMutex->Leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogManager::Init()
|
||||||
|
{
|
||||||
|
m_logManager = new LogManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogManager::Shutdown()
|
||||||
|
{
|
||||||
|
delete m_logManager;
|
||||||
|
m_logManager = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
LogContainer::LogContainer(const char* shortName, const char* fullName, bool enable)
|
LogContainer::LogContainer(const char* shortName, const char* fullName, bool enable)
|
||||||
: m_enable(enable) {
|
: m_enable(enable) {
|
||||||
strncpy(m_fullName, fullName, 128);
|
strncpy(m_fullName, fullName, 128);
|
||||||
@ -183,7 +198,8 @@ void FileLogListener::Reload() {
|
|||||||
|
|
||||||
FileLogListener::~FileLogListener() {
|
FileLogListener::~FileLogListener() {
|
||||||
free(m_filename);
|
free(m_filename);
|
||||||
fclose(m_logfile);
|
if (m_logfile)
|
||||||
|
fclose(m_logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg) {
|
void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg) {
|
||||||
|
@ -165,14 +165,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static LogManager* GetInstance() {
|
static LogManager* GetInstance() {
|
||||||
if (! m_logManager)
|
|
||||||
m_logManager = new LogManager();
|
|
||||||
return m_logManager;
|
return m_logManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetInstance(LogManager *logManager) {
|
static void SetInstance(LogManager *logManager) {
|
||||||
m_logManager = logManager;
|
m_logManager = logManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Init();
|
||||||
|
static void Shutdown();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _LOGMANAGER_H_
|
#endif // _LOGMANAGER_H_
|
||||||
|
@ -28,12 +28,19 @@ SConfig SConfig::m_Instance;
|
|||||||
|
|
||||||
SConfig::SConfig()
|
SConfig::SConfig()
|
||||||
{
|
{
|
||||||
// Make sure we have log manager
|
|
||||||
LoadSettings();
|
|
||||||
//Make sure we load settings
|
|
||||||
LoadSettingsHLE();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SConfig::Init()
|
||||||
|
{
|
||||||
|
// Make sure we have log manager
|
||||||
|
m_Instance.LoadSettings();
|
||||||
|
//Make sure we load settings
|
||||||
|
m_Instance.LoadSettingsHLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SConfig::Shutdown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
SConfig::~SConfig()
|
SConfig::~SConfig()
|
||||||
{
|
{
|
||||||
|
@ -105,6 +105,9 @@ struct SConfig
|
|||||||
// Return the permanent and somewhat globally used instance of this struct
|
// Return the permanent and somewhat globally used instance of this struct
|
||||||
static SConfig& GetInstance() {return(m_Instance);}
|
static SConfig& GetInstance() {return(m_Instance);}
|
||||||
|
|
||||||
|
static void Init();
|
||||||
|
static void Shutdown();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
|
@ -41,11 +41,22 @@
|
|||||||
#include "Setup.h"
|
#include "Setup.h"
|
||||||
|
|
||||||
// Create the plugin manager class
|
// Create the plugin manager class
|
||||||
CPluginManager CPluginManager::m_Instance;
|
CPluginManager* CPluginManager::m_Instance;
|
||||||
|
|
||||||
// The Plugin Manager Class
|
// The Plugin Manager Class
|
||||||
// ------------
|
// ------------
|
||||||
|
|
||||||
|
void CPluginManager::Init()
|
||||||
|
{
|
||||||
|
m_Instance = new CPluginManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPluginManager::Shutdown()
|
||||||
|
{
|
||||||
|
delete m_Instance;
|
||||||
|
m_Instance = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// The plugin manager is some sort of singleton that runs during Dolphin's entire lifespan.
|
// The plugin manager is some sort of singleton that runs during Dolphin's entire lifespan.
|
||||||
CPluginManager::CPluginManager()
|
CPluginManager::CPluginManager()
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,10 @@ typedef std::vector<CPluginInfo>CPluginInfos;
|
|||||||
class CPluginManager
|
class CPluginManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CPluginManager& GetInstance() {return(m_Instance);}
|
static CPluginManager& GetInstance() {return(*m_Instance);}
|
||||||
|
static void Init();
|
||||||
|
static void Shutdown();
|
||||||
|
|
||||||
Common::PluginVideo *GetVideo();
|
Common::PluginVideo *GetVideo();
|
||||||
Common::PluginDSP *GetDSP();
|
Common::PluginDSP *GetDSP();
|
||||||
Common::PluginPAD *GetPad(int controller);
|
Common::PluginPAD *GetPad(int controller);
|
||||||
@ -68,8 +71,7 @@ public:
|
|||||||
const CPluginInfos& GetPluginInfos() {return(m_PluginInfos);}
|
const CPluginInfos& GetPluginInfos() {return(m_PluginInfos);}
|
||||||
PLUGIN_GLOBALS* GetGlobals();
|
PLUGIN_GLOBALS* GetGlobals();
|
||||||
private:
|
private:
|
||||||
static CPluginManager m_Instance;
|
static CPluginManager* m_Instance;
|
||||||
bool m_Initialized;
|
|
||||||
|
|
||||||
CPluginInfos m_PluginInfos;
|
CPluginInfos m_PluginInfos;
|
||||||
PLUGIN_GLOBALS *m_PluginGlobals;
|
PLUGIN_GLOBALS *m_PluginGlobals;
|
||||||
|
@ -518,6 +518,8 @@ CFrame::~CFrame()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ClosePages();
|
ClosePages();
|
||||||
|
|
||||||
|
delete m_Mgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event))
|
void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event))
|
||||||
|
@ -57,7 +57,6 @@ IMPLEMENT_APP(DolphinApp)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
CFrame* main_frame = NULL;
|
CFrame* main_frame = NULL;
|
||||||
LogManager *logManager = NULL;
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
//Has no error handling.
|
//Has no error handling.
|
||||||
@ -106,7 +105,6 @@ bool DolphinApp::OnInit()
|
|||||||
wxString padPluginFilename;
|
wxString padPluginFilename;
|
||||||
wxString wiimotePluginFilename;
|
wxString wiimotePluginFilename;
|
||||||
|
|
||||||
|
|
||||||
// Detect CPU info and write it to the cpu_info struct
|
// Detect CPU info and write it to the cpu_info struct
|
||||||
cpu_info.Detect();
|
cpu_info.Detect();
|
||||||
|
|
||||||
@ -116,6 +114,11 @@ bool DolphinApp::OnInit()
|
|||||||
_CrtSetDbgFlag(tmpflag);
|
_CrtSetDbgFlag(tmpflag);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
LogManager::Init();
|
||||||
|
EventHandler::Init();
|
||||||
|
SConfig::Init();
|
||||||
|
CPluginManager::Init();
|
||||||
|
|
||||||
// Register message box handler
|
// Register message box handler
|
||||||
#if ! defined(_WIN32) && defined(HAVE_WX) && HAVE_WX
|
#if ! defined(_WIN32) && defined(HAVE_WX) && HAVE_WX
|
||||||
RegisterMsgAlertHandler(&wxMsgAlert);
|
RegisterMsgAlertHandler(&wxMsgAlert);
|
||||||
@ -484,6 +487,16 @@ void DolphinApp::OnEndSession()
|
|||||||
SConfig::GetInstance().SaveSettings();
|
SConfig::GetInstance().SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DolphinApp::OnExit()
|
||||||
|
{
|
||||||
|
CPluginManager::Shutdown();
|
||||||
|
SConfig::Shutdown();
|
||||||
|
EventHandler::Shutdown();
|
||||||
|
LogManager::Shutdown();
|
||||||
|
|
||||||
|
return wxApp::OnExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------
|
// ------------
|
||||||
// Talk to GUI
|
// Talk to GUI
|
||||||
|
@ -27,6 +27,7 @@ class DolphinApp : public wxApp
|
|||||||
public:
|
public:
|
||||||
bool OnInit();
|
bool OnInit();
|
||||||
void OnEndSession();
|
void OnEndSession();
|
||||||
|
int OnExit();
|
||||||
CFrame* GetCFrame();
|
CFrame* GetCFrame();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,13 +19,15 @@ EventHandler::~EventHandler() {
|
|||||||
|
|
||||||
EventHandler *EventHandler::GetInstance() {
|
EventHandler *EventHandler::GetInstance() {
|
||||||
// fprintf(stderr, "handler instance %p\n", m_Instance);
|
// fprintf(stderr, "handler instance %p\n", m_Instance);
|
||||||
|
return m_Instance;
|
||||||
if (! m_Instance)
|
|
||||||
m_Instance = new EventHandler();
|
|
||||||
return m_Instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventHandler::Destroy() {
|
void EventHandler::Init()
|
||||||
|
{
|
||||||
|
m_Instance = new EventHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventHandler::Shutdown() {
|
||||||
if (m_Instance)
|
if (m_Instance)
|
||||||
delete m_Instance;
|
delete m_Instance;
|
||||||
// fprintf(stderr, "deleting instance %p\n", m_Instance);
|
// fprintf(stderr, "deleting instance %p\n", m_Instance);
|
||||||
|
@ -51,7 +51,8 @@ public:
|
|||||||
bool RemoveEventListener(Keys key);
|
bool RemoveEventListener(Keys key);
|
||||||
void Update();
|
void Update();
|
||||||
static EventHandler *GetInstance();
|
static EventHandler *GetInstance();
|
||||||
static void Destroy();
|
static void Init();
|
||||||
|
static void Shutdown();
|
||||||
bool addEvent(sf::Event *e);
|
bool addEvent(sf::Event *e);
|
||||||
static bool TestEvent (Keys k, sf::Event e);
|
static bool TestEvent (Keys k, sf::Event e);
|
||||||
#if defined HAVE_WX && HAVE_WX
|
#if defined HAVE_WX && HAVE_WX
|
||||||
|
Loading…
x
Reference in New Issue
Block a user