From fc800ddcee4cc73a4c12abfba84a8e939b1cb306 Mon Sep 17 00:00:00 2001
From: Utkarsh Ayachit <utkarsh.ayachit@kitware.com>
Date: Fri, 20 Apr 2012 22:17:10 -0400
Subject: [PATCH] BUG: 13116. Fixed segfault on exit on windows.

The problem was that there were some extra checks added that
looked at the Server ptr which ended up being a dangling
ptr during cleanup. Fixed by using a QPointer.

Change-Id: Ica14b57827e0fe07e2c45edf206ee3107e58ae95
---
 Qt/Core/pqProxy.cxx |    6 ++++++
 Qt/Core/pqProxy.h   |    9 +++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/Qt/Core/pqProxy.cxx b/Qt/Core/pqProxy.cxx
index 6c85be7..2eedf15 100644
--- a/Qt/Core/pqProxy.cxx
+++ b/Qt/Core/pqProxy.cxx
@@ -102,6 +102,12 @@ pqProxy::~pqProxy()
 }
 
 //-----------------------------------------------------------------------------
+pqServer* pqProxy::getServer() const
+{
+  return this->Server;
+}
+
+//-----------------------------------------------------------------------------
 void pqProxy::addHelperProxy(const QString& key, vtkSMProxy* proxy)
 {
   bool already_added = false;
diff --git a/Qt/Core/pqProxy.h b/Qt/Core/pqProxy.h
index 56ed32b..48572a4 100644
--- a/Qt/Core/pqProxy.h
+++ b/Qt/Core/pqProxy.h
@@ -38,6 +38,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define _pqPipelineObject_h
 
 #include "pqServerManagerModelItem.h"
+#include <QPointer>
+
 class pqProxyInternal;
 class pqServer;
 class vtkPVXMLElement;
@@ -60,9 +62,8 @@ public:
   virtual ~pqProxy();
 
   /// Get the server on which this proxy exists.
-  pqServer *getServer() const
-    { return this->Server; }
-
+  pqServer *getServer() const;
+  
   /// This is a convenience method. It re-registers the underlying proxy
   /// with the requested new name under the same group. Then it unregisters
   /// the proxy from the group with the old name. This operation is
@@ -172,7 +173,7 @@ protected slots:
   void onProxyUnRegistered(const QString&, const QString&, vtkSMProxy*);
 
 private:
-  pqServer *Server;           ///< Stores the parent server.
+  QPointer<pqServer> Server;           ///< Stores the parent server.
   QString SMName;
   QString SMGroup;
   pqProxyInternal* Internal;
-- 
1.7.3.1.msysgit.0

