qt history list: fix minor sorting issue

closes #4989
This commit is contained in:
SomberNight 2019-01-17 17:09:22 +01:00
parent 4e10f9e301
commit 44a2ceab3c
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9

View File

@ -29,6 +29,7 @@ from datetime import date
from typing import TYPE_CHECKING, Tuple, Dict
import threading
from enum import IntEnum
from decimal import Decimal
from electrum.address_synchronizer import TX_HEIGHT_LOCAL
from electrum.i18n import _
@ -77,9 +78,14 @@ class HistorySortModel(QSortFilterProxyModel):
item2 = self.sourceModel().data(source_right, Qt.UserRole)
if item1 is None or item2 is None:
raise Exception(f'UserRole not set for column {source_left.column()}')
if item1.value() is None or item2.value() is None:
v1 = item1.value()
v2 = item2.value()
if v1 is None or isinstance(v1, Decimal) and v1.is_nan(): v1 = -float("inf")
if v2 is None or isinstance(v2, Decimal) and v2.is_nan(): v2 = -float("inf")
try:
return v1 < v2
except:
return False
return item1.value() < item2.value()
class HistoryModel(QAbstractItemModel, PrintError):