gaasedelen / tenet

A Trace Explorer for Reverse Engineers
MIT License
1.32k stars 133 forks source link

PyQt5 float fixes (TypeError: setSpacing(self, int): argument 1 has unexpected type 'float') #17

Closed arizvisa closed 2 years ago

arizvisa commented 2 years ago

Some minor fixes for Qt where it now requires floats to be truncated for some of its parameters.

iff --git a/plugins/tenet/util/qt/waitbox.py b/plugins/tenet/util/qt/waitbox.py
index c0b05f9..434a35b 100644
--- a/plugins/tenet/util/qt/waitbox.py
+++ b/plugins/tenet/util/qt/waitbox.py
@@ -86,17 +86,17 @@ class WaitBox(QtWidgets.QDialog):
             self._abort_button.clicked.connect(self._abort)
             v_layout.addWidget(self._abort_button)

-        v_layout.setSpacing(self._dpi_scale*3)
+        v_layout.setSpacing(int(self._dpi_scale*3))
         v_layout.setContentsMargins(
-            self._dpi_scale*5,
-            self._dpi_scale,
-            self._dpi_scale*5,
-            self._dpi_scale
+            int(self._dpi_scale*5),
+            int(self._dpi_scale),
+            int(self._dpi_scale*5),
+            int(self._dpi_scale)
         )

         # scale widget dimensions based on DPI
         height = self._dpi_scale * 15
-        self.setMinimumHeight(height)
+        self.setMinimumHeight(int(height))

         # compute the dialog layout
         self.setLayout(v_layout)

That's for this exception:

Traceback (most recent call last):
  File "/home/$USER/idapro-8.0/python/3/ida_idaapi.py", line 580, in IDAPython_ExecScript
    exec(code, g)
  File "/home/$USER/.idapro/plugins/tenet_plugin.py", line 1, in <module>
    from tenet.util.log import logging_started, start_logging
  File "/home/$USER/.idapro/plugins/tenet/util/log.py", line 6, in <module>
    from ..integration.api import disassembler
  File "/home/$USER/.idapro/plugins/tenet/integration/api/__init__.py", line 19, in <module>
    disassembler = IDACoreAPI()
  File "/home/$USER/.idapro/plugins/tenet/integration/api/ida_api.py", line 74, in __init__
    super(IDACoreAPI, self).__init__()
  File "/home/$USER/.idapro/plugins/tenet/integration/api/api.py", line 47, in __init__
    self._waitbox = WaitBox("Please wait...")
  File "/home/$USER/.idapro/plugins/tenet/util/qt/waitbox.py", line 27, in __init__
    self._ui_init()
  File "/home/$USER/.idapro/plugins/tenet/util/qt/waitbox.py", line 71, in _ui_init
    self._ui_layout()
  File "/home/$USER/.idapro/plugins/tenet/util/qt/waitbox.py", line 89, in _ui_layout
    v_layout.setSpacing(self._dpi_scale*3)
TypeError: setSpacing(self, int): argument 1 has unexpected type 'float'
arizvisa commented 2 years ago

Closing this as apparently PR #14 does this and fixes the other case.