Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
4.6.2
-
None
-
Ubuntu Linux 10.04
Description
In a rather complex situation with some meta-programming I ended up doing something that is the equivalent of this:
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTabWidget *tw = new QTabWidget();
tw->addTab( tw, "Doh" );
tw->show();
return a.exec();
}
Now this will obviously lead to an infinite loop, but it would be nice if the addTab() function would check if you were trying to add itself or one of its parents and stop you. Since it's already retuning an int corresponding to the new tab index, it could fail and return -1. I imagine it could be done with something like:
int TabWidget::addTab( QWidget *tab, QString &label )
{
QWidget *w = this;
while( w )
// Continue as usual
}
Maybe even throw in a qWarning that this shouldn't happen or something as well, I don't know the policy on that. But it'd be a lot easier to debug than what I had to just do to figure out what's going on. Infinite recursion is plain nasty and even though this will add a microscopic speed penalty I think it's worth it.