r6928 redux

removes memleak in exchange for 2 additional calls to ::IsValidCodePage

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6941 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2011-01-27 23:59:12 +00:00
parent 179fb38716
commit 72d604d3f2
6 changed files with 43 additions and 34 deletions

View File

@ -399,7 +399,18 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
// title: 0xFF0000
// company: 0x007030
int ImageIndex = -1;
static wxCSConv *SJISConv = WxUtils::SJISConv();
#ifdef _WIN32
wxCSConv SJISConv(*(wxCSConv*)wxConvCurrent);
static bool validCP932 = ::IsValidCodePage(932) != 0;
if (validCP932)
{
SJISConv = wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS));
}
WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932");
#else
wxCSConv SJISConv(wxFontMapper::GetEncodingName(wxFONTENCODING_EUC_JP));
#endif
GameListItem& rISOFile = m_ISOFiles[_Index];
m_gamePath.append(rISOFile.GetFileName() + '\n');
@ -432,12 +443,12 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
case DiscIO::IVolume::COUNTRY_TAIWAN:
case DiscIO::IVolume::COUNTRY_JAPAN:
{
wxString name = wxString(rISOFile.GetName(0).c_str(), *SJISConv);
wxString name = wxString(rISOFile.GetName(0).c_str(), SJISConv);
m_gameList.append(StringFromFormat("%s (J)\n", (const char *)name.c_str()));
SetItem(_Index, COLUMN_TITLE, name, -1);
SetItem(_Index, COLUMN_NOTES, wxString(company.size() ?
company.c_str() : rISOFile.GetDescription(0).c_str(),
*SJISConv), -1);
SJISConv), -1);
}
break;
case DiscIO::IVolume::COUNTRY_USA:
@ -467,9 +478,9 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
{
m_gameList.append(StringFromFormat("%s (WAD)\n", rISOFile.GetName(0).c_str()));
SetItem(_Index, COLUMN_TITLE,
wxString(rISOFile.GetName(0).c_str(), *SJISConv), -1);
wxString(rISOFile.GetName(0).c_str(), SJISConv), -1);
SetItem(_Index, COLUMN_NOTES,
wxString(rISOFile.GetDescription(0).c_str(), *SJISConv), -1);
wxString(rISOFile.GetDescription(0).c_str(), SJISConv), -1);
}
#ifndef _WIN32

View File

@ -27,7 +27,6 @@
#include "GeckoCodeDiag.h"
#include "ConfigManager.h"
#include "StringUtil.h"
#include "WxUtils.h"
#include "../resources/isoprop_file.xpm"
#include "../resources/isoprop_folder.xpm"
@ -1249,14 +1248,24 @@ void CISOProperties::ChangeBannerDetails(int lang)
|| OpenGameListItem->GetCountry() == DiscIO::IVolume::COUNTRY_TAIWAN
|| OpenGameListItem->GetPlatform() == GameListItem::WII_WAD)
{
static wxCSConv * SJISConv = WxUtils::SJISConv();
#ifdef _WIN32
wxCSConv SJISConv(*(wxCSConv*)wxConvCurrent);
static bool validCP932 = ::IsValidCodePage(932) != 0;
if (validCP932)
{
SJISConv = wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS));
}
WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932");
#else
wxCSConv SJISConv(wxFontMapper::GetEncodingName(wxFONTENCODING_EUC_JP));
#endif
wxString name = wxString(OpenGameListItem->GetName(0).c_str(), *SJISConv);
wxString name = wxString(OpenGameListItem->GetName(0).c_str(), SJISConv);
// Updates the informations shown in the window
m_ShortName->SetValue(name);
m_Comment->SetValue(wxString(OpenGameListItem->GetDescription(0).c_str(), *SJISConv));
m_Maker->SetValue(wxString(OpenGameListItem->GetCompany().c_str(), *SJISConv));//dev too
m_Comment->SetValue(wxString(OpenGameListItem->GetDescription(0).c_str(), SJISConv));
m_Maker->SetValue(wxString(OpenGameListItem->GetCompany().c_str(), SJISConv));//dev too
std::string filename, extension;
SplitPath(OpenGameListItem->GetFileName(), 0, &filename, &extension);

View File

@ -22,7 +22,6 @@
#include "FileUtil.h"
#include "DebuggerUIUtil.h"
#include <wx/fontmap.h>
#include "WxUtils.h"
// Milliseconds between msgQueue flushes to wxTextCtrl
#define UPDATETIME 200
@ -50,8 +49,18 @@ CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos,
, Parent(parent) , m_LogAccess(true)
, m_Log(NULL), m_cmdline(NULL), m_FontChoice(NULL)
, m_LogSection(1)
, m_SJISConv(*(wxCSConv*)wxConvCurrent)
{
m_SJISConv = WxUtils::SJISConv();
#ifdef _WIN32
static bool validCP932 = ::IsValidCodePage(932) != 0;
if (validCP932)
{
m_SJISConv = wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS));
}
WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932");
#else
m_SJISConv = wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_EUC_JP));
#endif
m_LogManager = LogManager::GetInstance();
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
@ -156,7 +165,6 @@ CLogWindow::~CLogWindow()
}
m_LogTimer->Stop();
delete m_LogTimer;
delete m_SJISConv;
}
void CLogWindow::OnClose(wxCloseEvent& event)
@ -537,6 +545,6 @@ void CLogWindow::Log(LogTypes::LOG_LEVELS level, const char *text)
m_LogSection.Enter();
if (msgQueue.size() >= 100)
msgQueue.pop();
msgQueue.push(std::pair<u8, wxString>((u8)level, wxString(text, *m_SJISConv)));
msgQueue.push(std::pair<u8, wxString>((u8)level, wxString(text, m_SJISConv)));
m_LogSection.Leave();
}

View File

@ -85,7 +85,7 @@ private:
Common::CriticalSection m_LogSection;
wxCSConv* m_SJISConv;
wxCSConv m_SJISConv;
DECLARE_EVENT_TABLE()

View File

@ -19,26 +19,9 @@
#include <wx/wx.h>
#include <wx/string.h>
#include <wx/fontmap.h>
namespace WxUtils {
wxCSConv *SJISConv()
{
#ifdef _WIN32
static bool validCP932 = ::IsValidCodePage(932) != 0;
if (validCP932)
{
return new wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS));
}
WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932");
return (wxCSConv*)wxConvCurrent;
#else
return new wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_EUC_JP));
#endif
}
// Launch a file according to its mime type
void Launch(const char *filename)
{

View File

@ -20,8 +20,6 @@
namespace WxUtils {
wxCSConv * SJISConv();
// Launch a file according to its mime type
void Launch(const char *filename);