Added cache for the fonts.

Fixed a memory leak in the string meter.
Changed the library project to use precompiled headers.
This commit is contained in:
Kimmo Pekkola 2009-10-07 16:45:14 +00:00
parent 61df4e1bad
commit 0b4ba32924
38 changed files with 595 additions and 335 deletions

View File

@ -18,6 +18,9 @@
#pragma warning(disable : 4996) #pragma warning(disable : 4996)
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include "resource.h" #include "resource.h"
#include "..\Library\Rainmeter.h" #include "..\Library\Rainmeter.h"
@ -50,6 +53,9 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
WCHAR* WinName = L"Rainmeter control window"; WCHAR* WinName = L"Rainmeter control window";
HWND hWnd; HWND hWnd;
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
// _CrtSetBreakAlloc(5055);
if(!hPrevInstance) if(!hPrevInstance)
{ {
if (!InitApplication(hInstance, WinClass)) return FALSE; if (!InitApplication(hInstance, WinClass)) return FALSE;

View File

@ -16,9 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4786) #include "StdAfx.h"
#pragma warning(disable: 4996)
#include "Rainmeter.h" #include "Rainmeter.h"
#include "MeterWindow.h" #include "MeterWindow.h"
#include "Measure.h" #include "Measure.h"

View File

@ -16,9 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4786) #include "StdAfx.h"
#pragma warning(disable: 4996)
#include "ConfigParser.h" #include "ConfigParser.h"
#include "Litestep.h" #include "Litestep.h"
#include "Rainmeter.h" #include "Rainmeter.h"

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "Error.h" #include "Error.h"
#include <stdio.h> #include <stdio.h>

File diff suppressed because it is too large Load Diff

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "Litestep.h" #include "Litestep.h"
#include "Error.h" #include "Error.h"
#include "Rainmeter.h" #include "Rainmeter.h"

View File

@ -18,6 +18,7 @@
#pragma warning(disable: 4996) #pragma warning(disable: 4996)
#include "StdAfx.h"
#include "Measure.h" #include "Measure.h"
#include "MeasureCPU.h" #include "MeasureCPU.h"
#include "MeasureMemory.h" #include "MeasureMemory.h"

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "MeasureCPU.h" #include "MeasureCPU.h"
#include "Rainmeter.h" #include "Rainmeter.h"

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "MeasureCalc.h" #include "MeasureCalc.h"
#include "Rainmeter.h" #include "Rainmeter.h"
#include <cstdlib> #include <cstdlib>

View File

