mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
pamhyr: Catch some table data type exception (crash Fix).
This commit is contained in:
1 parent
e8ae1c0631
commit
464209b6e5
21 files changed
+303
-190
No files matched your search
@@ -16,6 +16,9 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
@@ -39,8 +42,9 @@ from View.Stricklers.UndoCommand import (
|
||||
|
||||
from View.Stricklers.translate import *
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
logger = logging.getLogger()
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
class TableModel(QAbstractTableModel):
|
||||
def __init__(self, data=None, undo=None, tab=""):
|
||||
@@ -92,30 +96,34 @@ class TableModel(QAbstractTableModel):
|
||||
row = index.row()
|
||||
column = index.column()
|
||||
|
||||
if self._headers[column] == "name":
|
||||
self._undo.push(
|
||||
SetNameCommand(
|
||||
self._data, row, value
|
||||
try:
|
||||
if self._headers[column] == "name":
|
||||
self._undo.push(
|
||||
SetNameCommand(
|
||||
self._data, row, value
|
||||
)
|
||||
)
|
||||
)
|
||||
elif self._headers[column] == "comment":
|
||||
self._undo.push(
|
||||
SetCommentCommand(
|
||||
self._data, row, value
|
||||
elif self._headers[column] == "comment":
|
||||
self._undo.push(
|
||||
SetCommentCommand(
|
||||
self._data, row, value
|
||||
)
|
||||
)
|
||||
)
|
||||
elif self._headers[column] == "minor":
|
||||
self._undo.push(
|
||||
SetMinorCommand(
|
||||
self._data, row, value
|
||||
elif self._headers[column] == "minor":
|
||||
self._undo.push(
|
||||
SetMinorCommand(
|
||||
self._data, row, value
|
||||
)
|
||||
)
|
||||
)
|
||||
elif self._headers[column] == "medium":
|
||||
self._undo.push(
|
||||
SetMediumCommand(
|
||||
self._data, row, value
|
||||
elif self._headers[column] == "medium":
|
||||
self._undo.push(
|
||||
SetMediumCommand(
|
||||
self._data, row, value
|
||||
)
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
logger.info(e)
|
||||
logger.debug(traceback.format_exc())
|
||||
|
||||
self.dataChanged.emit(index, index)
|
||||
return True
|
||||
|
||||
@@ -33,7 +33,7 @@ class SetNameCommand(QUndoCommand):
|
||||
self._data = data
|
||||
self._index = index
|
||||
self._old = self._data.get(self._index).name
|
||||
self._new = new_value
|
||||
self._new = str(new_value)
|
||||
|
||||
def undo(self):
|
||||
self._data.get(self._index).name = self._old
|
||||
@@ -48,7 +48,7 @@ class SetCommentCommand(QUndoCommand):
|
||||
self._data = data
|
||||
self._index = index
|
||||
self._old = self._data.get(self._index).comment
|
||||
self._new = new_value
|
||||
self._new = str(new_value)
|
||||
|
||||
def undo(self):
|
||||
self._data.get(self._index).comment = self._old
|
||||
@@ -63,7 +63,7 @@ class SetMinorCommand(QUndoCommand):
|
||||
self._data = data
|
||||
self._index = index
|
||||
self._old = self._data.get(self._index).minor
|
||||
self._new = new_value
|
||||
self._new = float(new_value)
|
||||
|
||||
def undo(self):
|
||||
self._data.get(self._index).minor = self._old
|
||||
@@ -78,7 +78,7 @@ class SetMediumCommand(QUndoCommand):
|
||||
self._data = data
|
||||
self._index = index
|
||||
self._old = self._data.get(self._index).medium
|
||||
self._new = new_value
|
||||
self._new = float(new_value)
|
||||
|
||||
def undo(self):
|
||||
self._data.get(self._index).medium = self._old
|
||||
|
||||
Reference in new issue
Block a user