Applied patch [ 600051 ] DDE and TCP improvements and fixes
By Michael Fielding As discussed on wx-dev. some fixes and improvements for Interprocess Communication (IPC), using DDE and TCP. 1. DDE buffers were using a global buffer 2. TCP buffers were allocated each time needed, and Request would have caused memory leaks had it been used. Fixed these both by using a self-resizing buffer in wxConnectionBase. Changed samples and docs to reflect the improved (but backward compatible) internal buffer management. wxConnectionBase could (in future) use wxMemoryBuffer. 3. IPC sample had trouble closing, causing crash, when closing server using window X button. Because it was (effectively) trying to delete a window in OnExit, when that window was already destroyed. Fixed by making IPCDialog and MyConnection remember if they'd destroyed each other. It's not elegant, but either the connection or the window could be deleted first. 4. Docs for wxDDE... and wxTCP... duplicated eachother, supposed to have same API. Some parts unclear. Patch removes dde and tcp-specific files (including from tipc.tex and classes.tex), and explains how ipc.h selects for you which one to use based on platform. Some other misc clarifications. 6. Client sample was suffering apparent memory leak because of not deleting connection object, and had a hack in there to do that. In fact this was due to the derived OnDisconnect not deleting itself, as it does in base class. Mentioned need to do it in docs, fixed sample so that it does. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
// Created: 4/1/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart and Markus Holzem
|
||||
// Licence: wxWindows license
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_IPCBASEH__
|
||||
@@ -50,8 +50,13 @@ class WXDLLEXPORT wxConnectionBase: public wxObject
|
||||
DECLARE_CLASS(wxConnectionBase)
|
||||
|
||||
public:
|
||||
inline wxConnectionBase(void) {}
|
||||
inline ~wxConnectionBase(void) {}
|
||||
wxConnectionBase(wxChar *buffer, int size); // use external buffer
|
||||
wxConnectionBase(); // use internal, adaptive buffer
|
||||
wxConnectionBase(wxConnectionBase& copy);
|
||||
~wxConnectionBase(void);
|
||||
|
||||
void SetConnected( bool c ) { m_connected = c; }
|
||||
bool GetConnected() { return m_connected; }
|
||||
|
||||
// Calls that CLIENT can make
|
||||
virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT ) = 0;
|
||||
@@ -106,8 +111,20 @@ public:
|
||||
// Callbacks to BOTH - override at will
|
||||
// Default behaviour is to delete connection and return TRUE
|
||||
virtual bool OnDisconnect(void) = 0;
|
||||
|
||||
// return a buffer at least this size, reallocating buffer if needed
|
||||
// returns NULL if using an inadequate user buffer - it can't be resized
|
||||
wxChar * GetBufferAtLeast( size_t bytes );
|
||||
|
||||
protected:
|
||||
bool m_connected;
|
||||
private:
|
||||
wxChar * m_buffer;
|
||||
size_t m_buffersize;
|
||||
bool m_deletebufferwhendone;
|
||||
};
|
||||
|
||||
|
||||
class WXDLLEXPORT wxServerBase: public wxObject
|
||||
{
|
||||
DECLARE_CLASS(wxServerBase)
|
||||
|
Reference in New Issue
Block a user