Details

[Home]

Issue of the Implementation # S0718

Brief

Incorrect interaction of QGLColormap::size() const and QGLColormap::setEntry(int, unsigned int) functions in Qt4 library

Detailed Description

According to documentation the example of use for functions QGLColormap::size() const and QGLColormap::setEntry(int, unsigned int) is as follows:

...
QGLColormap colormap;
...
for (int i = 0; i < colormap.size(); i++)
         colormap.setEntry(i, qRgb(i, i, i));
...
Color map size, returned by QGLColormap::size() const, is increased by 1 after each QGLColormap::setEntry(int, unsigned int) call. Hence, if the colormap is empty before the cycle, the program does not enter to the cycle at all, and if the colormap is nonempty it enters to the infinite cycle.

Problem location(s) in the standard

http://doc.trolltech.com/4.5/qglcolormap.html#details

Example

#include <QGLColormap>
int main()
{
	QGLColormap colormap;
	colormap.setEntry(0, qRgb(0, 0, 0));
	//INFINITE CYCLE
	for (int i = 0; i < colormap.size(); i++)
            colormap.setEntry(i, qRgb(i, i, i));
	return 0;
}

Component

qt4 4.2 or later

Accepted

Qt Software Task Tracker 244151, 244442

[Home]