|
From: <ma...@us...> - 2010-01-10 22:46:59
|
Revision: 3263
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3263&view=rev
Author: matzon
Date: 2010-01-10 22:46:41 +0000 (Sun, 10 Jan 2010)
Log Message:
-----------
fix for issue with Cursor that turned out to be a leaking DC
Modified Paths:
--------------
trunk/LWJGL/src/native/windows/org_lwjgl_input_Cursor.c
Modified: trunk/LWJGL/src/native/windows/org_lwjgl_input_Cursor.c
===================================================================
--- trunk/LWJGL/src/native/windows/org_lwjgl_input_Cursor.c 2010-01-04 18:47:49 UTC (rev 3262)
+++ trunk/LWJGL/src/native/windows/org_lwjgl_input_Cursor.c 2010-01-10 22:46:41 UTC (rev 3263)
@@ -68,6 +68,7 @@
int maskCount = 0;
HBITMAP colorBitmap;
int x, y;
+ HDC hDC;
jobject handle_buffer = newJavaManagedByteBuffer(env, sizeof(HCURSOR));
int *pixels;
@@ -85,8 +86,10 @@
bitmapInfo.bmiHeader.biBitCount = 24;
bitmapInfo.bmiHeader.biCompression = BI_RGB;
+
+ hDC = GetDC(NULL);
- colorDIB = CreateDIBSection(GetDC(NULL), (BITMAPINFO*)&(bitmapInfo),
+ colorDIB = CreateDIBSection(hDC, (BITMAPINFO*)&(bitmapInfo),
DIB_RGB_COLORS,
(void*)&(ptrCursorImage),
NULL, 0);
@@ -94,6 +97,7 @@
dstPtr = ptrCursorImage;
if (!dstPtr) {
throwException(env, "Could not allocate DIB section.");
+ ReleaseDC(NULL, hDC);
return NULL;
}
for (y = 0; y < height; y++ ) {
@@ -107,7 +111,7 @@
}
}
- colorBitmap = CreateDIBitmap(GetDC(NULL),
+ colorBitmap = CreateDIBitmap(hDC,
(BITMAPINFOHEADER*)&bitmapInfo.bmiHeader,
CBM_INIT,
(void *)ptrCursorImage,
@@ -148,6 +152,7 @@
DeleteObject(colorBitmap);
DeleteObject(cursorMask);
free(maskPixels);
+ ReleaseDC(NULL, hDC);
cursor_handle = (HCURSOR *)(*env)->GetDirectBufferAddress(env, handle_buffer);
*cursor_handle = cursor;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|