Don't define interfaces inside anonymous namespace in wxMSW

IAutoCompleteDropDown interface was defined inside anonymous namespace to
avoid clashing with the same interface possibly (but not necessarily) declared
in the standard headers.

However gcc 4.9 is smart enough to realize that no classes deriving from a
class in an anonymous namespace can exist and so it devirtualizes the calls to
virtual methods of the objects of this type when compiling with optimizations
enabled. And it does it even if it means replacing the call to a virtual
method with just a call to __cxa_pure_virtual(), i.e. crashing during
run-time.

Prevent it from doing this by moving class declarations outside of the
anonymous namespace and fix the crash when using wxTextEntry::AutoComplete()
in the code compiled with g++ 4.9.

(this is a backport of 4475fe36a5 from master)
This commit is contained in:
Vadim Zeitlin
2016-02-11 23:39:44 +01:00
parent 41be4271e1
commit 65c634ed80

View File

@@ -81,9 +81,6 @@
// above.
#include <initguid.h>
namespace
{
// Normally this interface and its IID are defined in shobjidl.h header file
// included in the platform SDK but MinGW and Cygwin don't have it so redefine
// the interface ourselves and, as long as we do it all, do it for all
@@ -96,6 +93,9 @@ public:
virtual HRESULT wxSTDCALL ResetEnumerator() = 0;
};
namespace
{
DEFINE_GUID(wxIID_IAutoCompleteDropDown,
0x3cd141f4, 0x3c6a, 0x11d2, 0xbc, 0xaa, 0x00, 0xc0, 0x4f, 0xd9, 0x29, 0xdb);