Moved joystick initialization to happen *after* the construction of windows, to fix a deadlock happening on Windows at DLL loading

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1003 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
laurentgom 2009-01-30 14:12:56 +00:00
parent 2f524481c1
commit c3687b4018
3 changed files with 274 additions and 259 deletions

View File

@ -43,8 +43,8 @@ myWindow (NULL),
myLastFrameTime (0.f),
myIsExternal (false),
myFramerateLimit(0),
mySetCursorPosX (-1),
mySetCursorPosY (-1)
mySetCursorPosX (0xFFFF),
mySetCursorPosY (0xFFFF)
{
}
@ -73,8 +73,8 @@ myWindow (NULL),
myLastFrameTime (0.f),
myIsExternal (true),
myFramerateLimit(0),
mySetCursorPosX (-1),
mySetCursorPosY (-1)
mySetCursorPosX (0xFFFF),
mySetCursorPosY (0xFFFF)
{
Create(Handle, Params);
}
@ -413,11 +413,12 @@ void Window::OnEvent(const Event& EventReceived)
////////////////////////////////////////////////////////////
void Window::Initialize(priv::WindowImpl* Window)
{
// Assign new window and listen to its events
// Assign and initialize the new window
myWindow = Window;
myWindow->AddListener(this);
myWindow->Initialize();
// Attach input to the window
// Listen to events from the new window
myWindow->AddListener(this);
myWindow->AddListener(&myInput);
// Setup default behaviours (to get a consistent behaviour across different implementations)

View File

@ -88,12 +88,6 @@ myWidth (0),
myHeight (0),
myJoyThreshold(0.1f)
{
// Initialize the joysticks
for (unsigned int i = 0; i < JoysticksCount; ++i)
{
myJoysticks[i].Initialize(i);
myJoyStates[i] = myJoysticks[i].UpdateState();
}
}
@ -125,6 +119,20 @@ void WindowImpl::RemoveListener(WindowListener* Listener)
}
////////////////////////////////////////////////////////////
/// Initialize window's states that can't be done at construction
////////////////////////////////////////////////////////////
void WindowImpl::Initialize()
{
// Initialize the joysticks
for (unsigned int i = 0; i < JoysticksCount; ++i)
{
myJoysticks[i].Initialize(i);
myJoyStates[i] = myJoysticks[i].UpdateState();
}
}
////////////////////////////////////////////////////////////
/// Get the client width of the window
////////////////////////////////////////////////////////////

View File

@ -108,6 +108,12 @@ public :
////////////////////////////////////////////////////////////
void RemoveListener(WindowListener* Listener);
////////////////////////////////////////////////////////////
/// Initialize window's states that can't be done at construction
///
////////////////////////////////////////////////////////////
void Initialize();
////////////////////////////////////////////////////////////
/// Get the client width of the window
///