Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-69679

QXcbConnection::KeyChecker::m_release looks redundant

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 5.12
    • Fix Version/s: 5.12.0 Alpha
    • Component/s: QPA: X11/XCB
    • Labels:
      None
    • Platform/s:
      Linux/X11

      Description

      It's default value is 'true' and it never gets assigned 'false';

      class KeyChecker
      {
      public:
          KeyChecker(xcb_window_t window, xcb_keycode_t code, xcb_timestamp_t time, quint16 state)
              : m_window(window)
              , m_code(code)
              , m_time(time)
              , m_state(state)
              , m_error(false)
              , m_release(true)
          {
          }
      
          bool operator() (xcb_generic_event_t *ev)
          {
              if (m_error || !ev)
                  return false;
      
              int type = ev->response_type & ~0x80;
              if (type != XCB_KEY_PRESS && type != XCB_KEY_RELEASE)
                  return false;
      
              auto *event = reinterpret_cast<xcb_key_press_event_t *>(ev);
      
              if (event->event != m_window || event->detail != m_code || event->state != m_state) {
                  m_error = true;
                  return false;
              }
      
              if (type == XCB_KEY_PRESS) {
                  m_error = !m_release || event->time - m_time > 10;
                  return !m_error;
              }
      
              if (m_release) {
                  m_error = true;
                  return false;
              }
      
              m_release = true;
              m_time = event->time;
      
              return false;
          }
      
      private:
          xcb_window_t m_window;
          xcb_keycode_t m_code;
          xcb_timestamp_t m_time;
          quint16 m_state;
      
          bool m_error;
          bool m_release;
      };
      

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              paeglis Gatis Paeglis
              Reporter:
              paeglis Gatis Paeglis
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes