Advertisement
Ancurio

SFML Xlib thread-safety

Dec 24th, 2012
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.36 KB | None | 0 0
  1. diff --git a/src/SFML/Window/Linux/Display.cpp b/src/SFML/Window/Linux/Display.cpp
  2. index 2420268..f46e525 100644
  3. --- a/src/SFML/Window/Linux/Display.cpp
  4. +++ b/src/SFML/Window/Linux/Display.cpp
  5. @@ -26,6 +26,7 @@
  6.  // Headers
  7.  ////////////////////////////////////////////////////////////
  8.  #include <SFML/Window/Linux/Display.hpp>
  9. +#include <X11/Xlib.h>
  10.  #include <cassert>
  11.  
  12.  
  13. @@ -43,6 +44,9 @@ namespace priv
  14.  ////////////////////////////////////////////////////////////
  15.  Display* OpenDisplay()
  16.  {
  17. +    // Ensure thread-safety
  18. +    XInitThreads();
  19. +
  20.      if (referenceCount == 0)
  21.          sharedDisplay = XOpenDisplay(NULL);
  22.      referenceCount++;
  23. diff --git a/src/SFML/Window/Linux/VideoModeImpl.cpp b/src/SFML/Window/Linux/VideoModeImpl.cpp
  24. index 0b8aca8..8c439f0 100644
  25. --- a/src/SFML/Window/Linux/VideoModeImpl.cpp
  26. +++ b/src/SFML/Window/Linux/VideoModeImpl.cpp
  27. @@ -42,6 +42,9 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
  28.  {
  29.      std::vector<VideoMode> modes;
  30.  
  31. +    // Ensure thread-safety
  32. +    XInitThreads();
  33. +
  34.      // Open a connection with the X server
  35.      Display* display = OpenDisplay();
  36.      if (display)
  37. @@ -119,6 +122,9 @@ VideoMode VideoModeImpl::getDesktopMode()
  38.  {
  39.      VideoMode desktopMode;
  40.  
  41. +    // Ensure thread-safety
  42. +    XInitThreads();
  43. +
  44.      // Open a connection with the X server
  45.      Display* display = OpenDisplay();
  46.      if (display)
  47. diff --git a/src/SFML/Window/Linux/WindowImplX11.cpp b/src/SFML/Window/Linux/WindowImplX11.cpp
  48. index 3cf2293..b38e6e6 100644
  49. --- a/src/SFML/Window/Linux/WindowImplX11.cpp
  50. +++ b/src/SFML/Window/Linux/WindowImplX11.cpp
  51. @@ -30,6 +30,7 @@
  52.  #include <SFML/Window/Linux/Display.hpp>
  53.  #include <SFML/System/Utf.hpp>
  54.  #include <SFML/System/Err.hpp>
  55. +#include <X11/Xlib.h>
  56.  #include <X11/Xutil.h>
  57.  #include <X11/keysym.h>
  58.  #include <X11/extensions/Xrandr.h>
  59. @@ -72,6 +73,9 @@ m_oldVideoMode(-1),
  60.  m_hiddenCursor(0),
  61.  m_keyRepeat   (true)
  62.  {
  63. +    // Ensure thread-safety
  64. +    XInitThreads();
  65. +
  66.      // Open a connection with the X server
  67.      m_display = OpenDisplay();
  68.      m_screen  = DefaultScreen(m_display);
  69. @@ -101,6 +105,9 @@ m_oldVideoMode(-1),
  70.  m_hiddenCursor(0),
  71.  m_keyRepeat   (true)
  72.  {
  73. +    // Ensure thread-safety
  74. +    XInitThreads();
  75. +
  76.      // Open a connection with the X server
  77.      m_display = OpenDisplay();
  78.      m_screen  = DefaultScreen(m_display);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement