From 98724979cbf0119d1466bb8eee277b53b8b56aff Mon Sep 17 00:00:00 2001 From: lightningterror <18107717+lightningterror@users.noreply.github.com> Date: Wed, 24 Aug 2022 03:43:53 +0200 Subject: [PATCH] GUI-Wx: Fix variable initializations. Codacy Warning: Variable 'variable' is assigned in constructor body. Consider performing initialization in initialization list. --- pcsx2/gui/AppConfig.cpp | 28 ++++++++++++++-------------- pcsx2/gui/AppCoreThread.cpp | 2 +- pcsx2/gui/AppInit.cpp | 8 ++++---- pcsx2/gui/ConsoleLogger.cpp | 4 ++-- pcsx2/gui/IsoDropTarget.cpp | 8 ++++---- pcsx2/gui/SysCoreThread.cpp | 3 +-- pcsx2/gui/i18n.cpp | 11 ++++------- 7 files changed, 30 insertions(+), 34 deletions(-) diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index d48190dbc1..562002e527 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -557,8 +557,8 @@ AppConfig::AppConfig() , McdSettingsTabName(L"none") , AppSettingsTabName(L"none") , GameDatabaseTabName(L"none") + , LanguageId(wxLANGUAGE_DEFAULT) { - LanguageId = wxLANGUAGE_DEFAULT; LanguageCode = L"default"; RecentIsoCount = 20; Listbook_ImageSize = 32; @@ -827,6 +827,8 @@ void AppSetEmuFolders() // ------------------------------------------------------------------------ AppConfig::GSWindowOptions::GSWindowOptions() + : WindowSize(wxSize(640, 480)) + , WindowPos(wxDefaultPosition) { CloseOnEsc = true; DefaultToFullscreen = false; @@ -834,8 +836,6 @@ AppConfig::GSWindowOptions::GSWindowOptions() DisableResizeBorders = false; DisableScreenSaver = true; - WindowSize = wxSize(640, 480); - WindowPos = wxDefaultPosition; IsMaximized = false; IsFullscreen = false; EnableVsyncWindowFlag = false; @@ -934,18 +934,18 @@ void AppConfig::CaptureOptions::LoadSave(IniInterface& ini) } AppConfig::UiTemplateOptions::UiTemplateOptions() + : LimiterUnlimited(L"Max") + , LimiterTurbo(L"Turbo") + , LimiterSlowmo(L"Slowmo") + , LimiterNormal(L"Normal") + , OutputFrame(L"Frame") + , OutputField(L"Field") + , OutputProgressive(L"Progressive") + , OutputInterlaced(L"Interlaced") + , Paused(L" ") + , TitleTemplate(L"Slot: ${slot} | Speed: ${speed} (${vfps}) | ${videomode} | Limiter: ${limiter} | ${gs} | ${omodei} | ${cpuusage}") + , RecordingTemplate(L"Slot: ${slot} | Frame: ${frame}/${maxFrame} | Rec. Mode: ${mode} | Speed: ${speed} (${vfps}) | Limiter: ${limiter}") { - LimiterUnlimited = L"Max"; - LimiterTurbo = L"Turbo"; - LimiterSlowmo = L"Slowmo"; - LimiterNormal = L"Normal"; - OutputFrame = L"Frame"; - OutputField = L"Field"; - OutputProgressive = L"Progressive"; - OutputInterlaced = L"Interlaced"; - Paused = L" "; - TitleTemplate = L"Slot: ${slot} | Speed: ${speed} (${vfps}) | ${videomode} | Limiter: ${limiter} | ${gs} | ${omodei} | ${cpuusage}"; - RecordingTemplate = L"Slot: ${slot} | Frame: ${frame}/${maxFrame} | Rec. Mode: ${mode} | Speed: ${speed} (${vfps}) | Limiter: ${limiter}"; } void AppConfig::UiTemplateOptions::LoadSave(IniInterface& ini) diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp index ebe47b989b..bfa2cdb97d 100644 --- a/pcsx2/gui/AppCoreThread.cpp +++ b/pcsx2/gui/AppCoreThread.cpp @@ -112,8 +112,8 @@ static void PostCoreStatus(CoreThreadStatus pevt) // -------------------------------------------------------------------------------------- AppCoreThread::AppCoreThread() : SysCoreThread() + , m_resetCdvd(false) { - m_resetCdvd = false; } AppCoreThread::~AppCoreThread() diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp index 913954ab8b..8fa536a8cc 100644 --- a/pcsx2/gui/AppInit.cpp +++ b/pcsx2/gui/AppInit.cpp @@ -677,6 +677,10 @@ protected: Pcsx2App::Pcsx2App() : SysExecutorThread(new SysEvtHandler()) + , m_id_MainFrame(wxID_ANY) + , m_id_GsFrame(wxID_ANY) + , m_id_ProgramLogBox(wxID_ANY) + , m_id_Disassembler(wxID_ANY) { // Warning: Do not delete this comment block! Gettext will parse it to allow // the translation of some wxWidget internal strings. -- greg @@ -717,10 +721,6 @@ Pcsx2App::Pcsx2App() m_UseGUI = true; m_NoGuiExitPrompt = true; - m_id_MainFrame = wxID_ANY; - m_id_GsFrame = wxID_ANY; - m_id_ProgramLogBox = wxID_ANY; - m_id_Disassembler = wxID_ANY; m_ptr_ProgramLog = NULL; SetAppName(L"PCSX2"); diff --git a/pcsx2/gui/ConsoleLogger.cpp b/pcsx2/gui/ConsoleLogger.cpp index 943f82c9b0..a19becaacd 100644 --- a/pcsx2/gui/ConsoleLogger.cpp +++ b/pcsx2/gui/ConsoleLogger.cpp @@ -387,13 +387,13 @@ ConsoleLogFrame::ConsoleLogFrame( MainEmuFrame *parent, const wxString& title, A , m_timer_FlushUnlocker( this ) , m_ColorTable( options.FontSize ) + , m_pendingFlushMsg(false) + , m_WaitingThreadsForFlush(0) , m_QueueColorSection( "ConsoleLog::QueueColorSection" ) , m_QueueBuffer( "ConsoleLog::QueueBuffer" ) , m_threadlogger( EnableThreadedLoggingTest ? new ConsoleTestThread() : NULL ) { m_CurQueuePos = 0; - m_WaitingThreadsForFlush = 0; - m_pendingFlushMsg = false; m_FlushRefreshLocked = false; // create Log menu (contains most options) diff --git a/pcsx2/gui/IsoDropTarget.cpp b/pcsx2/gui/IsoDropTarget.cpp index b4a2a66baf..63c3b0b7d1 100644 --- a/pcsx2/gui/IsoDropTarget.cpp +++ b/pcsx2/gui/IsoDropTarget.cpp @@ -41,8 +41,8 @@ protected: public: DroppedTooManyFiles( const wxWindow* window ) : pxActionEvent() + , m_ownerid(window->GetId()) { - m_ownerid = window->GetId(); } virtual ~DroppedTooManyFiles() = default; @@ -70,8 +70,8 @@ protected: public: DroppedElf( const wxWindow* window ) : pxActionEvent() + , m_ownerid(window->GetId()) { - m_ownerid = window->GetId(); } virtual ~DroppedElf() = default; @@ -118,9 +118,9 @@ protected: public: DroppedIso( const wxWindow* window, const wxString& filename ) : pxActionEvent() - , m_filename( filename ) + , m_ownerid(window->GetId()) + , m_filename(filename) { - m_ownerid = window->GetId(); } virtual ~DroppedIso() = default; diff --git a/pcsx2/gui/SysCoreThread.cpp b/pcsx2/gui/SysCoreThread.cpp index 35f441d1d6..04855b7fb3 100644 --- a/pcsx2/gui/SysCoreThread.cpp +++ b/pcsx2/gui/SysCoreThread.cpp @@ -64,14 +64,13 @@ namespace PINESettings // -------------------------------------------------------------------------------------- SysCoreThread::SysCoreThread() + : m_hasActiveMachine(false) { m_name = L"EE Core"; m_resetRecompilers = true; m_resetProfilers = true; m_resetVsyncTimers = true; m_resetVirtualMachine = true; - - m_hasActiveMachine = false; } SysCoreThread::~SysCoreThread() diff --git a/pcsx2/gui/i18n.cpp b/pcsx2/gui/i18n.cpp index 29657a3d9e..f5771c21db 100644 --- a/pcsx2/gui/i18n.cpp +++ b/pcsx2/gui/i18n.cpp @@ -50,9 +50,8 @@ static wxString i18n_GetBetterLanguageName( const wxLanguageInfo* info ) } LangPackEnumeration::LangPackEnumeration( wxLanguage langId ) + : wxLangId(langId) { - wxLangId = langId; - if (const wxLanguageInfo* info = wxLocale::GetLanguageInfo( wxLangId )) { canonicalName = info->CanonicalName; @@ -61,12 +60,10 @@ LangPackEnumeration::LangPackEnumeration( wxLanguage langId ) } LangPackEnumeration::LangPackEnumeration() + : wxLangId(wxLANGUAGE_DEFAULT) + , canonicalName(L"default") + , englishName(L"System Default" + _(" (default)")) { - wxLangId = wxLANGUAGE_DEFAULT; - englishName = L"System Default"; - englishName += _(" (default)"); - canonicalName = L"default"; - int sysLang = wxLocale::GetSystemLanguage(); if (sysLang == wxLANGUAGE_UNKNOWN)