pamhyr: Catch some table data type exception (crash Fix).

This commit is contained in:
Pierre-Antoine Rouby committed 2023-08-04 10:40:32 +02:00
1 parent e8ae1c0631
commit 464209b6e5
21 files changed
+303 -190

No files matched your search

+30 -23
View File
@@ -16,6 +16,9 @@
# -*- coding: utf-8 -*-
import logging
import traceback
from Model.Network.Node import Node
from Model.Network.Edge import Edge
from Model.Network.Graph import Graph
@@ -153,31 +156,35 @@ class GraphTableModel(QAbstractTableModel):
def setData(self, index, value, role=Qt.EditRole):
if index.isValid():
if role == Qt.EditRole:
if (self.headers[index.column()] == "node1" or
self.headers[index.column()] == "node2"):
node = self.graph.node(value)
self._undo.push(
SetNodeCommand(
self.graph,
self.rows[index.row()],
self.headers[index.column()],
node
try:
if (self.headers[index.column()] == "node1" or
self.headers[index.column()] == "node2"):
node = self.graph.node(value)
self._undo.push(
SetNodeCommand(
self.graph,
self.rows[index.row()],
self.headers[index.column()],
node
)
)
)
# elif self.headers[index.column()] == "enable":
# self._undo.push(
# EnableEdgeCommand(
# self.rows[index.row()], value
# )
# )
else:
self._undo.push(
SetCommand(
self.rows[index.row()],
self.headers[index.column()],
value
# elif self.headers[index.column()] == "enable":
# self._undo.push(
# EnableEdgeCommand(
# self.rows[index.row()], value
# )
# )
else:
self._undo.push(
SetCommand(
self.rows[index.row()],
self.headers[index.column()],
value
)
)
)
except Exception as e:
logger.info(e)
logger.debug(traceback.format_exc())
self.dataChanged.emit(index, index, [Qt.DisplayRole])
self.layoutChanged.emit()