[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: terrible bug (feature?) in KdialogBase
From: Ravikiran Rajagopal <ravi () ee ! eng ! ohio-state ! edu>
Date: 2003-04-01 20:33:48
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
> Ugh, that's nasty. Does the attached patch help?
It does for me. However, the code in the example makes an assumption that is
not generally valid. See below.
> > Thus, all programs of this kind will crash:
> >
> > QList<someType> myList;
> > myList.append(someObj);
> > myList.append(someObj);
> > myList.append(someObj);
> > myList.append(someObj);
> > myList.append(someObj);
> >
> > ...
> > myList.at(activePageIndex());
This is really bad however. The implicit assumption is that KJanusWidget will
start assigning indices from 0 continuously. It would be safer (and also
better programming practice) to use something like the following:
QMap<int,someType> myList;
myPage = addPage(...);
myList[pageIndex(myPage)] = someObj;
[...]
someType wantedObject = myList[activePageIndex()];
This way, we don't run into random crashes. Note that the implicit assumption
mentioned above is no longer valid if a page is deleted (which is a feature
of KJanusWidget, and hence, of KDialogBase). In such cases, the method
outlined above is the right way.
Regards,
Ravi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE+ife0bI8Y8y0oVXcRAvOTAJ9x8riS5eG7I5QddnzsdXHCVFnOQACfVoX9
teSszlWmHDTRG+tTYv79ghU=
=c+Yl
-----END PGP SIGNATURE-----
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic