Having just spent the last several hours chasing down a weird bug, there is a sense of anticlimax having finally figured it out. I have to say the debugger was less than useless in this matter: various functions mysteriously were not working, although identical code seemed to work elsewhere, variables were listed as “not in scope” when they clearly had to be … it was just weird! Since Qt C++ is not really C++, that is, the language is extended, mostly by using evil MACROS, I was half-convinced there was some bug in the Qt meta-compiler that I would never in a million years solve. Then I was thinking I should be using a mutable iterator instead of a plain one, then I was sure that something was wrong with my copy constructors, then that some global scope library variable was hiding my variable or vice versa, around and around it went. I actually found a few other bugs in trying to fix this, but the ultimate problem eluded me for hours. Until…
There it was, staring me in the face all along:
while (iter.hasNext()); names << iter.next().name();
Unbelievably, a misplaced semicolon at the end of the while()
line was causing all the trouble. Sometimes (maybe more than sometimes) C++ can drive you crazy, as much as I love it. It certainly is making me appreciate "cleaner" higher level languages like Python and Ruby.