Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QApplication::clipboard()->setMimeData causing the QT application to crash
Forum Updated to NodeBB v4.3 + New Features

QApplication::clipboard()->setMimeData causing the QT application to crash

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
7 Posts 5 Posters 1.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PradeepJoy
    wrote on last edited by PradeepJoy
    #1

    Is there an issue with QApplication::clipboard()->setMimeData being used in very quick succession? Observed that the application crashes when the QApplication::clipboard()->setMimeData is made use of to update the clipboard very frequently( for eg: 10 cut operations per second)?

    Is there a way that can be suggested to give a throttling effect to the very frequent user operations? (Like restricting the Clipboard update to occur, say once in 500 ms rather at the user defined pace)

    raven-worxR 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Please show the backtrace. Maybe QApplication::clipboard() returns a nullptr?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • P PradeepJoy

        Is there an issue with QApplication::clipboard()->setMimeData being used in very quick succession? Observed that the application crashes when the QApplication::clipboard()->setMimeData is made use of to update the clipboard very frequently( for eg: 10 cut operations per second)?

        Is there a way that can be suggested to give a throttling effect to the very frequent user operations? (Like restricting the Clipboard update to occur, say once in 500 ms rather at the user defined pace)

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        @PradeepJoy
        show the code where you create and insert the QMimeData object into the clipboard.
        Note that the clipboard takes ownership of the mimedata object and thus shouldn't have a parent nor destroyed prematurely.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        1
        • P Offline
          P Offline
          PradeepJoy
          wrote on last edited by PradeepJoy
          #4

          @Christian-Ehrlicher , @raven-worx
          We are using qt version 4.7.3 (if this helps)

          Code Pointer


          QMimeData *mimeData = new QMimeData;
          QString strToCopy = defToDrag.isEmpty() ? textToDrag : (defToDrag + "{}" + textToDrag);
          mimeData->setText(strToCopy);
          QApplication::clipboard()->setMimeData(mimeData, QClipboard::Selection);
          QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
          

          We are not destroying mimeData anywhere..

          We are able consistently replicate the crash. Attaching couple of stack traces we observed,
          Stack Trace 1


          #0 0x00002aaaab1a1b0e in ?? () from /libQtGui.so.4
          #1 0x00002aaaab213304 in QClipboard::event(QEvent*) () from /libQtGui.so.4
          #2 0x00002aaaab18b6af in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /libQtGui.so.4
          #3 0x00002aaaab190e30 in QApplication::notify(QObject*, QEvent*) () from /libQtGui.so.4
          #4 0x00002aaaaac64364 in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /libQtCore.so.4
          #5 0x00002aaaab20ac3b in QApplication::x11ProcessEvent(_XEvent*) () from /libQtGui.so.4
          #6 0x00002aaaab233622 in ?? () from /libQtGui.so.4
          #7 0x0000003cf6640555 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
          #8 0x0000003cf6644d08 in ?? () from /lib64/libglib-2.0.so.0
          #9 0x0000003cf6644ec2 in g_main_context_iteration () from /lib64/libglib-2.0.so.0
          #10 0x00002aaaaac8fd15 in QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /libQtCore.so.4
          #11 0x00002aaaab23316f in ?? () from /libQtGui.so.4
          #12 0x00002aaaaac63715 in QEventLoop::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /libQtCore.so.4
          #13 0x00002aaaaac6397d in QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) () from /libQtCore.so.4
          #14 0x00002aaaaac65176 in QCoreApplication::exec() () from /libQtCore.so.4

          Stack Trace 2


          #0 0x00002aaaab211319 in QClipboard::setMimeData(QMimeData*, QClipboard::Mode) () from ../libQtGui.so.4
          #1 0x00000000008b1013 in MyClass::slotCut (this=0x18860d0, Cut=true, includeValues=false) at MyClass.C:2511

          Thank you for the support..

          jsulmJ 1 Reply Last reply
          0
          • P PradeepJoy

            @Christian-Ehrlicher , @raven-worx
            We are using qt version 4.7.3 (if this helps)

            Code Pointer


            QMimeData *mimeData = new QMimeData;
            QString strToCopy = defToDrag.isEmpty() ? textToDrag : (defToDrag + "{}" + textToDrag);
            mimeData->setText(strToCopy);
            QApplication::clipboard()->setMimeData(mimeData, QClipboard::Selection);
            QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
            

            We are not destroying mimeData anywhere..

            We are able consistently replicate the crash. Attaching couple of stack traces we observed,
            Stack Trace 1


            #0 0x00002aaaab1a1b0e in ?? () from /libQtGui.so.4
            #1 0x00002aaaab213304 in QClipboard::event(QEvent*) () from /libQtGui.so.4
            #2 0x00002aaaab18b6af in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /libQtGui.so.4
            #3 0x00002aaaab190e30 in QApplication::notify(QObject*, QEvent*) () from /libQtGui.so.4
            #4 0x00002aaaaac64364 in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /libQtCore.so.4
            #5 0x00002aaaab20ac3b in QApplication::x11ProcessEvent(_XEvent*) () from /libQtGui.so.4
            #6 0x00002aaaab233622 in ?? () from /libQtGui.so.4
            #7 0x0000003cf6640555 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
            #8 0x0000003cf6644d08 in ?? () from /lib64/libglib-2.0.so.0
            #9 0x0000003cf6644ec2 in g_main_context_iteration () from /lib64/libglib-2.0.so.0
            #10 0x00002aaaaac8fd15 in QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /libQtCore.so.4
            #11 0x00002aaaab23316f in ?? () from /libQtGui.so.4
            #12 0x00002aaaaac63715 in QEventLoop::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /libQtCore.so.4
            #13 0x00002aaaaac6397d in QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) () from /libQtCore.so.4
            #14 0x00002aaaaac65176 in QCoreApplication::exec() () from /libQtCore.so.4

            Stack Trace 2


            #0 0x00002aaaab211319 in QClipboard::setMimeData(QMimeData*, QClipboard::Mode) () from ../libQtGui.so.4
            #1 0x00000000008b1013 in MyClass::slotCut (this=0x18860d0, Cut=true, includeValues=false) at MyClass.C:2511

            Thank you for the support..

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @PradeepJoy said in QApplication::clipboard()->setMimeData causing the QT application to crash:

            QApplication::clipboard()

            So, did you check whether it returns nullptr as @Christian-Ehrlicher suggested?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            P 1 Reply Last reply
            0
            • jsulmJ jsulm

              @PradeepJoy said in QApplication::clipboard()->setMimeData causing the QT application to crash:

              QApplication::clipboard()

              So, did you check whether it returns nullptr as @Christian-Ehrlicher suggested?

              P Offline
              P Offline
              PradeepJoy
              wrote on last edited by
              #6

              @jsulm QApplication::clipboard() was not returning a null pointer.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                RogueWarrior
                wrote on last edited by
                #7

                See this forum post.
                https://forum.qt.io/topic/50701/solved-apparently-qmimedata-is-responsible-for-it-s-own-delete-after-having-been-used-to-set-the-clipboard/6

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved