Fixed DDE memory leaks.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25332 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -116,6 +116,7 @@ All (GUI):
|
|||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
|
||||||
|
- fixed DDE memory leaks
|
||||||
- fixed wxTE_*WRAP styles handling
|
- fixed wxTE_*WRAP styles handling
|
||||||
- wxTextCtrl::GetValue() works with text in non default encoding
|
- wxTextCtrl::GetValue() works with text in non default encoding
|
||||||
- changed wxCrashReport to generate minidumps instead of text files
|
- changed wxCrashReport to generate minidumps instead of text files
|
||||||
|
@@ -112,6 +112,7 @@ static HSZ DDEGetAtom(const wxString& string);
|
|||||||
// string handles
|
// string handles
|
||||||
static HSZ DDEAtomFromString(const wxString& s);
|
static HSZ DDEAtomFromString(const wxString& s);
|
||||||
static wxString DDEStringFromAtom(HSZ hsz);
|
static wxString DDEStringFromAtom(HSZ hsz);
|
||||||
|
static void DDEFreeString(HSZ hsz);
|
||||||
|
|
||||||
// error handling
|
// error handling
|
||||||
static wxString DDEGetErrorMsg(UINT error);
|
static wxString DDEGetErrorMsg(UINT error);
|
||||||
@@ -301,26 +302,45 @@ bool wxDDEServer::Create(const wxString& server)
|
|||||||
{
|
{
|
||||||
m_serviceName = server;
|
m_serviceName = server;
|
||||||
|
|
||||||
if ( !DdeNameService(DDEIdInst, DDEAtomFromString(server), (HSZ)NULL, DNS_REGISTER) )
|
HSZ hsz = DDEAtomFromString(server);
|
||||||
{
|
|
||||||
DDELogError(wxString::Format(_("Failed to register DDE server '%s'"),
|
|
||||||
server.c_str()));
|
|
||||||
|
|
||||||
|
if ( !hsz )
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
|
bool success = (DdeNameService(DDEIdInst, hsz, (HSZ) NULL, DNS_REGISTER)
|
||||||
|
!= NULL);
|
||||||
|
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
DDELogError(wxString::Format(_("Failed to register DDE server '%s'"),
|
||||||
|
server.c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
|
DDEFreeString(hsz);
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDDEServer::~wxDDEServer()
|
wxDDEServer::~wxDDEServer()
|
||||||
{
|
{
|
||||||
if ( !!m_serviceName )
|
if ( !!m_serviceName )
|
||||||
{
|
{
|
||||||
if ( !DdeNameService(DDEIdInst, DDEAtomFromString(m_serviceName),
|
HSZ hsz = DDEAtomFromString(m_serviceName);
|
||||||
(HSZ)NULL, DNS_UNREGISTER) )
|
|
||||||
|
if (hsz)
|
||||||
{
|
{
|
||||||
DDELogError(wxString::Format(_("Failed to unregister DDE server '%s'"),
|
if ( !DdeNameService(DDEIdInst, hsz,
|
||||||
m_serviceName.c_str()));
|
(HSZ) NULL, DNS_UNREGISTER) )
|
||||||
|
{
|
||||||
|
DDELogError(wxString::Format(
|
||||||
|
_("Failed to unregister DDE server '%s'"),
|
||||||
|
m_serviceName.c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
|
DDEFreeString(hsz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,12 +438,35 @@ wxConnectionBase *wxDDEClient::MakeConnection(const wxString& WXUNUSED(host),
|
|||||||
const wxString& server,
|
const wxString& server,
|
||||||
const wxString& topic)
|
const wxString& topic)
|
||||||
{
|
{
|
||||||
HCONV hConv = DdeConnect(DDEIdInst, DDEAtomFromString(server), DDEAtomFromString(topic),
|
HSZ hszServer = DDEAtomFromString(server);
|
||||||
(PCONVCONTEXT)NULL);
|
|
||||||
|
if ( !hszServer )
|
||||||
|
{
|
||||||
|
return (wxConnectionBase*) NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HSZ hszTopic = DDEAtomFromString(topic);
|
||||||
|
|
||||||
|
if ( !hszTopic )
|
||||||
|
{
|
||||||
|
DDEFreeString(hszServer);
|
||||||
|
return (wxConnectionBase*) NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HCONV hConv = ::DdeConnect(DDEIdInst, hszServer, hszTopic,
|
||||||
|
(PCONVCONTEXT) NULL);
|
||||||
|
|
||||||
|
DDEFreeString(hszServer);
|
||||||
|
DDEFreeString(hszTopic);
|
||||||
|
|
||||||
|
|
||||||
if ( !hConv )
|
if ( !hConv )
|
||||||
{
|
{
|
||||||
DDELogError(wxString::Format(_("Failed to create connection to server '%s' on topic '%s'"),
|
DDELogError( wxString::Format(
|
||||||
server.c_str(), topic.c_str()));
|
_("Failed to create connection to server '%s' on topic '%s'"),
|
||||||
|
server.c_str(), topic.c_str()) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -576,9 +619,9 @@ wxChar *wxDDEConnection::Request(const wxString& item, int *size, wxIPCFormat fo
|
|||||||
wxChar *data = GetBufferAtLeast( len );
|
wxChar *data = GetBufferAtLeast( len );
|
||||||
wxASSERT_MSG(data != NULL,
|
wxASSERT_MSG(data != NULL,
|
||||||
_T("Buffer too small in wxDDEConnection::Request") );
|
_T("Buffer too small in wxDDEConnection::Request") );
|
||||||
DdeGetData(returned_data, (LPBYTE)data, len, 0);
|
(void) DdeGetData(returned_data, (LPBYTE)data, len, 0);
|
||||||
|
|
||||||
DdeFreeDataHandle(returned_data);
|
(void) DdeFreeDataHandle(returned_data);
|
||||||
|
|
||||||
if (size)
|
if (size)
|
||||||
*size = (int)len;
|
*size = (int)len;
|
||||||
@@ -947,7 +990,10 @@ static HSZ DDEGetAtom(const wxString& str)
|
|||||||
return DDEAddAtom(str);
|
return DDEAddAtom(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
// atom <-> strings
|
/* atom <-> strings
|
||||||
|
The returned handle has to be freed by the caller (using
|
||||||
|
(static) DDEFreeString).
|
||||||
|
*/
|
||||||
static HSZ DDEAtomFromString(const wxString& s)
|
static HSZ DDEAtomFromString(const wxString& s)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( DDEIdInst, _T("DDE not initialized") );
|
wxASSERT_MSG( DDEIdInst, _T("DDE not initialized") );
|
||||||
@@ -972,6 +1018,15 @@ static wxString DDEStringFromAtom(HSZ hsz)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void DDEFreeString(HSZ hsz)
|
||||||
|
{
|
||||||
|
// DS: Failure to free a string handle might indicate there's
|
||||||
|
// some other severe error.
|
||||||
|
bool ok = (::DdeFreeStringHandle(DDEIdInst, hsz) != 0);
|
||||||
|
wxASSERT_MSG( ok, wxT("Failed to free DDE string handle") );
|
||||||
|
wxUnusedVar(ok);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// error handling
|
// error handling
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user