Don't define interfaces inside anonymous namespace in wxMSW

Some interfaces, notably IAutoCompleteDropDown, but also several other ones in
taskbarbutton.cpp, were defined inside anonymous namespace to avoid clashing
with the interfaces 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 commit is contained in:
Vadim Zeitlin
2016-02-11 23:39:44 +01:00
parent 1908c41f36
commit 4475fe36a5
2 changed files with 56 additions and 51 deletions

View File

@@ -83,9 +83,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
@@ -98,6 +95,9 @@ public:
virtual HRESULT wxSTDCALL ResetEnumerator() = 0;
};
namespace
{
DEFINE_GUID(wxIID_IAutoCompleteDropDown,
0x3cd141f4, 0x3c6a, 0x11d2, 0xbc, 0xaa, 0x00, 0xc0, 0x4f, 0xd9, 0x29, 0xdb);