--- vcl/inc/svdata.hxx.old	2006-07-10 18:32:58.000000000 +0200
+++ vcl/inc/svdata.hxx	2006-09-27 16:03:43.218388000 +0200
@@ -78,6 +78,9 @@
 namespace frame {
 	class XSessionManagerClient;
 }
+namespace awt {
+    class XDisplayConnection;
+}
 }}}
 
 struct ImplTimerData;
@@ -341,8 +344,9 @@
     Window*                 mpIntroWindow;      // the splash screen
     DockingManager*         mpDockingManager;
 
-    vos::OThread::TThreadIdentifier     mnMainThreadId;
-    ::vcl::DisplayConnection*           mpDisplayConnection;
+    vos::OThread::TThreadIdentifier                     mnMainThreadId;
+    ::com::sun::star::uno::Reference< 
+        ::com::sun::star::awt::XDisplayConnection >     mxDisplayConnection;
 
     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxAccessBridge;
     com::sun::star::uno::Reference< com::sun::star::frame::XSessionManagerClient > xSMClient;
--- vcl/source/app/svapp.cxx.old	2006-08-10 16:51:15.000000000 +0200
+++ vcl/source/app/svapp.cxx	2006-09-27 16:03:43.218388000 +0200
@@ -1662,7 +1662,11 @@
 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayConnection > Application::GetDisplayConnection()
 {
     ImplSVData* pSVData = ImplGetSVData();
-    return pSVData->mpDisplayConnection ? pSVData->mpDisplayConnection : new ::vcl::DisplayConnection;
+
+    if( !pSVData->mxDisplayConnection.is() )
+        pSVData->mxDisplayConnection.set( new ::vcl::DisplayConnection );
+
+    return pSVData->mxDisplayConnection;
 }
 
 // -----------------------------------------------------------------------
--- vcl/source/app/svmain.cxx.old	2006-08-04 14:31:30.000000000 +0200
+++ vcl/source/app/svmain.cxx	2006-09-27 16:03:43.218388000 +0200
@@ -252,8 +252,15 @@
         pSVData->maAppData.mbInAppMain = FALSE;
     }
     
-    if( pSVData->mpDisplayConnection )
-        pSVData->mpDisplayConnection->dispatchDowningEvent();
+    if( pSVData->mxDisplayConnection.is() )
+    {
+        vcl::DisplayConnection* pConnection = 
+            dynamic_cast<vcl::DisplayConnection*>(pSVData->mxDisplayConnection.get());
+
+        if( pConnection )
+            pConnection->dispatchDowningEvent();
+        pSVData->mxDisplayConnection.clear();
+    }
 
     // This is a hack to work around the problem of the asynchronous nature
     // of bridging accessibility through Java: on shutdown there might still 
--- vcl/source/helper/xconnection.cxx.old	2006-07-10 18:35:54.000000000 +0200
+++ vcl/source/helper/xconnection.cxx	2006-09-27 16:03:43.218388000 +0200
@@ -49,7 +49,6 @@
 DisplayConnection::DisplayConnection()
 {
 	ImplSVData* pSVData = ImplGetSVData();
-	pSVData->mpDisplayConnection = this;
 	pSVData->mpDefInst->SetEventCallback( this, dispatchEvent );
 	pSVData->mpDefInst->SetErrorEventCallback( this, dispatchErrorEvent );
 
@@ -70,9 +69,12 @@
 DisplayConnection::~DisplayConnection()
 {
 	ImplSVData* pSVData = ImplGetSVData();
-	pSVData->mpDisplayConnection = NULL;
-	pSVData->mpDefInst->SetEventCallback( NULL, NULL );
-	pSVData->mpDefInst->SetErrorEventCallback( NULL, NULL );
+
+    if( pSVData )
+    {
+        pSVData->mpDefInst->SetEventCallback( NULL, NULL );
+        pSVData->mpDefInst->SetErrorEventCallback( NULL, NULL );
+    }
 }
 
 