@ -18,6 +18,7 @@
#pragma warning(disable: 4996) #pragma warning(disable: 4996)
#include "StdAfx.h"
#include "MeasureDiskSpace.h" #include "MeasureDiskSpace.h"
#include "Rainmeter.h" #include "Rainmeter.h"

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "MeasureMemory.h" #include "MeasureMemory.h"
/* /*

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "MeasureNet.h" #include "MeasureNet.h"
#include "Rainmeter.h" #include "Rainmeter.h"

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "MeasureNetIn.h" #include "MeasureNetIn.h"
/* /*

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "MeasureNetOut.h" #include "MeasureNetOut.h"
/* /*

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "MeasureNetTotal.h" #include "MeasureNetTotal.h"
/* /*

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "MeasurePhysicalMemory.h" #include "MeasurePhysicalMemory.h"
/* /*

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "MeasurePlugin.h" #include "MeasurePlugin.h"
#include "Rainmeter.h" #include "Rainmeter.h"
#include "Error.h" #include "Error.h"

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "MeasureRegistry.h" #include "MeasureRegistry.h"
#include "Rainmeter.h" #include "Rainmeter.h"
#include "Error.h" #include "Error.h"

View File

@ -18,6 +18,7 @@
#pragma warning(disable: 4996) #pragma warning(disable: 4996)
#include "StdAfx.h"
#include "MeasureTime.h" #include "MeasureTime.h"
#include "Rainmeter.h" #include "Rainmeter.h"
#include <time.h> #include <time.h>

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "MeasureUptime.h" #include "MeasureUptime.h"
#include "Rainmeter.h" #include "Rainmeter.h"
#include <time.h> #include <time.h>

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "MeasureVirtualMemory.h" #include "MeasureVirtualMemory.h"
/* /*

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "Error.h" #include "Error.h"
#include "Meter.h" #include "Meter.h"
#include "MeterBitmap.h" #include "MeterBitmap.h"

View File

@ -16,9 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4786) #include "StdAfx.h"
#pragma warning(disable: 4996)
#include "MeterBar.h" #include "MeterBar.h"
#include "Measure.h" #include "Measure.h"
#include "Error.h" #include "Error.h"

View File

@ -16,9 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4786) #include "StdAfx.h"
#pragma warning(disable: 4996)
#include "MeterBitmap.h" #include "MeterBitmap.h"
#include "Measure.h" #include "Measure.h"
#include "Error.h" #include "Error.h"

View File

@ -16,9 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4786) #include "StdAfx.h"
#pragma warning(disable: 4996)
#include "MeterButton.h" #include "MeterButton.h"
#include "Measure.h" #include "Measure.h"
#include "Rainmeter.h" #include "Rainmeter.h"

View File

@ -16,9 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4786) #include "StdAfx.h"
#pragma warning(disable: 4996)
#include "MeterHistogram.h" #include "MeterHistogram.h"
#include "Measure.h" #include "Measure.h"
#include "Error.h" #include "Error.h"
@ -83,6 +81,7 @@ void CMeterHistogram::Initialize()
// Load the bitmaps if defined // Load the bitmaps if defined
if(!m_PrimaryImageName.empty()) if(!m_PrimaryImageName.empty())
{ {
if (m_PrimaryBitmap) delete m_PrimaryBitmap;
m_PrimaryBitmap = new Bitmap(m_PrimaryImageName.c_str()); m_PrimaryBitmap = new Bitmap(m_PrimaryImageName.c_str());
Status status = m_PrimaryBitmap->GetLastStatus(); Status status = m_PrimaryBitmap->GetLastStatus();
if(Ok != status) if(Ok != status)
@ -96,6 +95,7 @@ void CMeterHistogram::Initialize()
if(!m_SecondaryImageName.empty()) if(!m_SecondaryImageName.empty())
{ {
if (m_SecondaryBitmap) delete m_SecondaryBitmap;
m_SecondaryBitmap = new Bitmap(m_SecondaryImageName.c_str()); m_SecondaryBitmap = new Bitmap(m_SecondaryImageName.c_str());
Status status = m_SecondaryBitmap->GetLastStatus(); Status status = m_SecondaryBitmap->GetLastStatus();
if(Ok != status) if(Ok != status)
@ -106,6 +106,7 @@ void CMeterHistogram::Initialize()
if(!m_BothImageName.empty()) if(!m_BothImageName.empty())
{ {
if (m_BothBitmap) delete m_BothBitmap;
m_BothBitmap = new Bitmap(m_BothImageName.c_str()); m_BothBitmap = new Bitmap(m_BothImageName.c_str());
Status status = m_BothBitmap->GetLastStatus(); Status status = m_BothBitmap->GetLastStatus();
if(Ok != status) if(Ok != status)
@ -121,10 +122,12 @@ void CMeterHistogram::Initialize()
} }
// Create buffers for values // Create buffers for values
if (m_PrimaryValues) delete [] m_PrimaryValues;
m_PrimaryValues = new double[m_W]; m_PrimaryValues = new double[m_W];
memset(m_PrimaryValues, 0, sizeof(double) * m_W); memset(m_PrimaryValues, 0, sizeof(double) * m_W);
if (m_SecondaryMeasure) if (m_SecondaryMeasure)
{ {
if (m_SecondaryValues) delete [] m_SecondaryValues;
m_SecondaryValues = new double[m_W]; m_SecondaryValues = new double[m_W];
memset(m_SecondaryValues, 0, sizeof(double) * m_W); memset(m_SecondaryValues, 0, sizeof(double) * m_W);
} }

View File

@ -16,9 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4786) #include "StdAfx.h"
#pragma warning(disable: 4996)
#include "MeterImage.h" #include "MeterImage.h"
#include "Measure.h" #include "Measure.h"
#include "Error.h" #include "Error.h"

View File

@ -16,9 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4786) #include "StdAfx.h"
#pragma warning(disable: 4996)
#include "MeterLine.h" #include "MeterLine.h"
#include "Measure.h" #include "Measure.h"
#include "Error.h" #include "Error.h"

View File

@ -16,9 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4786) #include "StdAfx.h"
#pragma warning(disable: 4996)
#include "MeterRotator.h" #include "MeterRotator.h"
#include "Measure.h" #include "Measure.h"
#include "Error.h" #include "Error.h"

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#include "MeterRoundLine.h" #include "MeterRoundLine.h"
#include "Measure.h" #include "Measure.h"
#include "Error.h" #include "Error.h"

View File

@ -16,9 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4786) #include "StdAfx.h"
#pragma warning(disable: 4996)
#include "MeterString.h" #include "MeterString.h"
#include "Rainmeter.h" #include "Rainmeter.h"
#include "Measure.h" #include "Measure.h"
@ -26,6 +24,9 @@
using namespace Gdiplus; using namespace Gdiplus;
std::map<std::wstring, Gdiplus::FontFamily*> CMeterString::c_FontFamilies;
std::map<std::wstring, Gdiplus::Font*> CMeterString::c_Fonts;
/* /*
** CMeterString ** CMeterString
** **
@ -60,8 +61,6 @@ CMeterString::CMeterString(CMeterWindow* meterWindow) : CMeter(meterWindow)
*/ */
CMeterString::~CMeterString() CMeterString::~CMeterString()
{ {
if(m_Font) delete m_Font;
if(m_FontFamily) delete m_FontFamily;
} }
/* /*
@ -106,28 +105,39 @@ void CMeterString::Initialize()
{ {
CMeter::Initialize(); CMeter::Initialize();
if(m_FontFamily) delete m_FontFamily; // Check if the font family is in the cache and use it
m_FontFamily = new FontFamily(m_FontFace.c_str()); std::map<std::wstring, Gdiplus::FontFamily*>::iterator iter = c_FontFamilies.find(m_FontFace);
Status status = m_FontFamily->GetLastStatus(); if (iter != c_FontFamilies.end())
// It couldn't find the font family
// Therefore we look in the privatefontcollection of this meters MeterWindow
if(Ok != status)
{ {
m_FontFamily = new FontFamily(m_FontFace.c_str(), m_MeterWindow->GetPrivateFontCollection()); m_FontFamily = (*iter).second;
status = m_FontFamily->GetLastStatus(); }
else
{
m_FontFamily = new FontFamily(m_FontFace.c_str());
Status status = m_FontFamily->GetLastStatus();
// It couldn't find the font family: Log it. // It couldn't find the font family
// Therefore we look in the privatefontcollection of this meters MeterWindow
if(Ok != status) if(Ok != status)
{ {
std::wstring error = L"Error: Couldn't load font family: ";
error += m_FontFace;
DebugLog(error.c_str());
delete m_FontFamily; delete m_FontFamily;
m_FontFamily = NULL; m_FontFamily = new FontFamily(m_FontFace.c_str(), m_MeterWindow->GetPrivateFontCollection());
status = m_FontFamily->GetLastStatus();
// It couldn't find the font family: Log it.
if(Ok != status)
{
std::wstring error = L"Error: Couldn't load font family: ";
error += m_FontFace;
DebugLog(error.c_str());
delete m_FontFamily;
m_FontFamily = NULL;
}
} }
c_FontFamilies[m_FontFace] = m_FontFamily;
} }
FontStyle style = FontStyleRegular; FontStyle style = FontStyleRegular;
@ -154,18 +164,25 @@ void CMeterString::Initialize()
REAL size = (REAL)m_FontSize * (96.0f / (REAL)dpi); REAL size = (REAL)m_FontSize * (96.0f / (REAL)dpi);
if (m_FontFamily) std::map<std::wstring, Gdiplus::Font*>::iterator iter2 = c_Fonts.find(FontPropertiesToString(size, style));
if (iter2 != c_Fonts.end())
{ {
if(m_Font) delete m_Font; m_Font = (*iter2).second;
m_Font = new Gdiplus::Font(m_FontFamily, size, style);
} }
else else
{ {
if(m_Font) delete m_Font; if (m_FontFamily)
m_Font = new Gdiplus::Font(FontFamily::GenericSansSerif(), size, style); {
m_Font = new Gdiplus::Font(m_FontFamily, size, style);
}
else
{
m_Font = new Gdiplus::Font(FontFamily::GenericSansSerif(), size, style);
}
c_Fonts[FontPropertiesToString(size, style)] = m_Font;
} }
status = m_Font->GetLastStatus(); Status status = m_Font->GetLastStatus();
if(Ok != status) if(Ok != status)
{ {
throw CError(std::wstring(L"Unable to create font: ") + m_FontFace, __LINE__, __FILE__); throw CError(std::wstring(L"Unable to create font: ") + m_FontFace, __LINE__, __FILE__);
@ -192,6 +209,8 @@ void CMeterString::ReadConfig(const WCHAR* section)
CConfigParser& parser = m_MeterWindow->GetParser(); CConfigParser& parser = m_MeterWindow->GetParser();
m_MeasureNames.clear();
// Check for extra measures // Check for extra measures
int i = 2; int i = 2;
bool loop = true; bool loop = true;
@ -530,3 +549,41 @@ void CMeterString::BindMeasure(std::list<CMeasure*>& measures)
} }
} }
} }
/*
** FreeFontCache
**
** Static function which frees the font cache.
**
*/
void CMeterString::FreeFontCache()
{
std::map<std::wstring, Gdiplus::FontFamily*>::iterator iter = c_FontFamilies.begin();
for ( ; iter != c_FontFamilies.end(); iter++)
{
delete (*iter).second;
}
c_FontFamilies.clear();
std::map<std::wstring, Gdiplus::Font*>::iterator iter2 = c_Fonts.begin();
for ( ; iter2 != c_Fonts.end(); iter2++)
{
delete (*iter2).second;
}
c_Fonts.clear();
}
/*
** FontPropertiesToString
**
** Static helper to convert font properties to a string so it can be used as a key for the cache map.
**
*/
std::wstring CMeterString::FontPropertiesToString(REAL size, FontStyle style)
{
std::wstringstream stream;
stream << size << L"-" << (int)style;
return stream.str();
}
// EOF

