Fix crash caused by 04090b2

This commit is contained in:
Birunthan Mohanathas 2013-06-14 16:58:42 +03:00
parent 1847e89b8e
commit 9a62ebef95
2 changed files with 32 additions and 26 deletions

View File

@ -99,6 +99,7 @@ int RainmeterMain(LPWSTR cmdLine)
{
ret = rainmeter.MessagePump();
}
rainmeter.Finalize();
return ret;
}
@ -143,32 +144,6 @@ Rainmeter::Rainmeter() :
*/
Rainmeter::~Rainmeter()
{
KillTimer(m_Window, TIMER_NETSTATS);
DeleteAllUnmanagedMeterWindows();
DeleteAllMeterWindows();
delete m_TrayWindow;
System::Finalize();
MeasureNet::UpdateIFTable();
MeasureNet::UpdateStats();
WriteStats(true);
MeasureNet::FinalizeStatic();
MeasureCPU::FinalizeStatic();
MeterString::FinalizeStatic();
// Change the work area back
if (m_DesktopWorkAreaChanged)
{
UpdateDesktopWorkArea(true);
}
if (m_ResourceInstance) FreeLibrary(m_ResourceInstance);
if (m_Mutex) ReleaseMutex(m_Mutex);
CoUninitialize();
GdiplusShutdown(m_GDIplusToken);
@ -441,6 +416,35 @@ int Rainmeter::Initialize(LPCWSTR iniPath, LPCWSTR layout)
return 0; // All is OK
}
void Rainmeter::Finalize()
{
KillTimer(m_Window, TIMER_NETSTATS);
DeleteAllUnmanagedMeterWindows();
DeleteAllMeterWindows();
delete m_TrayWindow;
System::Finalize();
MeasureNet::UpdateIFTable();
MeasureNet::UpdateStats();
WriteStats(true);
MeasureNet::FinalizeStatic();
MeasureCPU::FinalizeStatic();
MeterString::FinalizeStatic();
// Change the work area back
if (m_DesktopWorkAreaChanged)
{
UpdateDesktopWorkArea(true);
}
if (m_ResourceInstance) FreeLibrary(m_ResourceInstance);
if (m_Mutex) ReleaseMutex(m_Mutex);
}
bool Rainmeter::IsAlreadyRunning()
{
typedef struct

View File

@ -93,6 +93,8 @@ public:
static Rainmeter& GetInstance();
int Initialize(LPCWSTR iniPath, LPCWSTR layout);
void Finalize();
bool IsAlreadyRunning();
int MessagePump();