Hey folks,
I was misunderstanding the concept of heap and stack variables. I have made:
engine.addImageProvider("pictures", new ImageProvider());
The problem is now solved!
Thanks for your help!
Regards,
Nuno
> On 25 Jul 2018, at 12:35, Nuno Santos wrote:
>
> Sérgio,
>
> Thanks for your r
you still have a double delete in this case. A first delete when
QQmlApplicationEngine is destroyed at the end of the main, and a second
delete when the static is deleted.
---
Jean-Michaël Celerier
http://www.jcelerier.name
On Wed, Jul 25, 2018 at 1:35 PM, Nuno Santos
wrote:
> Sérgio,
>
>
Sérgio,
Thanks for your reply.
I have tried the following:
ImageProvider imageProvider;
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
Controller controller;
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("controller", &controller)
Hi Nuno,
The docs for QQmlEngine::addImageProvider() say: "The QQmlEngine takes
ownership of provider".
So QQmlEngine::removeImageProvider() is calling free() on stack
variable, hence it complains that address wasn't heap allocated.
Create it on the heap as suggested by Jean-Michaël.
Reg
> Hi Jean,
>
> From: Nuno Santos <mailto:nunosan...@imaginando.pt>>
> To: Jean-Michaël Celerier <mailto:jeanmichael.celer...@gmail.com>>
> Cc: Qt Project MailingList <mailto:interest@qt-project.org>>
> Sent: 7/25/2018 12:59 PM
> Subject: Re:
Hi Jean,
From: Nuno Santos
To: Jean-Michaël Celerier
Cc: Qt Project MailingList
Sent: 7/25/2018 12:59 PM
Subject: Re: [Interest] App crashing because of ImageProvider when exiting
Jean,
This is the main context. It will not get out until app.exec() terminates
Jean,
This is the main context. It will not get out until app.exec() terminates.
That’s why I’m connecting to aboutToQuit signal in order to remove the provider
from the Qml engine.
I had the provider instantiated inside the controller but I was having this
problem already, therefore my effor
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
---
Jean-Michaël Celerier
http://www.jcelerier.name
On Wed, Jul 25, 2018 at 11:24 AM, Nuno Santos
wrote:
> Hi,
>
> Yes
Hi,
Yesterday I have used for the first time a QQuickImageProvider but I’m having
problems because now the app crashes when I terminate it.
Tried to do the following in order to avoid the crash but it is crashing anyway:
ImageProvider imageProvider;
engine.addImageProvider("pictures", &imagePro