Hello,

My application is composed of an "Icone" (Personal class that setup a QSystemTrayIcon with a QMenu).

This Icone creates a "Veilleur" object (Personal class that simulate a service in order to administrate a client side connection to a server).

So the "Veilleur" creates a "MailChecker" (Personal class that checks for new mails on a server).

At the end, the "MailChecker" use a QTcpSocket to connect to the server.

The problem is that today I need to developp the "Veilleur" class, and a strange thing as appeared : I can't add anything !
For example, if I want to add a QAction (private or public) the application will fall down.
The application as no problem to pass the builder : no errors, no warning... Nothing.
But when I launch it, I get a Windows error box saying me that the application as encoutered an error and must be closed...

I can't understand the problem, so I put here my code... As reduced as possible .

main.cpp
Qt Code:
  1. #include <QApplication>
  2. #include <QtGui>
  3.  
  4. #include "Icone.h"
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8. QApplication app(argc, argv);
  9. Icone mon_icone;
  10. return app.exec();
  11. }
To copy to clipboard, switch view to plain text mode 




Icone.h
Qt Code:
  1. #ifndef ICONE_H
  2. #define ICONE_H
  3.  
  4. #include "Veilleur.h"
  5.  
  6. #include <iostream>
  7. #include <QSystemTrayIcon>
  8. #include <QWidget>
  9.  
  10. class QAction;
  11. class QMenu;
  12.  
  13. class Icone : public QWidget
  14. {
  15. Q_OBJECT
  16.  
  17. public:
  18. Icone();
  19.  
  20. protected:
  21. [...]
  22.  
  23. private slots:
  24. [...]
  25.  
  26. private:
  27. // QActions and QMenus
  28. // [...]
  29.  
  30. QSystemTrayIcon *trayIcon;
  31.  
  32. Veilleur mon_veilleur;
  33. };
  34.  
  35. #endif
To copy to clipboard, switch view to plain text mode 




Icone.cpp
Qt Code:
  1. #include <QtGui>
  2.  
  3. #include "Icone.h"
  4.  
  5. Icone::Icone()
  6. {
  7. Creer_actions(); // Initialise the QActions
  8. Creer_menu(); // Initialise the QMenus
  9. Creer_TrayIcon(); // Initialise the trayicon and bind it the QMenus
  10. }
To copy to clipboard, switch view to plain text mode 




Veilleur.h
Qt Code:
  1. #ifndef Veilleur_h
  2. #define Veilleur_h
  3.  
  4. #include "MailChecker.h"
  5.  
  6. #include <QTextStream>
  7. #include <QObject>
  8. #include <QTimer>
  9.  
  10. // Added in order to try to add a QAction
  11. #include <iostream>
  12. #include <QWidget>
  13. class QAction;
  14. class QMenu;
  15.  
  16. class Veilleur : public QObject
  17. {
  18. Q_OBJECT
  19.  
  20. public:
  21. Veilleur();
  22. [...]
  23.  
  24. private slots:
  25. [...]
  26.  
  27. private:
  28. MailChecker mChecker;
  29. //MailChecker mCheckersecond; // Crash the application if uncommented
  30. //QAction *Act_Tic; // Crash the application if uncommented
  31. //QAction *Act_Ticlol; // Crash the application if uncommented
  32. };
  33. #endif
To copy to clipboard, switch view to plain text mode 





Veilleur.cpp
Qt Code:
  1. #include <iostream>
  2. #include <QApplication>
  3.  
  4. #include "Veilleur.h"
  5.  
  6. Veilleur::Veilleur() : QObject()
  7. {
  8. }
To copy to clipboard, switch view to plain text mode 




MailChecker.h
Qt Code:
  1. #ifndef MailChecker_h
  2. #define MailChecker_h
  3.  
  4. #include <QThread>
  5. #include <QTextStream>
  6. #include <QSettings>
  7. #include <QObject>
  8. #include <QTcpSocket>
  9.  
  10. class QTcpSocket;
  11.  
  12. class MailChecker : public QObject
  13. {
  14. Q_OBJECT
  15.  
  16. public:
  17. MailChecker();
  18. [...]
  19.  
  20. private slots:
  21. void afficher_erreur_socket(QAbstractSocket::SocketError socketError);
  22.  
  23. private:
  24. [...]
  25.  
  26. QTcpSocket *socket_r;
  27. };
  28.  
  29. #endif
To copy to clipboard, switch view to plain text mode 




MailChecker.cpp
Qt Code:
  1. #include <iostream>
  2.  
  3. #include <QApplication>
  4. #include <QHostAddress>
  5. #include <QTcpSocket>
  6. #include <QStringList>
  7.  
  8. #include "MailChecker.h"
  9.  
  10.  
  11. MailChecker::MailChecker() : QObject()
  12. {
  13. connect(socket_r, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(afficher_erreur_socket(QAbstractSocket::SocketError)));
  14. }
  15.  
  16. void MailChecker::afficher_erreur_socket(QAbstractSocket::SocketError socketError)
  17. {
  18. switch (socketError)
  19. {
  20. case QAbstractSocket::RemoteHostClosedError:
  21. break;
  22. case QAbstractSocket::HostNotFoundError:
  23. std::cout << "\n ERREUR SOCKET : Host not found" << std::endl;
  24. break;
  25. case QAbstractSocket::ConnectionRefusedError:
  26. std::cout << "\n ERREUR SOCKET : Connection refused by peer" << std::endl;
  27. break;
  28. default:
  29. std::cout << "\n ERREUR SOCKET : \n" << socket_r->errorString().toStdString() << std::endl;
  30. }
  31. }
To copy to clipboard, switch view to plain text mode 



I'm sure I made my nOOb another time... But I'm a nOOb .
I can't understand what's the problem,
I can't understand why the application crashes if I add an object,
I can't understand why the application has been compile and built but crashes...

I think it's a class initialisation problem, but I can't see what.

Perhaps coul you help me ?
Thanks