Ticket #2962: qt_removeCrash2.patch

File qt_removeCrash2.patch, 663 bytes (added by Longinus00, 12 years ago)

Safer, if slower, version

  • qt/torrent-model.cc

    diff --git qt/torrent-model.cc qt/torrent-model.cc
    index 5f5b9af..2ba9d24 100644
    TorrentModel :: removeTorrent( int id ) 
    206206        Torrent * tor = myIdToTorrent.value( id, 0 );
    207207
    208208        beginRemoveRows( QModelIndex(), row, row );
     209        /* We need to make the myIdToRow map consistent with what exists in the list view/model */
     210        for( QMap<int,int>::iterator i = myIdToRow.begin(); i != myIdToRow.end(); ++i )
     211            if( i.value() > row ) --i.value();
    209212        myIdToRow.remove( id );
    210213        myIdToTorrent.remove( id );
    211214        myTorrents.remove( myTorrents.indexOf( tor ) );