PDA

View Full Version : QDialog crashing problem (Header)



boro_11
8th April 2016, 19:47
I have a problem with following code...


#ifndef SIGNALSETTINGS_H
#define SIGNALSETTINGS_H

#include <QDialog>
#include "signalfile.h"
#include <QLabel>
#include <QLineEdit>
#include <QCheckBox>

struct SignalProperties{
int signalHeight;
int verticalPosition;
int slotNumber;
bool isVisible;
QColor bgColour;
QColor signalColour;
QColor fillColour;
int signalThicness;
bool showAsAnalog;
Signal *signal; //Pointer to signal
};


class SignalSettings : public QDialog
{
Q_OBJECT

public:
explicit SignalSettings(SignalProperties *p, QWidget *parent = 0);
void paintEvent(QPaintEvent *event);
~SignalSettings();



private:
SignalProperties *properties;

QLabel *labelFGColour;
QLabel *labelBGColour;
QLineEdit *inputHeight;

int krneki; // <------ Problem, works great without this line but but program crashes with this line of code.


signals:
void signalPropertiesChanged();

public slots:
void onBGButtonClicked();
void onFGButtonClicked();
void onShowHide(int state);
void onSignalHeightChange();
};

#endif // SIGNALSETTINGS_H


I have a custom QDialog widget, and it worked great. Now I want to save some integer and if I write the int in header, program sometimes (not always) crashes when QDialog (SignalSettings) should open...

Any ideas why it works without that line and why not when I include it in my code?

This is my first post so I say Hi to you all :D

Added after 13 minutes:

Amm ok above code actualy works ok, but if I put integer between pointers as below, than it crashes quiet often.

this code crashes:


private:
SignalProperties *properties;
int krneki; //<---- if integer between pointers than code irregulary crashes
QLabel *labelFGColour;
QLabel *labelBGColour;
QLineEdit *inputHeight;

anda_skoa
8th April 2016, 21:35
You need to have a problem elsewhere.

What is the stacktrace at the time of the crash?

Cheers,
_

boro_11
21st April 2016, 07:45
You need to have a problem elsewhere.

What is the stacktrace at the time of the crash?

Cheers,
_

Sorry for late reply,

If I run it in DEBUGING mode, it never stops with error. No matter how many times I open that dialog, I get error the second or third time if I compile in release mode and I never get an error if I compile with debug mode...

What would be the difference between those two modes?

I will trie to compile on linux box to see if there is any difference there.