Qt-interest Archive, May 2008
Re: Constructing a QPixmap in main ()after QApplication is constructed fails
Message 1 in thread
Hi,
> This code
> [...]
> results in
>
> ASSERT failure in QVector<T>::operator[]: "index out of range",
> file ../../include/QtCore/../../src/corelib/tools/qvector.h, line 324
> Aborted
>
> and is due to construction of the QPixmap (I have simply added this
> line to one of the Qt4 examples "examples/mainwindows/application")
>
> This is Qt 4.3.4( Ubuntu Hardy Heron)
>
> What's going on ?
Something could be wrong with the XPM, for example it could declare a size of
16x16 but not provide 16 lines of 16 pixels.
The following example works for me:
#include <QApplication>
#include <QLabel>
static const char* const file_xpm[]={
"16 16 5 1",
". c #7f7f7f",
"# c None",
"c c #000000",
"b c #bfbfbf",
"a c #ffffff",
"################",
"..........######",
".aaaaaaaab.#####",
".aaaaaaaaba.####",
".aaaaaaaacccc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".bbbbbbbbbbbc###",
"ccccccccccccc###"};
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QPixmap pm(file_xpm);
QLabel window;
window.show();
return app.exec();
}
Can you modify it to reproduce the crash?
--
[ signature omitted ]