<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi,</p>
    <p>Processing algorithms run often in background threads. That's
      likely why you are getting a crash, it's not safe to call UI
      functions from background threads.</p>
    <p>It's possible to</p>
    <p> - run the processing algorithm with a custom
      QgsProcessingFeedback implementation<br>
    </p>
    <p> - make sure that pushInfo etc. is first sent to the main thread
      as a signal and executed there</p>
    <p> - return the QgsProcessingAlgorithm.FlagNoThreading from your
      algorithms flags() method</p>
    <p> - or consider sticking to the way that processing has been
      designed for</p>
    <p>Regards</p>
    <p>Matthias<br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 07/09/2018 02:14 PM, Jean-Baptiste
      Desbas wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAJJa5yC=qBRSZ0kWB1SYWn3F8gcHz5HefmqGMpou3FGjS+dhyA@mail.gmail.com">
      <div dir="auto"><br>
        <span style="font-family:sans-serif;font-size:12.8px">Hi,</span>
        <div dir="auto" style="font-family:sans-serif;font-size:12.8px"><br>
        </div>
        <div dir="auto" style="font-family:sans-serif;font-size:12.8px">I
          just want to display a messageBar instead of displaying it un
          the processing output console (feedback.pushInfo) It's ni big
          deal but i was just confused.</div>
        <div dir="auto" style="font-family:sans-serif;font-size:12.8px"><br>
        </div>
        <div dir="auto" style="font-family:sans-serif;font-size:12.8px">Do
          toi have any tips of use case of the differents pushInfo,
          pushConsoleInfo, etc. ?</div>
        <div dir="auto" style="font-family:sans-serif;font-size:12.8px"><br>
        </div>
        <div dir="auto" style="font-family:sans-serif;font-size:12.8px">Thanks</div>
        <br>
        <div class="gmail_quote" dir="auto">
          <div dir="ltr">Le lun. 9 juil. 2018 19:18, Matthias Kuhn <<a
              href="mailto:matthias@opengis.ch" moz-do-not-send="true">matthias@opengis.ch</a>>
            a écrit :<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div text="#000000" bgcolor="#FFFFFF">
              <p>Hi,</p>
              <p>can you elaborate why you need access to iface? In most
                cases there are different ways that help you keep the
                algorithm modular and portable by specifying required
                components via parameters or acquiring them from the
                processing context.</p>
              <p>Best regards</p>
              <p>Matthias<br>
              </p>
              <br>
              <div class="m_-6297671294293076627moz-cite-prefix">On
                07/09/2018 09:58 AM, Jean-Baptiste Desbas wrote:<br>
              </div>
              <blockquote type="cite">
                <div dir="ltr">
                  <div>Hello,</div>
                  <div><br>
                  </div>
                  <div>What is the proper way to access iface in a
                    processing alg ?</div>
                  <div><br>
                  </div>
                  <div>I try "from qgis.utils import iface" but it crash
                    when i make an iface.pushWarning.</div>
                  <div><br>
                  </div>
                  <div>Thanks,</div>
                  <div><br>
                  </div>
                  <div>Here is the stack trace : <br>
                  </div>
                  <div><br>
                  </div>
                  <div><br>
                  </div>
                  <div><br>
                    <br>
                    *Crash ID*: 59968a8cbec4e3d98bbe532ada707149cd7f9eee<br>
                    <br>
                    <br>
                    *Stack Trace*<br>
                    <pre><br>
                    QgsCustomization::preNotify :<br>
                    QObject::event :<br>
                    QApplicationPrivate::notify_helper :<br>
                    QApplication::notify :<br>
                    QgsApplication::notify :<br>
                    QCoreApplication::notifyInternal2 :<br>
                    QCoreApplicationPrivate::sendPostedEvents :<br>
                    qt_plugin_query_metadata :<br>
                    QEventDispatcherWin32::processEvents :<br>
                    CallWindowProcW :<br>
                    DispatchMessageW :<br>
                    QEventDispatcherWin32::processEvents :<br>
                    qt_plugin_query_metadata :<br>
                    QEventLoop::exec :<br>
                    QDialog::exec :<br>
                    PyCFunction_FastCallDict :<br>
                    PyObject_GenericGetAttr :<br>
                    PyEval_EvalFrameDefault :<br>
                    PyFunction_FastCallDict :<br>
                    PyObject_CallFunctionObjArgs :<br>
                    PyObject_Call :<br>
                    PyInit_QtCore :<br>
                    PyInit_QtCore :<br>
                    PyInit_QtCore :<br>
                    PyInit_QtCore :<br>
                    PyInit_QtCore :<br>
                    QMetaObject::activate :<br>
                    QAbstractItemView::doubleClicked :<br>
                    QTreeView::mouseDoubleClickEvent :<br>
                    QWidget::event :<br>
                    QFrame::event :<br>
                    QAbstractItemView::viewportEvent :<br>
