Revert "Fix passing Unicode strings via wxIPC when using DDE"
This reverts commit c657fd3d61
because
changing the format of DDE advise requests/replies is not a good idea:
other applications (those using previous versions of wxWidgets or even
not using wxWidgets at all) may rely on getting data in real CF_TEXT
format rather than in one of text formats preceded by the extra byte
containing the actual format and the previous commit would have silently
broken this.
Another fix for #17900 will be implemented instead.
This commit is contained in:
@@ -124,10 +124,6 @@ All (GUI):
|
||||
- Allow changing tooltip text for button allowing to enter a new string
|
||||
in wxPGArrayEditorDialog.
|
||||
|
||||
wxMSW:
|
||||
|
||||
- Fix passing Unicode strings via wxIPC when using DDE.
|
||||
|
||||
|
||||
3.1.2: (released 2018-12-10)
|
||||
----------------------------
|
||||
|
@@ -70,6 +70,7 @@ public:
|
||||
WXHCONV m_hConv;
|
||||
const void* m_sendingData;
|
||||
int m_dataSize;
|
||||
wxIPCFormat m_dataType;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxDDEConnection);
|
||||
wxDECLARE_DYNAMIC_CLASS(wxDDEConnection);
|
||||
|
@@ -268,11 +268,7 @@ void MyServer::Advise()
|
||||
{
|
||||
const wxDateTime now = wxDateTime::Now();
|
||||
|
||||
m_connection->Advise
|
||||
(
|
||||
m_connection->m_advise,
|
||||
wxString::FromUTF8("\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82")
|
||||
);
|
||||
m_connection->Advise(m_connection->m_advise, now.Format());
|
||||
|
||||
const wxString s = now.FormatTime() + " " + now.FormatDate();
|
||||
m_connection->Advise(m_connection->m_advise, s.mb_str(), wxNO_LEN);
|
||||
|
@@ -748,20 +748,12 @@ bool wxDDEConnection::DoAdvise(const wxString& item,
|
||||
size_t size,
|
||||
wxIPCFormat format)
|
||||
{
|
||||
// Unfortunately we currently always use the same CF_TEXT in StartAdvise()
|
||||
// but allow calling Advise() with different formats. This doesn't map well
|
||||
// to the DDE API, so the price to pay for it is that we need to send the
|
||||
// actual format used as part of the data, even if this means making
|
||||
// another copy of it.
|
||||
wxCharBuffer buf;
|
||||
buf.extend(size + 1);
|
||||
*buf.data() = format;
|
||||
memcpy(buf.data() + 1, data, size);
|
||||
|
||||
HSZ item_atom = DDEGetAtom(item);
|
||||
HSZ topic_atom = DDEGetAtom(m_topicName);
|
||||
m_sendingData = buf.data();
|
||||
m_dataSize = size + 1;
|
||||
m_sendingData = data; // mrf: potential for scope problems here?
|
||||
m_dataSize = size;
|
||||
// wxIPC_PRIVATE does not succeed, so use text instead
|
||||
m_dataType = format == wxIPC_PRIVATE ? wxIPC_TEXT : format;
|
||||
|
||||
bool ok = DdePostAdvise(DDEIdInst, topic_atom, item_atom) != 0;
|
||||
if ( !ok )
|
||||
@@ -994,12 +986,11 @@ _DDECallback(UINT wType,
|
||||
connection->m_dataSize,
|
||||
0,
|
||||
hsz2,
|
||||
wFmt,
|
||||
connection->m_dataType,
|
||||
0
|
||||
);
|
||||
|
||||
connection->m_sendingData = NULL;
|
||||
connection->m_dataSize = 0;
|
||||
|
||||
return (DDERETURN)data;
|
||||
}
|
||||
@@ -1017,21 +1008,18 @@ _DDECallback(UINT wType,
|
||||
|
||||
DWORD len = DdeGetData(hData, NULL, 0, 0);
|
||||
|
||||
BYTE* const data = static_cast<BYTE*>(connection->GetBufferAtLeast(len));
|
||||
void *data = connection->GetBufferAtLeast(len);
|
||||
wxASSERT_MSG(data != NULL,
|
||||
wxT("Buffer too small in _DDECallback (XTYP_ADVDATA)") );
|
||||
|
||||
DdeGetData(hData, data, len, 0);
|
||||
DdeGetData(hData, (LPBYTE)data, len, 0);
|
||||
|
||||
DdeFreeDataHandle(hData);
|
||||
|
||||
// Our code in DoAdvise() prepends the actual format of the
|
||||
// data as the first byte, extract it back now.
|
||||
if ( connection->OnAdvise(connection->m_topicName,
|
||||
item_name,
|
||||
data + 1,
|
||||
(int)len - 1,
|
||||
(wxIPCFormat)*data) )
|
||||
data,
|
||||
(int)len,
|
||||
(wxIPCFormat) wFmt) )
|
||||
{
|
||||
return (DDERETURN)(DWORD)DDE_FACK;
|
||||
}
|
||||
|
Reference in New Issue
Block a user