@mrjj It goes like this :
Ctor connects a pushbutton click with QtDice::reload which in turn calls QtDice::image_update to animate the gif and after it's finished, show an image.
I found out what the problem is. QtDice::image_update is called multiple times and therefore it tries to setFileName every time. So a check if fileName() is empty must be done each time before attempting to setFileName.
void QtDice::image_update(int image_number)
{
//Make sure we don't constantly re-append a fileName!
if(movie->fileName() == "" )
{
movie->setFileName(":/images/rolling_infinite.gif");
//If it still is empty print error and exit. Not good at all
//TODO wrap the setFileName in some Qt assert to throw an exception
if (movie->fileName() == "")
{
qDebug() << "Error! Couldn't set a fileName to read for the animation";
QApplication::quit();
}
}
m_ui->label->setMovie(movie);
.....
}
I don't know exactly why this failed ( I mean I could change the fileName as many times as I like), but I checked and rechecked that with this if (movie->fileName() == "" ).... the animation works.
That could also explain why some (but not all) times the animation played the very first time I push the button (ie called the function) and the second time it stopped. If someone thinks that other reasons come into play, please inform me, I am more than glad to learn.
For any of you, that is curious what is the code and/or want to c&c, this is the QtDice and this is a screenshot
Have a nice afternoon!