From 427439780617614cd0f514bd9bc1db6a73d2b452 Mon Sep 17 00:00:00 2001 From: Kimmo Pekkola Date: Fri, 4 Sep 2009 17:18:15 +0000 Subject: [PATCH] The m_FontCollection wasn't initialized so it could cause a crash on exit. Some code cleanup. --- Library/MeasureCalc.cpp | 1 - Library/MeasureCalc.h | 1 - Library/MeterString.cpp | 5 +---- Library/MeterWindow.cpp | 20 ++++++-------------- Library/MeterWindow.h | 8 +------- 5 files changed, 8 insertions(+), 27 deletions(-) diff --git a/Library/MeasureCalc.cpp b/Library/MeasureCalc.cpp index 0a493528..de9f9c7c 100644 --- a/Library/MeasureCalc.cpp +++ b/Library/MeasureCalc.cpp @@ -26,7 +26,6 @@ using namespace std; hqStrMap* CMeasureCalc::c_VarMap = NULL; -int CMeasureCalc::m_Loop = 0; /* ** CMeasureCalc diff --git a/Library/MeasureCalc.h b/Library/MeasureCalc.h index 2409c947..c9bffc1d 100644 --- a/Library/MeasureCalc.h +++ b/Library/MeasureCalc.h @@ -40,7 +40,6 @@ private: hqMathParser* m_Parser; static hqStrMap* c_VarMap; - static int m_Loop; int m_UpdateRandom; int m_LowBound; diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index ca836afb..d7461376 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -109,8 +109,7 @@ void CMeterString::Initialize() if(m_FontFamily) delete m_FontFamily; m_FontFamily = new FontFamily(m_FontFace.c_str()); Status status = m_FontFamily->GetLastStatus(); - //=================================================== - /* Matt King Code */ + // It couldn't find the font family // Therefore we look in the privatefontcollection of this meters MeterWindow if(Ok != status) @@ -130,8 +129,6 @@ void CMeterString::Initialize() } } - /* Matt King end */ - //=================================================== FontStyle style = FontStyleRegular; diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index f3c8139f..cb2e1e8d 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -51,11 +51,12 @@ using namespace Gdiplus; #define SNAPDISTANCE 10 -int CMeterWindow::m_InstanceCount = 0; +int CMeterWindow::c_InstanceCount = 0; extern CRainmeter* Rainmeter; MULTIMONITOR_INFO CMeterWindow::m_Monitors = { 0 }; + /* ** CMeterWindow ** @@ -132,8 +133,9 @@ CMeterWindow::CMeterWindow(std::wstring& path, std::wstring& config, std::wstrin m_User32Library = LoadLibrary(L"user32.dll"); m_UpdateCounter = 0; + m_FontCollection = NULL; - m_InstanceCount++; + c_InstanceCount++; } /* @@ -165,18 +167,13 @@ CMeterWindow::~CMeterWindow() if(m_Window) DestroyWindow(m_Window); - //=================================================== - // Matt King Code if(m_FontCollection) delete m_FontCollection; - // Matt King Code End - //=================================================== - FreeLibrary(m_User32Library); - m_InstanceCount--; + c_InstanceCount--; - if (m_InstanceCount == 0) + if (c_InstanceCount == 0) { BOOL Result; int counter = 0; @@ -1413,8 +1410,6 @@ void CMeterWindow::ReadSkin() m_WindowUpdate = m_Parser.ReadInt(L"Rainmeter", L"Update", m_WindowUpdate); m_TransitionUpdate = m_Parser.ReadInt(L"Rainmeter", L"TransitionUpdate", m_TransitionUpdate); - //===================================================== - //Matt King Code // Checking for localfonts std::wstring localFont1 = m_Parser.ReadString(L"Rainmeter", L"LocalFont", L""); // If there is a local font we want to load it @@ -1506,9 +1501,6 @@ void CMeterWindow::ReadSkin() i++; } while(loop); } - //Matt King code end - //===================================================== - // Create the meters and measures diff --git a/Library/MeterWindow.h b/Library/MeterWindow.h index 6de9230f..fcbc1bd2 100644 --- a/Library/MeterWindow.h +++ b/Library/MeterWindow.h @@ -175,10 +175,7 @@ public: std::wstring MakePathAbsolute(std::wstring path); - //======================================================== - //MattKing Code Gdiplus::PrivateFontCollection* GetPrivateFontCollection(){ return m_FontCollection; } - //MattKing Code End protected: static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); @@ -320,12 +317,9 @@ private: CRainmeter* m_Rainmeter; // Pointer to the main object - static int m_InstanceCount; + static int c_InstanceCount; - //========================================================== - //MattKing code Gdiplus::PrivateFontCollection* m_FontCollection; - //MattKing end }; #endif