[LyX/master] Cleaner fix to ensure 32-bit XCB events

Enrico Forestieri forenr at lyx.org
Tue Feb 25 11:19:55 UTC 2020


commit f28334ac8bfb4b720c27516038ae89926bbf6258
Author: Enrico Forestieri <forenr at lyx.org>
Date:   Tue Feb 25 12:37:51 2020 +0100

    Cleaner fix to ensure 32-bit XCB events
    
    This fix still satisfies Valgrind and is cleaner than the approach
    at 19c41bd0: instead of using calloc we now use the C++11 specifier
    alignas. For more info, see the following ML thread:
    https://www.mail-archive.com/search?l=mid&q=20200219024908.5n4x4osni55gylo3%40tallinn
---
 src/frontends/qt/GuiApplication.cpp |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp
index 8fdd9bf..573ebb9 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -3352,7 +3352,13 @@ bool GuiApplication::nativeEventFilter(const QByteArray & eventType,
 				// not doing that, maybe because of our
 				// "persistent selection" implementation
 				// (see comments in GuiSelection.cpp).
-				xcb_selection_notify_event_t nev;
+				// It is expected that every X11 event is
+				// 32 bytes long, even if not all 32 bytes are
+				// needed. See:
+				// https://www.x.org/releases/current/doc/man/man3/xcb_send_event.3.xhtml
+				struct alignas(32) padded_event
+					: xcb_selection_notify_event_t {};
+				padded_event nev = {};
 				nev.response_type = XCB_SELECTION_NOTIFY;
 				nev.requestor = srev->requestor;
 				nev.selection = srev->selection;


More information about the lyx-cvs mailing list