I have put a lot of effort to rewrite huge part of my app to work with QValueVector but all in vain. Below I present proof of this broken component. Correct me if I'm wrong and I'll be happy.

My code:
Qt Code:
  1. qDebug(">");
  2. playlistsList::iterator i, j;
  3. i = playlists.begin();
  4. j = i;
  5. i += where;
  6.  
  7. //qDebug(playlists.at(which).name);
  8. //qDebug((*i).name);
  9.  
  10. for (int i = 0 ; i != playlists.count() ; i++, j++)
  11. {
  12. qDebug(playlists.at(i).name + " " + (*j).name);
  13. }
  14.  
  15. qDebug("i'll insert " + playlists.at(which).name + " before " + (*i).name);
  16.  
  17. playlists.insert(i, playlists.at(which));
  18.  
  19. for (int i = 0 ; i != playlists.count() ; i++)
  20. qDebug(playlists.at(i).name);
  21.  
  22. qDebug("after redundant removed");
  23.  
  24. i = playlists.begin();
  25. j = i;
  26. i += (which + 1);
  27.  
  28. playlists.erase(i);
  29.  
  30. for (int i = 0 ; i != playlists.count() ; i++, j++)
  31. qDebug(playlists.at(i).name + " " + (*j).name);
  32.  
  33. qDebug("");
  34. qDebug("");
To copy to clipboard, switch view to plain text mode 

Results after first execution of above code are correct:
Qt Code:
  1. >
  2. aa aa
  3. bb bb
  4. i'll insert bb before aa
  5. bb
  6. aa
  7. bb
  8. after redundant removed
  9. bb bb
  10. aa aa
To copy to clipboard, switch view to plain text mode 

Second execution gives INCORRECT result:
Qt Code:
  1. >
  2. bb bb
  3. aa aa
  4. i'll insert aa before bb
  5. bb
  6. bb
  7. aa
  8. after redundant removed
  9. bb bb
  10. bb bb
To copy to clipboard, switch view to plain text mode 

Can anyone help me?