From f5bca33eaa5d48ee613b07a1aea724794a8860ec Mon Sep 17 00:00:00 2001
From: Laurent Gomila <laurent.gom@gmail.com>
Date: Wed, 19 Sep 2012 23:12:45 +0200
Subject: [PATCH] Fixed X11 error caused by the previous commit

---
 src/SFML/Window/Linux/GlxContext.cpp | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/SFML/Window/Linux/GlxContext.cpp b/src/SFML/Window/Linux/GlxContext.cpp
index dac28989..bdc7be6c 100644
--- a/src/SFML/Window/Linux/GlxContext.cpp
+++ b/src/SFML/Window/Linux/GlxContext.cpp
@@ -40,8 +40,9 @@ namespace priv
 {
 ////////////////////////////////////////////////////////////
 GlxContext::GlxContext(GlxContext* shared) :
-m_window (0),
-m_context(NULL)
+m_window    (0),
+m_context   (NULL),
+m_ownsWindow(true)
 {
     // Open a connection with the X server
     m_display = OpenDisplay();
@@ -65,8 +66,9 @@ m_context(NULL)
 
 ////////////////////////////////////////////////////////////
 GlxContext::GlxContext(GlxContext* shared, const ContextSettings& settings, const WindowImpl* owner, unsigned int bitsPerPixel) :
-m_window (0),
-m_context(NULL)
+m_window    (0),
+m_context   (NULL),
+m_ownsWindow(false)
 {
     // Open a connection with the X server
     // (important: must be the same display as the owner window)
@@ -83,8 +85,9 @@ m_context(NULL)
 
 ////////////////////////////////////////////////////////////
 GlxContext::GlxContext(GlxContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height) :
-m_window (0),
-m_context(NULL)
+m_window    (0),
+m_context   (NULL),
+m_ownsWindow(true)
 {
     // Open a connection with the X server
     m_display = OpenDisplay();
@@ -118,7 +121,7 @@ GlxContext::~GlxContext()
     }
     
     // Destroy the window if we own it
-    if (m_window)
+    if (m_window && m_ownsWindow)
     {
         XDestroyWindow(m_display, m_window);
         XFlush(m_display);