Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2635

Official OpcUa Viewer Example does not run out-of-the-box

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.6.3, 6.5.6
    • 6.6.2
    • Documentation
    • None
    • b4642eda1e2481822f9a77f02208d4ba77202cc3, 5f8089693 (tqtc/dev), 9bec8a7ef (tqtc/6.6), e2580959d (tqtc/dev), d97ca0f9f (tqtc/6.5), f44feadc6 (tqtc/6.6), e138c01bd (tqtc/dev), 62123a34f (tqtc/6.6), 557731e5c (tqtc/6.5), 625f3c693 (tqtc/dev)

    Description

      See https://doc.qt.io/qtforpython-6/examples/example_opcua_opcuaviewer.html

       

      Problem 1: Undefined variable

      Traceback (most recent call last):
        File "D:\QtSupport\opcuaviewer\mainwindow.py", line 142, in findServers
          self.createClient()
        File "D:\QtSupport\opcuaviewer\mainwindow.py", line 115, in createClient
          QMessageBox.critical(self,  "Failed to connect to server", message)
      NameError: name 'message' is not defined
      Traceback (most recent call last):
        File "D:\QtSupport\opcuaviewer\mainwindow.py", line 142, in findServers
          self.createClient()
        File "D:\QtSupport\opcuaviewer\mainwindow.py", line 115, in createClient
          QMessageBox.critical(self,  "Failed to connect to server", message)
      NameError: name 'message' is not defined
      

       

      Original C++ code

      void MainWindow::createClient()
      {
          if (mOpcUaClient == nullptr) {
              mOpcUaClient = mOpcUaProvider->createClient(ui->opcUaPlugin->currentText());
              if (!mOpcUaClient) {
                  const QString message(tr("Connecting to the given sever failed. See the log for details."));
                  log(message, QString(), Qt::red);
                  QMessageBox::critical(this, tr("Failed to connect to server"), message);
                  return;
              }
              // ...
          }
      }
      

       

      Python code

          def createClient(self):
              if not self._opcua_client:
                  self._opcua_client = self.mOpcUaProvider.createClient(self._ui.opcUaPlugin.currentText())
              if not self._opcua_client:
                  qWarning("Connecting to the given server failed. See the log for details.")
                  QMessageBox.critical(self,  "Failed to connect to server", message)
                  return
      
              # ...
      

       

      Problem 2: Crash

      Steps to reproduce

      1. Fix the undefined variable above
      2. Ensure that OpenSSL is available in the PATH (required to load the "open62541" plugin)
      3. Run the example and click "Find servers"

      The program will soon crash, regardless of whether or not an OPC UA server is running on the local machine.

       

      Note: The C++ version of the example doesn't crash using Qt 6.6.2: It fails gracefully when no server is available, and connects successfully to the server when it is available.

      Attachments

        Issue Links

          For Gerrit Dashboard: PYSIDE-2635
          # Subject Branch Project Status CR V

          Activity

            People

              kleint Friedemann Kleint
              skoh-qt Sze Howe Koh
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: