]> git.saurik.com Git - wxWidgets.git/commitdiff
Committed a couple of IPC changes I forgot to do
authorJulian Smart <julian@anthemion.co.uk>
Mon, 2 Sep 2002 08:30:52 +0000 (08:30 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Mon, 2 Sep 2002 08:30:52 +0000 (08:30 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16928 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/dde.h
src/common/sckipc.cpp

index 8a2062753a95deba4153071d6842e3e7b15d22ad..8c915a4de2e5bf1539d0759122912f9f91f03065 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     01/02/97
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
-// Licence:    wxWindows licence
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #ifndef _WX_DDE_H_
@@ -49,8 +49,8 @@ class WXDLLEXPORT wxDDEConnection: public wxConnectionBase
 {
   DECLARE_DYNAMIC_CLASS(wxDDEConnection)
 public:
-  wxDDEConnection(char *buffer, int size);
-  wxDDEConnection(void);
+  wxDDEConnection(char *buffer, int size); // use external buffer
+  wxDDEConnection(); // use internal buffer
   ~wxDDEConnection(void);
 
   // Calls that CLIENT can make
@@ -70,9 +70,7 @@ public:
   virtual bool OnDisconnect(void);
 
  public:
-  char*         m_bufPtr;
   wxString      m_topicName;
-  int           m_bufSize;
   wxDDEServer*  m_server;
   wxDDEClient*  m_client;
 
index 634fbd6ee21f5fece35a2d08a4dd6362c9002e90..07fdd6582d8144a4ef6484991cfee23193ce333a 100644 (file)
@@ -346,12 +346,18 @@ wxTCPConnection::wxTCPConnection () : wxConnectionBase()
   m_codeco   = NULL;
 }
 
-wxTCPConnection::wxTCPConnection(char * WXUNUSED(buffer), int WXUNUSED(size))
+wxTCPConnection::wxTCPConnection(wxChar *buffer, int size)
+       : wxConnectionBase(buffer, size)
 {
+  m_sock     = NULL;
+  m_sockstrm = NULL;
+  m_codeci   = NULL;
+  m_codeco   = NULL;
 }
 
 wxTCPConnection::~wxTCPConnection ()
 {
+  Disconnect();
   wxDELETE(m_codeci);
   wxDELETE(m_codeco);
   wxDELETE(m_sockstrm);
@@ -371,10 +377,13 @@ void wxTCPConnection::Compress(bool WXUNUSED(on))
 // Calls that CLIENT can make.
 bool wxTCPConnection::Disconnect ()
 {
+  if ( !GetConnected() )
+      return TRUE;
   // Send the the disconnect message to the peer.
   m_codeco->Write8(IPC_DISCONNECT);
   m_sock->Notify(FALSE);
   m_sock->Close();
+  SetConnected(false);
 
   return TRUE;
 }
@@ -415,10 +424,11 @@ char *wxTCPConnection::Request (const wxString& item, int *size, wxIPCFormat for
   else
   {
     size_t s;
-    char *data = NULL;
 
     s = m_codeci->Read32();
-    data = new char[s];
+    wxChar *data = GetBufferAtLeast( s );
+    wxASSERT_MSG(data != NULL,
+                 _T("Buffer too small in wxTCPConnection::Request") );
     m_sockstrm->Read(data, s);
 
     if (size)
@@ -552,12 +562,13 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
 
     format = (wxIPCFormat)codeci->Read8();
     size = codeci->Read32();
-    data = new char[size];
+    data = connection->GetBufferAtLeast( size );
+    wxASSERT_MSG(data != NULL,
+                 _T("Buffer too small in wxTCPEventHandler::Client_OnRequest") );
     sockstrm->Read(data, size);
 
     connection->OnExecute (topic_name, data, size, format);
 
-    delete [] data;
     break;
   }
   case IPC_ADVISE:
@@ -569,12 +580,13 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
     item = codeci->ReadString();
     format = (wxIPCFormat)codeci->Read8();
     size = codeci->Read32();
-    data = new char[size];
+    data = connection->GetBufferAtLeast( size );
+    wxASSERT_MSG(data != NULL,
+                 _T("Buffer too small in wxTCPEventHandler::Client_OnRequest") );
     sockstrm->Read(data, size);
 
     connection->OnAdvise (topic_name, item, data, size, format);
 
-    delete [] data;
     break;
   }
   case IPC_ADVISE_START:
@@ -610,13 +622,13 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
     item = codeci->ReadString();
     format = (wxIPCFormat)codeci->Read8();
     size = codeci->Read32();
-    data = new wxChar[size];
+    data = connection->GetBufferAtLeast( size );
+    wxASSERT_MSG(data != NULL,
+                 _T("Buffer too small in wxTCPEventHandler::Client_OnRequest") );
     sockstrm->Read(data, size);
 
     connection->OnPoke (topic_name, item, data, size, format);
 
-    delete [] data;
-
     break;
   }
   case IPC_REQUEST:
@@ -648,6 +660,7 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
   {
     sock->Notify(FALSE);
     sock->Close();
+    connection->SetConnected(false);
     connection->OnDisconnect();
     break;
   }