View File

@ -40,6 +40,8 @@ public:
virtual bool Draw(Gdiplus::Graphics& graphics); virtual bool Draw(Gdiplus::Graphics& graphics);
virtual void BindMeasure(std::list<CMeasure*>& measures); virtual void BindMeasure(std::list<CMeasure*>& measures);
static void FreeFontCache();
private: private:
enum TEXTSTYLE enum TEXTSTYLE
{ {
@ -83,6 +85,10 @@ private:
std::vector<std::wstring> m_MeasureNames; std::vector<std::wstring> m_MeasureNames;
std::vector<CMeasure*> m_Measures; std::vector<CMeasure*> m_Measures;
static std::wstring FontPropertiesToString(Gdiplus::REAL size, Gdiplus::FontStyle style);
static std::map<std::wstring, Gdiplus::FontFamily*> c_FontFamilies; // Cache for the font families
static std::map<std::wstring, Gdiplus::Font*> c_Fonts; // Cache for the fonts
}; };
#endif #endif

View File

@ -16,9 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4786) #include "StdAfx.h"
#pragma warning(disable: 4996)
#include <windows.h> #include <windows.h>
#include <gdiplus.h> #include <gdiplus.h>
#include "MeterWindow.h" #include "MeterWindow.h"
@ -1551,11 +1549,14 @@ void CMeterWindow::ReadSkin()
{ {
// It's a measure // It's a measure
CMeasure* measure = CMeasure::Create(measureName.c_str(), this); CMeasure* measure = CMeasure::Create(measureName.c_str(), this);
measure->SetName(strSection.c_str()); if (measure)
measure->ReadConfig(m_Parser, strSection.c_str()); {
m_Measures.push_back(measure); measure->SetName(strSection.c_str());
measure->ReadConfig(m_Parser, strSection.c_str());
m_Measures.push_back(measure);
m_Parser.AddMeasure(measure); m_Parser.AddMeasure(measure);
}
} }
catch (CError& error) catch (CError& error)
{ {
@ -1568,9 +1569,12 @@ void CMeterWindow::ReadSkin()
{ {
// It's a meter // It's a meter
CMeter* meter = CMeter::Create(meterName.c_str(), this); CMeter* meter = CMeter::Create(meterName.c_str(), this);
meter->SetName(strSection.c_str()); if (meter)
meter->ReadConfig(strSection.c_str()); {
m_Meters.push_back(meter); meter->SetName(strSection.c_str());
meter->ReadConfig(strSection.c_str());
m_Meters.push_back(meter);
}
} }
catch (CError& error) catch (CError& error)
{ {

View File

@ -16,13 +16,12 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4996) #include "StdAfx.h"
#pragma warning(disable: 4786)
#include "Rainmeter.h" #include "Rainmeter.h"
#include "Error.h" #include "Error.h"
#include "AboutDialog.h" #include "AboutDialog.h"
#include "MeasureNet.h" #include "MeasureNet.h"
#include "MeterString.h"
#include "Resource.h" #include "Resource.h"
#include "UpdateCheck.h" #include "UpdateCheck.h"
#include <assert.h> #include <assert.h>
@ -656,6 +655,8 @@ CRainmeter::~CRainmeter()
WriteStats(true); WriteStats(true);
CMeterString::FreeFontCache();
GdiplusShutdown(m_GDIplusToken); GdiplusShutdown(m_GDIplusToken);
} }

19
Library/StdAfx.cpp Normal file
View File

@ -0,0 +1,19 @@
/*
Copyright (C) 2001 Kimmo Pekkola
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "StdAfx.h"

67
Library/StdAfx.h Normal file
View File

@ -0,0 +1,67 @@
/*
Copyright (C) 2009 Kimmo Pekkola
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __STDAFX_H__
#define __STDAFX_H__
#define _WIN32_IE 0x0600
#pragma warning(disable: 4786)
#pragma warning(disable: 4996)
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
// WINAPI
#include <windows.h>
#include <gdiplus.h>
#include <comdef.h>
#include <Iphlpapi.h>
#include <commctrl.h>
#include <shellapi.h>
#include <algorithm>
#include <Mmsystem.h>
#include <tchar.h>
#include <shlobj.h>
#include <winperf.h>
#include <Windns.h>
#include <Ipexport.h>
#include <Powrprof.h>
// STL
#include <map>
#include <string>
#include <vector>
#include <hash_map>
#include <list>
#include <sstream>
#include <ctime>
#include <cstdlib>
#include <fstream>
#include <iostream>
// RUNTIME
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <time.h>
#include <assert.h>
#include <io.h>
#endif

View File

@ -16,10 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#define _WIN32_IE 0x0600 #include "StdAfx.h"
#pragma warning(disable: 4996)
#include "TrayWindow.h" #include "TrayWindow.h"
#include "Resource.h" #include "Resource.h"
#include "Litestep.h" #include "Litestep.h"

View File

@ -16,9 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#pragma warning(disable: 4786) #include "StdAfx.h"
#pragma warning(disable: 4996)
#include <windows.h> #include <windows.h>
#include "Litestep.h" #include "Litestep.h"
#include "Rainmeter.h" #include "Rainmeter.h"