Skip to content

Commit 66b731b

Browse files
Fix QPointF IndexError: list index out of range (#11393)
* Fix QPointF IndexError: list index out of range 当QPointF 获取异常时,self.center 赋予默认值 * 增加QPointF异常时的提醒信息
1 parent c27ef01 commit 66b731b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

libs/shape.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from PyQt5.QtCore import QPointF
1919
from PyQt5.QtGui import QColor, QPen, QPainterPath, QFont
2020
from libs.utils import distance
21+
from ppocr.utils.logging import get_logger
2122

2223
DEFAULT_LINE_COLOR = QColor(0, 255, 0, 128)
2324
DEFAULT_FILL_COLOR = QColor(255, 0, 0, 128)
@@ -92,8 +93,15 @@ def rotatePoint(self, p, theta):
9293
return pRes
9394

9495
def close(self):
95-
self.center = QPointF((self.points[0].x() + self.points[2].x()) / 2,
96+
try:
97+
self.center = QPointF((self.points[0].x() + self.points[2].x()) / 2,
9698
(self.points[0].y() + self.points[2].y()) / 2)
99+
except:
100+
self.center = None
101+
logger = get_logger()
102+
logger.warning(
103+
'The XY coordinates of QPointF are not detectable!'
104+
)
97105
self._closed = True
98106

99107
def reachMaxPoints(self):

0 commit comments

Comments
 (0)