Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.3.0, 5.3.1
-
None
-
VS 2013, gcc
-
b0d0a2680afffe02713ee4110c7996ee423c1d1e
Description
Looking into the documentation this seems to be intended.
But it's extremely dangerous and quite unpredictable.
The behavior also seems to be compiler dependent!
Asume that you have a function that returns a QImage. "test.png" is RGBA8888 but has no transparent pixels. The format could be RGB888 but is set to RGBA8888
static QImage getImage() { static QImage img; if(img.isNull()) { img = QImage("test.png"); img.setFormat(Qt::RGBA8888); } return img; }
The following code does not change the value of the static "img":
void test1() { QImage image = getImage(); QPixmap pixmap = QPixmap::fromImage(imgage); }
This code changes the value of the static "img":
void test2() { QPixmap pixmap = QPixmap::fromImage(getImage()); }
At least when compiled with Visual Studio.
It seems that gcc does not change the value of "img".
Please do not create functions that behave compiler dependent and are completely unpredictable!