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

QVariant cause Access Violation after resume it value to pointer to class method

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 6.0.0
    • Core: Other
    • None
    • Windows

    Description

      namespace Ui {
      class Form;
      }
      class Form : public QWidget {
          Q_OBJECT
      private:
          void (*CallbackFunc)(QVariantMap*);public:    explicit Form(QWidget *parent = nullptr);    ~Form();
      signals:
          void Process(QVariantMap msg);
      private slots:
          void on_pushButton_clicked();
      private:
          Ui::Form *ui;
      };
      
      typedef void (Form::*FormFuncType)(void);
      Q_DECLARE_METATYPE(FormFuncType)
      
      class AppThread : public QThread {
          Q_OBJECT
      
      private:
          int argc;
          char ** argv;
          QApplication *app;    
      public:
          Form *window;
          explicit AppThread(QObject *parent = nullptr);
          ~AppThread();
      private slots:
          void onReceive(QVariantMap msg);
      };
      
      
      void AppThread::onReceive(QVariantMap msg)
      {
      // Here is ERROR!!!
          FormFuncType func = msg.value("window").value<FormFuncType>();
          if (func) (window->*func)();
      
      // But if I do below - It Works:
          FormFuncType func = &Form::activateWindow;
          if (func) (window->*func)();
      }
      
      
      
      // i call this function before any connections:
          qRegisterMetaType<FormFuncType>("FormFuncType");
      
      
          QVariantMap msg;
       // I try some variations code:
       // msg.insert("window", &Form::activateWindow);
       // msg.insert("window",   QVariant::fromValue((FormFuncType)&Form::activateWindow));
         msg.insert("window", (FormFuncType)&Form::activateWindow);
       // signal Receive(QVariantMap msg) connected to slot onReceive(QVariantMap msg):
         emit Receive(msg)
      
      

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            geniuser Evgeny Glukhovsky
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes