From 3b54720b3ac05b7dae4a8ab401a8d88d1d2467f3 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sun, 25 Aug 2019 18:11:01 -0700 Subject: [PATCH] Move wxKeyEvent assignment operator out of header It causes a warning with MSVC code analysis: "warning C26437: Do not slice (es.63)" It's unclear if this function even needs to exist, but at least move it out of line so the warning does not occur for user code. --- include/wx/event.h | 15 +-------------- src/common/event.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/wx/event.h b/include/wx/event.h index c13e7336b1..c57e6ff0ef 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -2186,20 +2186,7 @@ public: // we do need to copy wxKeyEvent sometimes (in wxTreeCtrl code, for // example) - wxKeyEvent& operator=(const wxKeyEvent& evt) - { - if ( &evt != this ) - { - wxEvent::operator=(evt); - - // Borland C++ 5.82 doesn't compile an explicit call to an - // implicitly defined operator=() so need to do it this way: - *static_cast(this) = evt; - - DoAssignMembers(evt); - } - return *this; - } + wxKeyEvent& operator=(const wxKeyEvent& evt); public: // Do not use these fields directly, they are initialized on demand, so diff --git a/src/common/event.cpp b/src/common/event.cpp index 7d269005ba..14249ede37 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -790,6 +790,21 @@ wxKeyEvent::wxKeyEvent(wxEventType eventType, const wxKeyEvent& evt) InitPropagation(); } +wxKeyEvent& wxKeyEvent::operator=(const wxKeyEvent& evt) +{ + if ( &evt != this ) + { + wxEvent::operator=(evt); + + // Borland C++ 5.82 doesn't compile an explicit call to an + // implicitly defined operator=() so need to do it this way: + *static_cast(this) = evt; + + DoAssignMembers(evt); + } + return *this; +} + void wxKeyEvent::InitPositionIfNecessary() const { if ( m_hasPosition )