[wx-dev] IPC issues
Vadim Zeitlin
vadim at wxwidgets.org
Sat Dec 1 12:09:44 PST 2007
On Sat, 01 Dec 2007 09:38:39 -0500 Brian Vanderburg II <BrianVanderburg2 at aim.com> wrote:
BVI> wxString GetDataAsText(const void* data, size_t size, wxIPCFormat format)
BVI> {
BVI> assert(format is valid)
BVI>
BVI> #if wxUSE_DDE_FOR_IPC
BVI> // the received data in GetDdeData is always in the format the
BVI> program is in
BVI> wxUnusedVar(format)
BVI> #if wxUSE_UNICODE
BVI> return wxString((wchar_t*)data, size);
BVI> #else
BVI> return wxString((char*)data, size);
BVI> #endif
BVI> #else
BVI> if(format == wxIPC_TEXT)
BVI> return wxString((char*)data, wxConvLibc);
BVI> else if(format == wxIPC_UTF8TEXT)
BVI> return wxString((char*)data, wxConvUTF8);
BVI> else
BVI> return wxString((wchar_t*)data);
BVI> #endif
BVI> }
In fact thinking more about it (and looking at the code) it seems that it
should be enough to set the format for DDE correctly, shouldn't it? So I'm
afraid I'm back to not understanding why exactly doesn't this work
currently, could you please reexplain? Thanks!
BVI> There is a minor problem with this code. If an empty string is sent
BVI> then the return string IsEmpty should be true, but the size will include
BVI> the null terminator and so wxString(data, size) will have the extra
BVI> null that it should not have.
I don't understand this at all: size of empty string is 0 and wxString
ctor from 0 length should create empty string. Do you say there is a bug in
wxString here?
Regards,
VZ
More information about the wx-dev
mailing list