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

Rare crash in clipboard access under Android

    XMLWordPrintable

    Details

    • Platform/s:
      Android
    • Commits:
      287b570ad5c00eb491f86eab0c4b8d3f6d96f666 (qt/qtbase/5.14) 08d6cb7673aa51bc0532d71db4134f4912e14769 (qt/qtbase/5.12.8)

      Description

      Caught by Firebase Crashlytics:

      Fatal Exception: java.lang.NullPointerException
      Attempt to invoke virtual method 'int android.content.ClipData.getItemCount()' on a null object reference
      org.qtproject.qt5.android.QtNative.hasClipboardText (QtNative.java:733)
      org.qtproject.qt5.android.QtActivityDelegate.updateHandles (QtActivityDelegate.java:550)
      org.qtproject.qt5.android.QtNative$10.run (QtNative.java:634)

      Code fragment:

               if (m_clipboardManager != null && m_clipboardManager.hasPrimaryClip()) {
                   ClipData primaryClip = m_clipboardManager.getPrimaryClip();
                   for (int i = 0; i < primaryClip.getItemCount(); ++i)
                       if (primaryClip.getItemAt(i).getText() != null)
                           return true;
      

      Looks like sometimes it is possible that getPrimaryClip() returns null even though hasPrimaryClip() returned false. A try-catch or check for null should be added.

        Attachments

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

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            tl1 Sergey Galin
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes