<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Martin,<div class=""><br class=""></div><div class="">Thanks for your reply. </div><div class=""><br class=""></div><div class="">But I still can’t understand how to fix the crash related with the provider destruction. </div><div class=""><br class=""></div><div class="">It seems that someone is trying to delete an already deleted pointer and therefore the crash.</div><div class=""><br class=""></div><div class="">Regards,</div><div class=""><br class=""></div><div class="">Nuno<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 25 Jul 2018, at 12:15, Martin Leutelt <<a href="mailto:martin.leutelt@basyskom.com" class="">martin.leutelt@basyskom.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Hi Jean,</span><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class=""></div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class=""><strong class="">From:<span class="Apple-converted-space"> </span></strong>Nuno Santos <<a href="mailto:nunosantos@imaginando.pt" class="">nunosantos@imaginando.pt</a>><span class="Apple-converted-space"> </span><br class=""><strong class="">To:<span class="Apple-converted-space"> </span></strong>Jean-Michaël Celerier <<a href="mailto:jeanmichael.celerier@gmail.com" class="">jeanmichael.celerier@gmail.com</a>><span class="Apple-converted-space"> </span><br class=""><strong class="">Cc:<span class="Apple-converted-space"> </span></strong>Qt Project MailingList <<a href="mailto:interest@qt-project.org" class="">interest@qt-project.org</a>><span class="Apple-converted-space"> </span><br class=""><strong class="">Sent:<span class="Apple-converted-space"> </span></strong>7/25/2018 12:59 PM<span class="Apple-converted-space"> </span><br class=""><strong class="">Subject:<span class="Apple-converted-space"> </span></strong>Re: [Interest] App crashing because of ImageProvider when exiting<span class="Apple-converted-space"> </span><br class=""><br class=""><blockquote class="mori" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="mcnt" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Jean,<div class="mcnt"><br class="mcnt"></div><div class="mcnt">This is the main context. It will not get out until app.exec() terminates.</div><div class="mcnt"><br class="mcnt"></div><div class="mcnt">That’s why I’m connecting to aboutToQuit signal in order to remove the provider from the Qml engine. </div></div></blockquote></div></div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class=""></div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Since the engine takes ownership you don't need to remove the image provider in your case, since you're not adding/removing providers dynamically during runtime.</div><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class=""><blockquote class="mori" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="mcnt" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div class="mcnt"></div><div class="mcnt"><br class="mcnt"></div><div class="mcnt">I had the provider instantiated inside the controller but I was having this problem already, therefore my efforts in getting it fixed.</div><div class="mcnt"><br class="mcnt"></div><div class="mcnt"><div class="mcnt"><b class="mcnt">QQmlApplicationEngine *e;</b></div><div class="mcnt"><b class="mcnt"><br class="mcnt"></b></div><div class="mcnt"><b class="mcnt">int main(int argc, char *argv[])</b></div><div class="mcnt"><b class="mcnt">{</b></div><div class="mcnt"><b class="mcnt">    QGuiApplication app(argc, argv);</b></div><div class="mcnt"><b class="mcnt"><br class="mcnt"></b></div><div class="mcnt"><b class="mcnt">    Controller controller;</b></div><div class="mcnt"><b class="mcnt"><br class="mcnt"></b></div><div class="mcnt"><b class="mcnt">    QQmlApplicationEngine engine;</b></div><div class="mcnt"><b class="mcnt"><br class="mcnt"></b></div><div class="mcnt"><b class="mcnt">    e = &engine;</b></div><div class="mcnt"><b class="mcnt"><br class="mcnt"></b></div><div class="mcnt"><b class="mcnt">    engine.rootContext()->setContextProperty("controller", &controller);</b></div><div class="mcnt"><b class="mcnt">    engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));</b></div><div class="mcnt"><b class="mcnt"><br class="mcnt"></b></div><div class="mcnt"><b class="mcnt">    ImageProvider imageProvider;</b></div><div class="mcnt"><b class="mcnt">    engine.addImageProvider("pictures", &imageProvider);</b></div><div class="mcnt"><b class="mcnt"><br class="mcnt"></b></div><div class="mcnt"><b class="mcnt">    QObject::connect(&app, &QGuiApplication::aboutToQuit, [=]()</b></div><div class="mcnt"><b class="mcnt">    {</b></div><div class="mcnt"><b class="mcnt">        e->removeImageProvider("pictures");</b></div><div class="mcnt"><b class="mcnt">    });</b></div><div class="mcnt"><b class="mcnt"><br class="mcnt"></b></div><div class="mcnt"><b class="mcnt">    return app.exec();</b></div><div class="mcnt"><b class="mcnt">}</b></div></div><div class="mcnt"><br class="mcnt"></div><div class="mcnt">Any ideas?</div><div class="mcnt"><br class="mcnt"></div><div class="mcnt">Regards,</div><div class="mcnt"><br class="mcnt"></div><div class="mcnt">Nuno</div><div class="mcnt"><div class=""><br class="mcnt"><blockquote type="cite" class="mcnt"><div class="mcnt">On 25 Jul 2018, at 11:30, Jean-Michaël Celerier <<a href="mailto:jeanmichael.celerier@gmail.com" class="mailto" title="Send email to jeanmichael.celerier@gmail.com" target="_blank">jeanmichael.celerier@gmail.com</a>> wrote:</div><br class="mcntApple-interchange-newline"><div class="mcnt"><div class="mcnt">Shouldn't you allocate your ImageProvider on the heap or at least ensure that it survives during the whole execution ? here it will be deleted by the end of your function<br class="mcnt"></div><div class="mcntgmail_extra"><br clear="all" class="mcnt"><div class="mcnt"><div class="mcntgmail_signature"><div class="mcnt"><div class="mcnt"><br class="mcnt"></div><div class="mcnt"><font color="#783f04" class="mcnt"><br class="mcnt"></font></div><div class="mcnt"><font face="arial, helvetica, sans-serif" size="2" color="#134f5c" class="mcnt">-------</font></div><font face="arial, helvetica, sans-serif" size="2" color="#134f5c" class="mcnt">Jean-Michaël Celerier</font><div class="mcnt"><font face="arial, helvetica, sans-serif" size="2" color="#134f5c" class="mcnt"><a href="http://www.jcelerier.name/" target="_blank" class="mcnt">http://www.jcelerier.name</a></font></div></div></div></div><br class="mcnt"><div class="mcntgmail_quote">On Wed, Jul 25, 2018 at 11:24 AM, Nuno Santos<span class="Apple-converted-space"> </span><span class="mcnt"><<a href="mailto:nunosantos@imaginando.pt" target="_blank" class="mailto" title="Send email to nunosantos@imaginando.pt">nunosantos@imaginando.pt</a>></span><span class="Apple-converted-space"> </span>wrote:<br class="mcnt"><blockquote class="mcntgmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="mcnt" style="word-wrap: break-word; line-break: after-white-space;">Hi,<div class="mcnt"><br class="mcnt"></div><div class="mcnt">Yesterday I have used for the first time a QQuickImageProvider but I’m having problems because now the app crashes when I terminate it.</div><div class="mcnt"><br class="mcnt"></div><div class="mcnt">Tried to do the following in order to avoid the crash but it is crashing anyway:</div><div class="mcnt"><br class="mcnt"></div><div class="mcnt"><div class="mcnt">ImageProvider imageProvider;</div><div class="mcnt">engine.addImageProvider("pictures", &imageProvider);</div><div class="mcnt"><br class="mcnt"></div><div class="mcnt">QObject::connect(&app, &QGuiApplication::aboutToQuit, [=]()</div><div class="mcnt">{</div><div class="mcnt">    e->removeImageProvider("pictures");</div><div class="mcnt">});</div></div><div class="mcnt"><br class="mcnt"></div><div class="mcnt">The crash is always something like this:</div><div class="mcnt"><br class="mcnt"></div><div class="mcnt"><div class="mcnt" style="margin: 0px;"><span class="mcnt" style="color: rgb(170, 0, 0);">malloc: *** error for object 0x7ffeef34e900: pointer being freed was not allocated</span></div></div><div class="mcnt"><br class="mcnt"></div><div class="mcnt">Does anyone knows how to fix this?</div><div class="mcnt"><br class="mcnt"></div><div class="mcnt">Thanks!</div><div class="mcnt"><br class="mcnt"></div><div class="mcnt">Regards,</div><div class="mcnt"><br class="mcnt"></div><div class="mcnt">Nuno</div><div class="mcnt"><br class="mcnt"></div></div><br class="mcnt">_______________________________________________<br class="mcnt">Interest mailing list<br class="mcnt"><a href="mailto:Interest@qt-project.org" class="mailto" title="Send email to Interest@qt-project.org" target="_blank">Interest@qt-project.org</a><br class="mcnt"><a href="http://lists.qt-project.org/mailman/listinfo/interest" target="_blank" class="mcnt">http://lists.qt-project.org/mailman/listinfo/interest</a><br class="mcnt"><br class="mcnt"></blockquote></div><br class="mcnt"></div></div></blockquote></div><br class="mcnt"></div></div><br class=""><br class="">_______________________________________________<span class="Apple-converted-space"> </span><br class="">Interest mailing list<span class="Apple-converted-space"> </span><br class=""><a href="mailto:Interest@qt-project.org" class="">Interest@qt-project.org</a><span class="Apple-converted-space"> </span><br class=""><a href="http://lists.qt-project.org/mailman/listinfo/interest" class="">http://lists.qt-project.org/mailman/listinfo/interest</a><span class="Apple-converted-space"> </span><br class=""></blockquote></div></div><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Interest mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><a href="mailto:Interest@qt-project.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">Interest@qt-project.org</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><a href="http://lists.qt-project.org/mailman/listinfo/interest" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">http://lists.qt-project.org/mailman/listinfo/interest</a></div></blockquote></div><br class=""></div></body></html>