Having a bit of an issue with my Slots/Signals. I have distilled the code down to basics and am using it in a scratch project to help figure it out. I have run this in debug mode and placed a breakpoint in the moc file where the signal runs. Sure enough, it hits. However, the initStuff method is only being called once.

manager.h
Qt Code:
  1. #ifndef MANAGER_H
  2. #define MANAGER_H
  3.  
  4. #include <QObject>
  5.  
  6. class Manager : public QObject
  7. {
  8. Q_OBJECT
  9. public:
  10. static Manager* instance();
  11. static void init();
  12. void start();
  13. bool hasStuff() {return mStuff.size() > 0;}
  14. private:
  15. explicit Manager(QObject *parent = 0);
  16. static Manager* _instance;
  17.  
  18. QList<Channel*> mStuff;
  19. void processStuff();
  20. void loadStuffQueue();
  21.  
  22. signals:
  23. void emptyQueue();
  24.  
  25. public slots:
  26. void initStuff();
  27. };
  28.  
  29. #endif // MANAGER_H
To copy to clipboard, switch view to plain text mode 

manager.cpp
Qt Code:
  1. #include "manager.h"
  2.  
  3. Manager::Manager(QObject *parent) :
  4. QObject(parent)
  5. {
  6. mThread = new QThread(0);
  7. moveToThread(mThread);
  8. }
  9.  
  10. void Manager::init()
  11. {
  12. _instance = new Manager();
  13. connect(_instance, SIGNAL(emptyQueue()), _instance, SLOT(initStuff()));
  14. _instance->initStuff();
  15. _instance->start();
  16. }
  17.  
  18. void Manager::start() {
  19. if(mStuff.size() > 0) {
  20. instance()->processStuff();
  21. } else {
  22. emit emptyQueue();
  23. }
  24. }
  25.  
  26.  
  27. void Manager::initStuff()
  28. {
  29. //if there is stuff to put in the mStuff -- put it in there
  30. }
  31.  
  32.  
  33. void Manager::processStuff()
  34. {
  35. //here is where process stuff and empty the Stuff queue
  36. //when queue is empty we emit
  37. emit emptyQueue();
  38. }
  39.  
  40. Manager* Manager::instance()
  41. {
  42. if (_instance == 0) {
  43. _instance = new DSManager();
  44. }
  45. return _instance;
  46. }
  47. Manager* Manager::_instance;
To copy to clipboard, switch view to plain text mode 
main.cpp — relevant code
Qt Code:
  1. Manager::init();
To copy to clipboard, switch view to plain text mode