QCoreApplicationPrivate::sendThroughObjectEventFilters :<br>
                    QApplicationPrivate::notify_helper :<br>
                    QApplication::notify :<br>
                    QgsApplication::notify :<br>
                    QCoreApplication::notifyInternal2 :<br>
                    QApplicationPrivate::sendMouseEvent :<br>
                    QSizePolicy::QSizePolicy :<br>
                    QSizePolicy::QSizePolicy :<br>
                    QApplicationPrivate::notify_helper :<br>
                    QApplication::notify :<br>
                    QgsApplication::notify :<br>
                    QCoreApplication::notifyInternal2 :<br>
                    QGuiApplicationPrivate::processMouseEvent :<br>
                    QWindowSystemInterface::sendWindowSystemEvents :<br>
                    QEventDispatcherWin32::processEvents :<br>
                    CallWindowProcW :<br>
                    DispatchMessageW :<br>
                    QEventDispatcherWin32::processEvents :<br>
                    qt_plugin_query_metadata :<br>
                    QEventLoop::exec :<br>
                    QCoreApplication::exec :<br>
                    main :<br>
                    BaseThreadInitThunk :<br>
                    RtlUserThreadStart :<br>
                    </pre><br>
                    <br>
                    <br>
                    *QGIS Info*<br>
                    QGIS Version: 3.2.0-Bonn<br>
                    QGIS code revision: commit:bc43194061<br>
                    Compiled against Qt: 5.9.2<br>
                    Running against Qt: 5.9.2<br>
                    Compiled against GDAL: 2.2.4<br>
                    Running against GDAL: 2.2.4<br>
                    <br>
                    <br>
                    <br>
                    *System Info*<br>
                    CPU Type: x86_64<br>
                    Kernel Type: winnt<br>
                    Kernel Version: 10.0.17134<br>
                    <br>
                  </div>
                </div>
                <br>
                <fieldset
                  class="m_-6297671294293076627mimeAttachmentHeader"></fieldset>
                <br>
                <pre>_______________________________________________
Qgis-user mailing list
<a class="m_-6297671294293076627moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org" target="_blank" rel="noreferrer" moz-do-not-send="true">Qgis-user@lists.osgeo.org</a>
List info: <a class="m_-6297671294293076627moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank" rel="noreferrer" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a>
Unsubscribe: <a class="m_-6297671294293076627moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank" rel="noreferrer" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
              </blockquote>
              <br>
              <div class="m_-6297671294293076627moz-signature">-- <br>
                <div class="m_-6297671294293076627moz-signature">
                  <div class="m_-6297671294293076627moz-signature"> <span
style="text-align:left;color:#000000;font-family:'Verdana',sans-serif;font-size:10pt">Matthias
                      Kuhn</span><br>
                    <a href="mailto:matthias@opengis.ch" target="_blank"
                      rel="noreferrer" moz-do-not-send="true"> <span
style="text-align:left;color:#000000;font-family:'Verdana',sans-serif;font-size:8pt">matthias@opengis.ch</span>
                    </a><br>
                    <span
style="text-align:left;color:#000000;font-family:'Verdana',sans-serif;font-size:8pt"><a
                        href="tel:+41764356763" target="_blank"
                        rel="noreferrer" moz-do-not-send="true">+41
                        (0)76 435 67 63</a></span><br>
                    <div> <a href="http://www.opengis.ch"
                        target="_blank" rel="noreferrer"
                        moz-do-not-send="true"> <img
                          src="cid:part3.0FCD1365.B6FD06EB@opengis.ch"
                          alt="OPENGIS.ch Logo" moz-do-not-send="true"
                          width="200" height="80"></a> </div>
                  </div>
                </div>
              </div>
            </div>
            _______________________________________________<br>
            Qgis-user mailing list<br>
            <a href="mailto:Qgis-user@lists.osgeo.org" target="_blank"
              rel="noreferrer" moz-do-not-send="true">Qgis-user@lists.osgeo.org</a><br>
            List info: <a
              href="https://lists.osgeo.org/mailman/listinfo/qgis-user"
              rel="noreferrer noreferrer" target="_blank"
              moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
            Unsubscribe: <a
              href="https://lists.osgeo.org/mailman/listinfo/qgis-user"
              rel="noreferrer noreferrer" target="_blank"
              moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></blockquote>
        </div>
      </div>
      <!--'"--><br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Qgis-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-user">https://lists.osgeo.org/mailman/listinfo/qgis-user</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-user">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
    </blockquote>
    <br>
    <div class="moz-signature">-- <br>
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      <div class="moz-signature">
        <title></title>
        <div class="moz-signature"> <span style="text-align: left;
            color: #000000; font-family: 'Verdana', sans-serif;
            font-size: 10pt">Matthias Kuhn</span><br>
          <a href="mailto:matthias@opengis.ch" target="_blank"> <span
              style="text-align: left; color: #000000; font-family:
              'Verdana', sans-serif; font-size: 8pt">matthias@opengis.ch</span>
          </a><br>
          <span style="text-align: left; color: #000000; font-family:
            'Verdana', sans-serif; font-size: 8pt"><a
              href="tel:+41764356763">+41 (0)76 435 67 63</a></span><br>
          <div> <a href="http://www.opengis.ch"> <img
                moz-do-not-send="false"
                src="cid:part14.FA383C68.DED579CB@opengis.ch"
                alt="OPENGIS.ch Logo" width="200" height="80"></a> </div>
        </div>
      </div>
    </div>
  </body>
</html>