views:

50

answers:

2

this generates a segmentation fault becuase of "QColor colorMap[9]";. If I remove colorMap the segmentation fault goes away. If I put it back. It comes back. If I do a clean all then build all, it goes away. If I increase its arraysize it comes back. On the other hand if I reduce it it doesnt come back. I tired adding this array to another project and

What could be happening. I am really curious to know. I have removed everything else in that class. This widget subclassed is used to promote a widget in a QMainWindow.

class LevelIndicator : public QWidget  
{  
public:  
    LevelIndicator(QWidget * parent);  
    void paintEvent(QPaintEvent * event );  
    float percent;  
    QColor colorMap[9];  
    int NUM_GRADS;  
};  

the error happens inside ui_mainwindow.h at one of these lines:

    hpaFwdPwrLvl->setObjectName(QString::fromUtf8("hpaFwdPwrLvl"));

    verticalLayout->addWidget(hpaFwdPwrLvl);

I know i am not providing much but I will give alink to the app. Im trying to see if anyone has a quick answer for this.

+2  A: 

Firstly it might not be QColor, that may simply be changing the memory layout enough that a buffer overrun somewhere else triggers a segfault - try a different size QColor ..[1] for example.

Can QColor be used as an array like this, does it have the correct default ctor?

Martin Beckett
ill check it out
yan bellavance
+3  A: 

If I do a clean all then build all, it goes away.

This makes it sound as though your build system isn't recognizing a dependency and that a change to that class definition isn't triggering a rebuild of something that should be recompiled when the definition changes.

Make sure class LevelIndicator is defined in exactly one place (generally that would be a header file that gets included by whatever modules need to use a LevelIndicator object). Also make sure that any global/static instances of LevelIndicator objects are following the one definition rule.

Michael Burr
You're correct. `qmake` doesn't always correctly propagate changes in headers through the rest of the build system.
Kaleb Pederson
thx for the tips
yan bellavance