Fixed a memory leak in sf::Window implementation on Windows

Synchronized sfml2 with trunk

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1280 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2009-11-21 21:39:31 +00:00
commit 17cf6873aa
8 changed files with 37 additions and 11 deletions

View file

@ -29,6 +29,7 @@
#include <unistd.h>
#include <sys/time.h>
namespace sf
{
namespace priv

View file

@ -36,29 +36,29 @@ namespace priv
////////////////////////////////////////////////////////////
double Platform::GetSystemTime()
{
static LARGE_INTEGER Frequency;
static BOOL UseHighPerformanceTimer = QueryPerformanceFrequency(&Frequency);
static LARGE_INTEGER frequency;
static BOOL useHighPerformanceTimer = QueryPerformanceFrequency(&frequency);
if (UseHighPerformanceTimer)
if (useHighPerformanceTimer)
{
// High performance counter available : use it
LARGE_INTEGER CurrentTime;
QueryPerformanceCounter(&CurrentTime);
LARGE_INTEGER currentTime;
QueryPerformanceCounter(&currentTime);
return static_cast<double>(CurrentTime.QuadPart) / Frequency.QuadPart;
return static_cast<double>(currentTime.QuadPart) / frequency.QuadPart;
}
else
{
// High performance counter not available : use GetTickCount (less accurate)
// High performance counter not available: use GetTickCount (less accurate)
return GetTickCount() * 0.001;
}
}
////////////////////////////////////////////////////////////
void Platform::Sleep(float Time)
void Platform::Sleep(float time)
{
::Sleep(static_cast<DWORD>(Time * 1000));
::Sleep(static_cast<DWORD>(time * 1000));
}
} // namespace priv

View file

@ -100,10 +100,12 @@ myIsCursorIn (false)
RegisterWindowClass();
// Compute position and size
int left = (GetDeviceCaps(GetDC(NULL), HORZRES) - mode.Width) / 2;
int top = (GetDeviceCaps(GetDC(NULL), VERTRES) - mode.Height) / 2;
HDC screenDC = GetDC(NULL);
int left = (GetDeviceCaps(screenDC, HORZRES) - mode.Width) / 2;
int top = (GetDeviceCaps(screenDC, VERTRES) - mode.Height) / 2;
int width = myWidth = mode.Width;
int height = myHeight = mode.Height;
ReleaseDC(NULL, screenDC);
// Choose the window style according to the Style parameter
DWORD win32Style = WS_VISIBLE;