On Mon, Feb 24, 2020 at 09:56:41PM +0100, Enrico Forestieri wrote: > On Mon, Feb 24, 2020 at 02:02:32PM -0500, Scott Kostyshak wrote: > > On Mon, Feb 24, 2020 at 06:39:25PM +0100, Enrico Forestieri wrote: > > > On Mon, Feb 24, 2020 at 11:05:51AM -0500, Scott Kostyshak wrote: > > > > > > > > Apparently another approach would be to add the following: > > > > > > > > memset(&padded_event, 0, sizeof(padded_event)); > > > > > > > > Valgrind does not complain when this line is added to the union patch. > > > > > > I am baffled. The last suggestion I have is trying > > > > > > alignas(32) xcb_selection_notify_event_t nev = {0}; > > > > Valgrind still gives the error. I attach the full Valgrind log. > > Sigh. The final attempt would be doing the same as it is done in Qt: > > struct alignas(32) padded_event > : xcb_selection_notify_event_t {}; > padded_event nev = {}; > > If also this fails, I give up.
It works! Please commit since I have no idea what is going on in this patch. In case it saves you time, attached is the diff and here's a commit message you can correct: 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 Thanks for the patch. Although this was frustrating for you, the non-valgrind-waiting part was fun for me since I got to learn a little bit more about memory and initialization. Scott
diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp index 2cdd5f6e3b..f665ae28f1 100644 --- a/src/frontends/qt/GuiApplication.cpp +++ b/src/frontends/qt/GuiApplication.cpp @@ -3356,22 +3356,21 @@ bool GuiApplication::nativeEventFilter(const QByteArray & eventType, // 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 - // TODO switch to Q_DECLARE_XCB_EVENT(event, xcb_selection_notify_event_t) - // once we require qt >= 5.6.3 or just copy the macro def. - xcb_selection_notify_event_t *nev = (xcb_selection_notify_event_t*) calloc(32, 1); - - nev->response_type = XCB_SELECTION_NOTIFY; - nev->requestor = srev->requestor; - nev->selection = srev->selection; - nev->target = srev->target; - nev->property = XCB_NONE; - nev->time = XCB_CURRENT_TIME; + 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; + nev.target = srev->target; + nev.property = XCB_NONE; + nev.time = XCB_CURRENT_TIME; xcb_connection_t * con = QX11Info::connection(); xcb_send_event(con, 0, srev->requestor, XCB_EVENT_MASK_NO_EVENT, - reinterpret_cast<char const *>(nev)); + reinterpret_cast<char const *>(&nev)); xcb_flush(con); - free(nev); #endif return true; }
signature.asc
Description: PGP signature
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel