Skip to content
Permalink
Browse files

Core: Use a shared_ptr for i18n categories.

This does not make them thread safe, but it reduces the chances of a crash
a bit (see #12594.)
  • Loading branch information
unknownbrackets committed Jan 26, 2020
1 parent a4ba5d4 commit 5009698cc09e01ff2c84d9ed632bcfa162cdcb37
Showing with 244 additions and 240 deletions.
  1. +1 −1 Core/CwCheat.cpp
  2. +1 −1 Core/Dialog/PSPDialog.cpp
  3. +2 −2 Core/Dialog/PSPMsgDialog.cpp
  4. +3 −3 Core/Dialog/PSPNetconfDialog.cpp
  5. +1 −1 Core/Dialog/PSPOskDialog.cpp
  6. +4 −4 Core/Dialog/PSPSaveDialog.cpp
  7. +4 −4 Core/Dialog/SavedataParam.cpp
  8. +1 −1 Core/FileSystems/BlockDevices.cpp
  9. +3 −3 Core/FileSystems/DirectoryFileSystem.cpp
  10. +1 −1 Core/HLE/proAdhoc.cpp
  11. +1 −1 Core/HLE/sceDisplay.cpp
  12. +5 −5 Core/SaveState.cpp
  13. +1 −1 Core/TextureReplacer.cpp
  14. +3 −3 Core/Util/GameManager.cpp
  15. +1 −1 GPU/Common/FramebufferCommon.cpp
  16. +1 −1 GPU/Directx9/GPU_DX9.cpp
  17. +1 −1 GPU/Directx9/ShaderManagerDX9.cpp
  18. +1 −1 GPU/GLES/GPU_GLES.cpp
  19. +1 −1 GPU/GLES/ShaderManagerGLES.cpp
  20. +1 −1 GPU/GLES/TextureCacheGLES.cpp
  21. +1 −1 GPU/Vulkan/TextureCacheVulkan.cpp
  22. +1 −1 Qt/QtMain.cpp
  23. +3 −3 UI/ComboKeyMappingScreen.cpp
  24. +13 −13 UI/ControlMappingScreen.cpp
  25. +4 −3 UI/ControlMappingScreen.h
  26. +2 −2 UI/CwCheatScreen.cpp
  27. +19 −19 UI/DevScreens.cpp
  28. +2 −1 UI/DevScreens.h
  29. +2 −2 UI/DiscordIntegration.cpp
  30. +3 −3 UI/DisplayLayoutScreen.cpp
  31. +13 −13 UI/EmuScreen.cpp
  32. +2 −2 UI/GPUDriverTestScreen.cpp
  33. +12 −12 UI/GameScreen.cpp
  34. +34 −34 UI/GameSettingsScreen.cpp
  35. +3 −3 UI/InstallZipScreen.cpp
  36. +5 −5 UI/MainScreen.cpp
  37. +10 −10 UI/MiscScreens.cpp
  38. +4 −4 UI/NativeApp.cpp
  39. +10 −9 UI/PauseScreen.cpp
  40. +8 −8 UI/RemoteISOScreen.cpp
  41. +11 −11 UI/ReportScreen.cpp
  42. +6 −6 UI/SavedataScreen.cpp
  43. +4 −4 UI/Store.cpp
  44. +2 −2 UI/TiltAnalogSettingsScreen.cpp
  45. +3 −3 UI/TouchControlLayoutScreen.cpp
  46. +3 −3 UI/TouchControlVisibilityScreen.cpp
  47. +2 −2 Windows/EmuThread.cpp
  48. +1 −1 Windows/GPU/D3D11Context.cpp
  49. +1 −1 Windows/GPU/WindowsGLContext.cpp
  50. +7 −7 Windows/MainWindowMenu.cpp
  51. +1 −1 Windows/main.cpp
  52. +6 −6 ext/native/i18n/i18n.cpp
  53. +5 −4 ext/native/i18n/i18n.h
  54. +4 −4 ext/native/ui/ui_screen.cpp
@@ -340,7 +340,7 @@ void CWCheatEngine::CreateCheatFile() {
fclose(f);
}
if (!File::Exists(activeCheatFile)) {
I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Unable to create cheat file, disk may be full"));
}
}
@@ -202,7 +202,7 @@ void PSPDialog::DisplayButtons(int flags, const char *caption)
truncate_cpy(safeCaption, caption);
}

