mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 18:04:32 +00:00
Fix unchecked dynamic_cast
Replace some unnecessary (and slow) dynamic_cast with static_cast.
This commit is contained in:
parent
a203246e85
commit
a35cbdc4a9
@ -167,9 +167,12 @@ TorrentContentModelItem::ItemType TorrentContentModel::itemType(const QModelInde
|
|||||||
|
|
||||||
int TorrentContentModel::getFileIndex(const QModelIndex& index)
|
int TorrentContentModel::getFileIndex(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
TorrentContentModelFile* item = dynamic_cast<TorrentContentModelFile*>(static_cast<TorrentContentModelItem*>(index.internalPointer()));
|
TorrentContentModelItem *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
|
||||||
Q_ASSERT(item);
|
if (item->itemType() == TorrentContentModelItem::FileType)
|
||||||
return item->fileIndex();
|
return static_cast<TorrentContentModelFile*>(item)->fileIndex();
|
||||||
|
|
||||||
|
Q_ASSERT(item->itemType() == TorrentContentModelItem::FileType);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant TorrentContentModel::data(const QModelIndex& index, int role) const
|
QVariant TorrentContentModel::data(const QModelIndex& index, int role) const
|
||||||
|
@ -191,7 +191,7 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
|
|||||||
|
|
||||||
bool TransferListSortModel::lowerPositionThan(const QModelIndex &left, const QModelIndex &right) const
|
bool TransferListSortModel::lowerPositionThan(const QModelIndex &left, const QModelIndex &right) const
|
||||||
{
|
{
|
||||||
const TorrentModel *model = dynamic_cast<TorrentModel*>(sourceModel());
|
const TorrentModel *model = static_cast<TorrentModel*>(sourceModel());
|
||||||
|
|
||||||
// Sort according to TR_PRIORITY
|
// Sort according to TR_PRIORITY
|
||||||
const int queueL = model->data(model->index(left.row(), TorrentModel::TR_PRIORITY)).toInt();
|
const int queueL = model->data(model->index(left.row(), TorrentModel::TR_PRIORITY)).toInt();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user