Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Exception after QMessageBox opened from C++ when another full-screen QDialog opened (android)
Forum Updated to NodeBB v4.3 + New Features

Exception after QMessageBox opened from C++ when another full-screen QDialog opened (android)

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 2 Posters 657 Views
  • 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.
  • V Offline
    V Offline
    Vega4
    wrote on last edited by Vega4
    #1

    Scenario: There's a full-screen custom QDialog in place, now the dialog sends a Signal to back-end causing the back-end to open-up a QMessageBox (sort of a typical situation I would say).

    Now, things go wrong with no debug-able errors from runtime environment

    W armeabi-v7a.so: QObject::setParent: Cannot set parent, new parent is in a different thread
    E DecorView: mWindow.mActivityCurrentConfig is null
    

    Code:

    void CTools::showNotification(QString title, QString msg, eNotificationType::eNotificationType eType)
    {
        QMessageBox msgBox;
        msgBox.setStandardButtons(QMessageBox::Ok);
        msgBox.setText(title);
        msgBox.setInformativeText(msg);
        switch(eType)
        {
        case eNotificationType::success:
            msgBox.setIconPixmap(QPixmap("qrc:/success.png"));
            break;
        case eNotificationType::warning:
              msgBox.setIconPixmap(QPixmap("qrc:/warning.png"));
            break;
        case eNotificationType::notification:
              msgBox.setIconPixmap(QPixmap("qrc:/info.png"));
            break;
        }
    
        msgBox.show();
    }
    

    Then the QMessageBox does open (without the instructed icon) followed by a sequence of segmentation faults. Of course we haven't spawned any thread at all besides the main one. Ideas?

    jsulmJ 1 Reply Last reply
    0
    • V Vega4

      Scenario: There's a full-screen custom QDialog in place, now the dialog sends a Signal to back-end causing the back-end to open-up a QMessageBox (sort of a typical situation I would say).

      Now, things go wrong with no debug-able errors from runtime environment

      W armeabi-v7a.so: QObject::setParent: Cannot set parent, new parent is in a different thread
      E DecorView: mWindow.mActivityCurrentConfig is null
      

      Code:

      void CTools::showNotification(QString title, QString msg, eNotificationType::eNotificationType eType)
      {
          QMessageBox msgBox;
          msgBox.setStandardButtons(QMessageBox::Ok);
          msgBox.setText(title);
          msgBox.setInformativeText(msg);
          switch(eType)
          {
          case eNotificationType::success:
              msgBox.setIconPixmap(QPixmap("qrc:/success.png"));
              break;
          case eNotificationType::warning:
                msgBox.setIconPixmap(QPixmap("qrc:/warning.png"));
              break;
          case eNotificationType::notification:
                msgBox.setIconPixmap(QPixmap("qrc:/info.png"));
              break;
          }
      
          msgBox.show();
      }
      

      Then the QMessageBox does open (without the instructed icon) followed by a sequence of segmentation faults. Of course we haven't spawned any thread at all besides the main one. Ideas?

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

      @Vega4 said in Exception after QMessageBox opened from C++ when another full-screen QDialog opened (android):

      msgBox.show();

      Your msgBox is a local variable and show() is a non blocking call, so msgBox will disappear just after msgBox.show().
      Either allocate the dialog on the heap or use exec().

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

      V 1 Reply Last reply
      1
      • V Offline
        V Offline
        Vega4
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • jsulmJ jsulm

          @Vega4 said in Exception after QMessageBox opened from C++ when another full-screen QDialog opened (android):

          msgBox.show();

          Your msgBox is a local variable and show() is a non blocking call, so msgBox will disappear just after msgBox.show().
          Either allocate the dialog on the heap or use exec().

          V Offline
          V Offline
          Vega4
          wrote on last edited by Vega4
          #4

          @jsulm I got to know that in fact it was not setParent(0) that fixed the issue but usage of .exec() indeed. Now that makes 100% sense, QMessageBox allocated on stack, it got deleted. Now I got into conclusions too soon on that one. It works. The icon is not set but we'll live with that for now.

          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