Adding new variable into header file breaks my application
Hi, I have this issue. I have header file which looks like this:
Code:
#ifndef CARDMANAGERMD_H
#define CARDMANAGERMD_H
#ifdef __APPLE__
#define IMG_PATH "/Applications/Card Manager EIDCze.app/Contents/Resources/"
#elif __unix
#define IMG_PATH "/usr/local/share/crplus-cm-eidcze/"
#endif
#include <QtGui>
#include "pkcs11manipulatorMD.h"
#include "messages.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QTranslator>
#include <QListData>
#include <QWebView>
#include <QHostInfo>
#include <stdlib.h>
#define H_SPRAVCE 0
#define H_READER 1
#define H_CARD 2
#define H_KEY 3
#define H_CERTIFICATE 4
#define H_CSPPARAM 5
#define H_SOLUTIONS 6
#define H_DATA 7
#define H_DIAG 8
#define M_FILE_CHANGEPIN 0
#define M_FILE_CHANGEPUK 1
#define M_FILE_UNBLOCKPIN 2
#define M_FILE_FORGETPIN 3
#define M_FILE_READINFO 4
#define M_FILE_DEFRAGCARD 5
#define M_CERT_DETAIL 6
#define M_CERT_EXPORT 7
#define M_CERT_IMPORTFILE 8
#define M_CERT_DELETE 9
#define M_KEY_EXPORT 10
#define M_KEY_IMPORT 11
#define M_KEY_TEST 12
#define M_KEY_DELETE 13
#define M_DATA_EXPORT 14
#define M_DATA_IMPORT 15
#define M_DATA_ACTUAL 16
#define M_DATA_READVALUE 17
#define M_DATA_DELETE 18
#define T_TEXT 0
#define T_DATA 1
{
Q_OBJECT
private:
bool firstTime;
bool reloadBool;
bool libraryLoaded;
int containerCount;
int readerSelected;
int containerSelected;
int dataObjectSelected;
QList<QString> readers;
QList<QString> vendors;
QList<bool> sCardConnects;
QList<QString> *containers;
QList<key_info> *keys;
QList<int> *certificates;
QList<QString> *dataObjects;
QList<bool> readerConnects;
QList<bool> readerUsbs;
QList<QString> readerVendors;
QList<QString> readerTypes;
QList<QString> readerPorts;
QList<int> cardRoots;
QList<int> cardValidCerts;
QList<int> *hardwareGenerated;
QList<int> *signsAllowed;
QList<int> *decryptsAllowed;
QList<bool> *isCA;
bool reloaded;
bool canceled;
bool *wrongPinCounter;
//QMenu *dataMenu;
QWebView *infoHtml;
//QAction *exportDataAction;
//QAction *importDataAction;
//QAction *deleteDataAction;
X509Cert *cert;
X509Viewer *viewer;
unsigned long *sCardConnected;
int initializeTree();
void initializeArea();
void waitForProgress();
void generateHeader(int type);
void generateCopyright();
void menuAllows(QList<int> items);
int verifyPin(int readerNumber);
int verifyPuk(int readerNumber);
public:
Pkcs11Manipulator *p11manipulator;
bool isLoaded();
~CardManager();
private slots:
void quit();
void activatedLink
(const QUrl &link
);
void version();
void changePin();
void changePuk();
void unblockPin();
void reload();
void statusbarOnOff();
void importCert();
void exportCert();
void showCertview();
void importKey();
void exportKey();
void testKey();
void deleteObject();
void suggestSolutions();
void showDiag();
void saveDiag();
void print();
void printSetup();
void expertMode();
void about();
void checkPinLength
(const QString &text
);
};
#endif // CARDMANAGER_H
Now everything works fine. But I wanted to add new menu item, so I added those commented variables. But if I uncomment even one of these (for example QMenu *dataMenu), my application stops working. They are not even used anywhere in cpp file, just declared in header. When I run my application after declaring one of these variables, there is no error, constructor of CardManager class creates everything (I have log on last line of constructor), but application frame never shows up. Why is that? If I declare those variables locally in constructor inside cpp file, everything works fine, but I need them global.
Re: Adding new variable into header file breaks my application
Re: Adding new variable into header file breaks my application
Tried that couple of times, even tried to build into new folder. Nothing helped.
Re: Adding new variable into header file breaks my application
run the application in a debugger - where does it crash?
Re: Adding new variable into header file breaks my application
show compilable example. What you are posting is very unlikely to be the fault. Your code is probably tripping over some other undefined behaviour.
Re: Adding new variable into header file breaks my application
Wiseguy: it doesn't crash. In my main:
Code:
CardManager cardManager;
if(cardManager.isLoaded())
{
cardManager.mainWindow.show();
app.exec();
}
when I have commented those 4 lines in header file, when debugger hits app.exec(), mainWindow of cardManager is shown. When I uncomment one of those commented lines, when it hits app.exec() nothing happens, no mainWindow is shown the application only get stuck in exec() loop and I must close it usind stop button.
amleto: Yes, what I'm posting is not fault, but as I said there are 4 commented lines in that code and when I uncoment one of them (define one new QMenu or QAction variable) my app stops working. I dont have used them anywhere else in my code except this definition.
Re: Adding new variable into header file breaks my application
Post your full code.
What do you mean by "stopped working"?
Re: Adding new variable into header file breaks my application
Quote:
Originally Posted by
amleto
show compilable example. What you are posting is very unlikely to be the fault. Your code is probably tripping over some other undefined behaviour.
Quote:
Originally Posted by
Raadush
amleto: Yes, what I'm posting is not fault, but as I said there are 4 commented lines in that code and when I uncoment one of them (define one new QMenu or QAction variable) my app stops working. I dont have used them anywhere else in my code except this definition.
I'll repeat.
Quote:
Originally Posted by
amleto
show compilable example.
Oh yeah, and it's in my sig too.
Re: Adding new variable into header file breaks my application
@Raadush: I put on my magic wizard hat, which allows me to see invisible code. My friends high_flyer and amleto don't have a hat like this one, so they are at a disadvantage.
You have about 300 member variables in your class. Are you initializing every one of them to some known, acceptable value in your constructor - especially those QList<int> * ones? Or are you just hoping that when you use one of them it will magically (like my hat) have a good enough value that Qt can do something with it?
Are you confusing QList<int> * with QList<int *> and using one when you mean the other? Likewise with the QString * member variables. What's the point of a pointer to a QString?