kekar
01-05-2012 14:50:09
Hi,
I'm currently working on a project that is being developed for the 64 bits architecture (Windows 7 currently).
I've managed to compile all the dependencies for Ogre and MyGUI, but I struggled with crashes in the MyGUI API. I traced it down, and found that the currently Windows Input manager is calling unsafe 32bits calls like these;
In the MSDN documentation, there are actually better system calls to use, that are much more architecture-safe.
E.g:
I've made a small patch, replacing these and similar calls, and everything runs stable and fine.
Please note, I haven't tested a 32 bit build yet, but I assume this will work on both systems. If anyone that already have a 32 bit configuration ready, please let me know if there are any issues. I will check it myself later on.
I wasn't able to attach the package file in this post (quota reached or something), but the RAR-file with the two patched files in Common\Input\Win32 (InputManager.cpp and PointerManager.cpp) can be downloaded from here;
http://www.rosodev.com/projects/mygui/M ... patch2.rar
I hope this will be adopted/fixed in the future releases of MyGUI
I'm currently working on a project that is being developed for the 64 bits architecture (Windows 7 currently).
I've managed to compile all the dependencies for Ogre and MyGUI, but I struggled with crashes in the MyGUI API. I traced it down, and found that the currently Windows Input manager is calling unsafe 32bits calls like these;
SetWindowLong(mHwnd, GWL_WNDPROC, (long)windowProc);
In the MSDN documentation, there are actually better system calls to use, that are much more architecture-safe.
E.g:
Note To write code that is compatible with both 32-bit and 64-bit Windows, use SetClassLongPtr. When compiling for 32-bit Windows, SetClassLongPtr is defined as a call to the SetClassLong function
I've made a small patch, replacing these and similar calls, and everything runs stable and fine.
diff -ru ../orig/MyGUI_3.2.0/Common/Input/Win32/InputManager.cpp ./Common/Input/Win32/InputManager.cpp
--- ../orig/MyGUI_3.2.0/Common/Input/Win32/InputManager.cpp 2012-02-29 00:46:16.000000000 +0100
+++ ./Common/Input/Win32/InputManager.cpp 2012-05-01 15:01:30.728479900 +0200
@@ -228,8 +228,8 @@
// подÑовываем нашу функцию калбеков
if (!msOldWindowProc)
{
- msOldWindowProc = GetWindowLong(mHwnd, GWL_WNDPROC);
- SetWindowLong(mHwnd, GWL_WNDPROC, (long)windowProc);
+ msOldWindowProc = GetWindowLongPtr(mHwnd, GWLP_WNDPROC);
+ SetWindowLongPtr(mHwnd, GWLP_WNDPROC, (LONG_PTR)windowProc);
}
// уÑтанавливаем поддержку дропа файлов
@@ -246,7 +246,7 @@
// еÑли мы подменили процедуру, то вернем на меÑто
if (msOldWindowProc)
{
- SetWindowLong((HWND)mHwnd, GWL_WNDPROC, (long)msOldWindowProc);
+ SetWindowLongPtr((HWND)mHwnd, GWLP_WNDPROC, (LONG_PTR)msOldWindowProc);
msOldWindowProc = 0;
}
}
diff -ru ../orig/MyGUI_3.2.0/Common/Input/Win32/PointerManager.cpp ./Common/Input/Win32/PointerManager.cpp
--- ../orig/MyGUI_3.2.0/Common/Input/Win32/PointerManager.cpp 2012-02-22 21:28:12.000000000 +0100
+++ ./Common/Input/Win32/PointerManager.cpp 2012-05-01 15:01:28.812370300 +0200
@@ -58,7 +58,8 @@
void PointerManager::setPointerHandle(size_t _id)
{
- SetClassLong((HWND)mHwnd, GCL_HCURSOR, (LONG)_id);
+ SetClassLongPtr((HWND)mHwnd, GCLP_HCURSOR, (LONG_PTR)_id);
+
if ((GetCapture() == (HWND)mHwnd)
|| isMouseInClient())
{
Please note, I haven't tested a 32 bit build yet, but I assume this will work on both systems. If anyone that already have a 32 bit configuration ready, please let me know if there are any issues. I will check it myself later on.
I wasn't able to attach the package file in this post (quota reached or something), but the RAR-file with the two patched files in Common\Input\Win32 (InputManager.cpp and PointerManager.cpp) can be downloaded from here;
http://www.rosodev.com/projects/mygui/M ... patch2.rar
I hope this will be adopted/fixed in the future releases of MyGUI