I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");
float x1 = 183.5f, x2 = 261.5f;
if (GetCommonParam()->buttonSwap == 1) {
x1 = 261.5f;
@@ -156,7 +156,7 @@ void PSPMsgDialog::DisplayMessage(std::string text, bool hasYesNo, bool hasOK)

if (hasYesNo)
{
I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");
const char *choiceText;
u32 yesColor, noColor;
float x, w;
@@ -193,7 +193,7 @@ void PSPMsgDialog::DisplayMessage(std::string text, bool hasYesNo, bool hasOK)
}

if (hasOK) {
I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");
float x, w;
x = 240.0f;
w = 15.0f;
@@ -62,14 +62,14 @@ void PSPNetconfDialog::DrawBanner() {

// TODO: Draw a hexagon icon
PPGeDrawImage(10, 6, 12.0f, 12.0f, 1, 10, 1, 10, 10, 10, CalcFadedColor(0xFFFFFFFF));
I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");
PPGeDrawText(di->T("Network Connection"), 30, 11, PPGE_ALIGN_VCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF));
}

int PSPNetconfDialog::Update(int animSpeed) {
UpdateButtons();
I18NCategory *di = GetI18NCategory("Dialog");
I18NCategory *err = GetI18NCategory("Error");
auto di = GetI18NCategory("Dialog");
auto err = GetI18NCategory("Error");
const float WRAP_WIDTH = 254.0f;
const int confirmBtnImage = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? I_CROSS : I_CIRCLE;
const int confirmBtn = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CROSS : CTRL_CIRCLE;
@@ -917,7 +917,7 @@ int PSPOskDialog::Update(int animSpeed) {
PPGeDrawRect(0, 0, 480, 272, CalcFadedColor(0x63636363));
RenderKeyboard();

I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");

PPGeDrawImage(I_SQUARE, 365, 222, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
PPGeDrawText(di->T("Space"), 390, 222, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
@@ -280,7 +280,7 @@ const std::string PSPSaveDialog::GetSelectedSaveDirName() const

void PSPSaveDialog::DisplayBanner(int which)
{
I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");
PPGeDrawRect(0, 0, 480, 23, CalcFadedColor(0x65636358));
const char *title;
switch (which)
@@ -394,7 +394,7 @@ void PSPSaveDialog::DisplaySaveDataInfo1()
{
std::lock_guard<std::mutex> guard(paramLock);
if (param.GetFileInfo(currentSelectedSave).size == 0) {
I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");
PPGeDrawText(di->T("NEW DATA"), 180, 136, PPGE_ALIGN_VCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF));
} else {
char title[512];
@@ -539,7 +539,7 @@ void PSPSaveDialog::DisplayMessage(std::string text, bool hasYesNo)
float h2 = h * (float)n / 2.0f;
if (hasYesNo)
{
I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");
const char *choiceText;
u32 yesColor, noColor;
float x, w;
@@ -621,7 +621,7 @@ int PSPSaveDialog::Update(int animSpeed)
cancelButtonFlag = CTRL_CIRCLE;
}

I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");

switch (display)
{
@@ -392,7 +392,7 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD

if (!pspFileSystem.GetFileInfo(dirPath).exists) {
if (!pspFileSystem.MkDir(dirPath)) {
I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Unable to write savedata, disk may be full"));
}
}
@@ -422,7 +422,7 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
}

if (EncryptData(decryptMode, cryptedData, &cryptedSize, &aligned_len, cryptedHash, (hasKey ? param->key : 0)) != 0) {
I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Save encryption failed. This save won't work on real PSP"), 6.0f);
ERROR_LOG(SCEUTILITY,"Save encryption failed. This save won't work on real PSP");
delete[] cryptedData;
@@ -689,7 +689,7 @@ void SavedataParam::LoadCryptedSave(SceUtilitySavedataParam *param, u8 *data, co

// Don't notify the user if we're not going to upgrade the save.
if (!g_Config.bEncryptSave) {
I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");
host->NotifyUserMessage(di->T("When you save, it will load on a PSP, but not an older PPSSPP"), 6.0f);
host->NotifyUserMessage(di->T("Old savedata detected"), 6.0f);
}
@@ -701,7 +701,7 @@ void SavedataParam::LoadCryptedSave(SceUtilitySavedataParam *param, u8 *data, co
}
if (g_Config.bSavedataUpgrade) {
decryptMode = prevCryptMode;
I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");
host->NotifyUserMessage(di->T("When you save, it will not work on outdated PSP Firmware anymore"), 6.0f);
host->NotifyUserMessage(di->T("Old savedata detected"), 6.0f);
}
@@ -64,7 +64,7 @@ u32 BlockDevice::CalculateCRC() {
}

void BlockDevice::NotifyReadError() {
I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
if (!reportedError_) {
host->NotifyUserMessage(err->T("Game disc read error - ISO corrupt"), 6.0f);
reportedError_ = true;
@@ -251,7 +251,7 @@ bool DirectoryFileHandle::Open(const std::string &basePath, std::string &fileNam

if (w32err == ERROR_DISK_FULL || w32err == ERROR_NOT_ENOUGH_QUOTA) {
// This is returned when the disk is full.
I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Disk full while writing data"));
error = SCE_KERNEL_ERROR_ERRNO_NO_PERM;
} else if (!success) {
@@ -315,7 +315,7 @@ bool DirectoryFileHandle::Open(const std::string &basePath, std::string &fileNam
}
} else if (errno == ENOSPC) {
// This is returned when the disk is full.
I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Disk full while writing data"));
error = SCE_KERNEL_ERROR_ERRNO_NO_PERM;
} else {
@@ -383,7 +383,7 @@ size_t DirectoryFileHandle::Write(const u8* pointer, s64 size)

if (diskFull) {
ERROR_LOG(FILESYS, "Disk full");
I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Disk full while writing data"));
// We only return an error when the disk is actually full.
// When writing this would cause the disk to be full, so it wasn't written, we return 0.
@@ -1457,7 +1457,7 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
int sent = send(metasocket, (char*)&packet, sizeof(packet), 0);
changeBlockingMode(metasocket, 1); // Change to non-blocking
if (sent > 0) {
I18NCategory *n = GetI18NCategory("Networking");
auto n = GetI18NCategory("Networking");
host->NotifyUserMessage(n->T("Network Initialized"), 1.0);
return 0;
}
@@ -720,7 +720,7 @@ void __DisplayFlip(int cyclesLate) {
static bool hasNotifiedSlow = false;
if (!g_Config.bHideSlowWarnings && !hasNotifiedSlow && PSP_CoreParameter().fpsLimit == FPSLimit::NORMAL && IsRunningSlow()) {
#ifndef _DEBUG
I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
if (g_Config.bSoftwareRendering) {
host->NotifyUserMessage(err->T("Running slow: Try turning off Software Rendering"), 6.0f, 0xFF30D0D0);
} else {
@@ -381,7 +381,7 @@ namespace SaveState
return StringFromFormat("%s (%c)", title.c_str(), slotChar);
}
if (detectSlot(UNDO_STATE_EXTENSION)) {
I18NCategory *sy = GetI18NCategory("System");
auto sy = GetI18NCategory("System");
// Allow the number to be positioned where it makes sense.
std::string undo = sy->T("undo %c");
return title + " (" + StringFromFormat(undo.c_str(), slotChar) + ")";
@@ -402,7 +402,7 @@ namespace SaveState
}

// The file can't be loaded - let's note that.
I18NCategory *sy = GetI18NCategory("System");
auto sy = GetI18NCategory("System");
return File::GetFilename(filename) + " " + sy->T("(broken)");
}

@@ -437,7 +437,7 @@ namespace SaveState
if (!fn.empty()) {
Load(fn, callback, cbUserData);
} else {
I18NCategory *sy = GetI18NCategory("System");
auto sy = GetI18NCategory("System");
if (callback)
callback(Status::FAILURE, sy->T("Failed to load state. Error in the file system."), cbUserData);
}
@@ -494,7 +494,7 @@ namespace SaveState
SaveScreenshot(shot, Callback(), 0);
Save(fn + ".tmp", renameCallback, cbUserData);
} else {
I18NCategory *sy = GetI18NCategory("System");
auto sy = GetI18NCategory("System");
if (callback)
callback(Status::FAILURE, sy->T("Failed to save state. Error in the file system."), cbUserData);
}
@@ -729,7 +729,7 @@ namespace SaveState
std::string reason;
std::string title;

I18NCategory *sc = GetI18NCategory("Screen");
auto sc = GetI18NCategory("Screen");
const char *i18nLoadFailure = sc->T("Load savestate failed", "");
const char *i18nSaveFailure = sc->T("Save State Failed", "");
if (strlen(i18nLoadFailure) == 0)
@@ -168,7 +168,7 @@ bool TextureReplacer::LoadIniValues(IniFile &ini, bool isOverride) {
}

if (filenameWarning) {
I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("textures.ini filenames may not be cross-platform"), 6.0f);
}

@@ -261,7 +261,7 @@ bool GameManager::InstallGame(const std::string &url, const std::string &fileNam
return InstallRawISO(fileName, shortFilename, deleteAfter);
}

I18NCategory *sy = GetI18NCategory("System");
auto sy = GetI18NCategory("System");
installInProgress_ = true;

std::string pspGame = GetSysDirectory(DIRECTORY_GAME);
@@ -312,7 +312,7 @@ bool GameManager::InstallGame(const std::string &url, const std::string &fileNam
}

bool GameManager::DetectTexturePackDest(struct zip *z, int iniIndex, std::string *dest) {
I18NCategory *iz = GetI18NCategory("InstallZip");
auto iz = GetI18NCategory("InstallZip");

struct zip_stat zstat;
zip_stat_index(z, iniIndex, 0, &zstat);
@@ -491,7 +491,7 @@ bool GameManager::InstallMemstickGame(struct zip *z, const std::string &zipfile,
size_t allBytes = 0;
size_t bytesCopied = 0;

I18NCategory *sy = GetI18NCategory("System");
auto sy = GetI18NCategory("System");

auto fileAllowed = [&](const char *fn) {
if (!allowRoot && strchr(fn, '/') == 0)
@@ -1906,7 +1906,7 @@ void FramebufferManagerCommon::UpdateFramebufUsage(VirtualFramebuffer *vfb) {
}

void FramebufferManagerCommon::ShowScreenResolution() {
I18NCategory *gr = GetI18NCategory("Graphics");
auto gr = GetI18NCategory("Graphics");

std::ostringstream messageStream;
messageStream << gr->T("Internal Resolution") << ": ";
@@ -101,7 +101,7 @@ GPU_DX9::GPU_DX9(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
// Disable hardware tessellation bacause DX9 is still unsupported.
g_Config.bHardwareTessellation = false;
ERROR_LOG(G3D, "Hardware Tessellation is unsupported, falling back to software tessellation");
I18NCategory *gr = GetI18NCategory("Graphics");
auto gr = GetI18NCategory("Graphics");
host->NotifyUserMessage(gr->T("Turn off Hardware Tessellation - unsupported"), 2.5f, 0xFF3030FF);
}
}
@@ -588,7 +588,7 @@ VSShader *ShaderManagerDX9::ApplyShader(int prim, u32 vertType) {
vs = new VSShader(device_, VSID, codeBuffer_, useHWTransform);

if (vs->Failed()) {
I18NCategory *gr = GetI18NCategory("Graphics");
auto gr = GetI18NCategory("Graphics");
ERROR_LOG(G3D, "Shader compilation failed, falling back to software transform");
if (!g_Config.bHideSlowWarnings) {
host->NotifyUserMessage(gr->T("hardware transform error - falling back to software"), 2.5f, 0xFF3030FF);
@@ -112,7 +112,7 @@ GPU_GLES::GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
if (!gstate_c.SupportsAll(GPU_SUPPORTS_VERTEX_TEXTURE_FETCH | GPU_SUPPORTS_TEXTURE_FLOAT) || !hasTexelFetch) {
g_Config.bHardwareTessellation = false;
ERROR_LOG(G3D, "Hardware Tessellation is unsupported, falling back to software tessellation");
I18NCategory *gr = GetI18NCategory("Graphics");
auto gr = GetI18NCategory("Graphics");
host->NotifyUserMessage(gr->T("Turn off Hardware Tessellation - unsupported"), 2.5f, 0xFF3030FF);
}
}
@@ -678,7 +678,7 @@ Shader *ShaderManagerGLES::ApplyVertexShader(int prim, u32 vertType, VShaderID *
// Vertex shader not in cache. Let's compile it.
vs = CompileVertexShader(*VSID);
if (vs->Failed()) {
I18NCategory *gr = GetI18NCategory("Graphics");
auto gr = GetI18NCategory("Graphics");
ERROR_LOG(G3D, "Shader compilation failed, falling back to software transform");
if (!g_Config.bHideSlowWarnings) {
host->NotifyUserMessage(gr->T("hardware transform error - falling back to software"), 2.5f, 0xFF3030FF);
@@ -219,7 +219,7 @@ void TextureCacheGLES::StartFrame() {
lowMemoryMode_ = true;
decimationCounter_ = 0;

I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
if (standardScaleFactor_ > 1) {
host->NotifyUserMessage(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
} else {
@@ -1122,7 +1122,7 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) {
// TODO: We should stall the GPU here and wipe things out of memory.
// As is, it will almost definitely fail the second time, but next frame it may recover.

I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
if (scaleFactor > 1) {
host->NotifyUserMessage(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
} else {
@@ -471,7 +471,7 @@ bool MainUI::event(QEvent *e) {
}
break;
} else if (e->type() == browseFolderEvent) {
I18NCategory *mm = GetI18NCategory("MainMenu");
auto mm = GetI18NCategory("MainMenu");
QString fileName = QFileDialog::getExistingDirectory(nullptr, mm->T("Choose folder"), g_Config.currentDirectory.c_str());
if (QDir(fileName).exists()) {
NativeMessageReceived("browse_folderSelect", fileName.toStdString().c_str());
@@ -33,13 +33,13 @@

void Combo_keyScreen::CreateViews() {
using namespace UI;
I18NCategory *co = GetI18NCategory("Controls");
auto co = GetI18NCategory("Controls");
root_ = new LinearLayout(ORIENT_VERTICAL);
root_->Add(new ItemHeader(co->T("Combo Key Setting")));
LinearLayout *root__ = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(1.0));
root_->Add(root__);
LinearLayout *leftColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(120, FILL_PARENT));
I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");

static const int comboKeyImages[5] = {
I_1, I_2, I_3, I_4, I_5,
@@ -113,7 +113,7 @@ void Combo_keyScreen::CreateViews() {

std::map<std::string, int>::iterator imageFinder;

I18NCategory *mc = GetI18NCategory("MappableControls");
auto mc = GetI18NCategory("MappableControls");

for (auto i = keyToggles.begin(); i != keyToggles.end(); ++i) {
LinearLayout *row = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));

0 comments on commit 5009698

Please sign in to comment.
You can’t perform that action at this time.