Revert "Add Qt environment validation and graceful fallback for broken PySide6"

This reverts commit 13afe98190.
This commit is contained in:
Jason Tang
2026-03-14 03:21:18 -04:00
parent 13afe98190
commit f656683981
3 changed files with 2 additions and 121 deletions
+2 -28
View File
@@ -27,16 +27,7 @@ PLUGIN_NAME = "IDAssist"
PLUGIN_HOTKEY = "Ctrl+Shift+A"
PLUGIN_COMMENT = "LLM-assisted reverse engineering"
PLUGIN_HELP = "Opens the IDAssist panel for AI-powered binary analysis"
def _load_version():
import json
try:
meta_path = os.path.join(_PLUGIN_DIR, "ida-plugin.json")
with open(meta_path, "r") as f:
return json.load(f)["plugin"]["version"]
except Exception:
return "0.0.0"
PLUGIN_VERSION = _load_version()
PLUGIN_VERSION = "1.0.0"
# ---------------------------------------------------------------------------
@@ -207,20 +198,9 @@ class IDAssistPlugin(idaapi.plugin_t):
def init(self):
"""Called when IDA loads the plugin. Return PLUGIN_KEEP to stay resident."""
try:
from src.ida_compat import log, check_qt_environment
from src.ida_compat import log
log.log_info(f"IDAssist v{PLUGIN_VERSION} loaded")
# Validate Qt environment
self._qt_ok = True
self._qt_diag = ""
qt_ok, qt_diag = check_qt_environment()
if qt_ok:
log.log_info(f"Qt env: {qt_diag}")
else:
log.log_error(f"Qt environment check failed: {qt_diag}")
self._qt_ok = False
self._qt_diag = qt_diag
# Register context menu actions
self._register_actions()
@@ -276,12 +256,6 @@ class IDAssistPlugin(idaapi.plugin_t):
def run(self, arg):
"""Called when the user activates the plugin (hotkey or menu)."""
if not self._qt_ok:
ida_kernwin.warning(
f"IDAssist: Qt environment is not usable.\n\n{self._qt_diag}\n\n"
"The UI cannot be opened. Check IDA's output window for details."
)
return
try:
from src.views.idassist_form import IDAssistForm
IDAssistForm.open()
-87
View File
@@ -123,90 +123,3 @@ def get_binary_hash():
def is_in_ida():
"""Check if we are running inside IDA Pro."""
return _IN_IDA
def check_qt_platform_plugins():
"""Lightweight file-existence check for Qt platform plugins.
This does NOT import PySide6 — it checks the filesystem to detect
whether the platform plugins directory exists. Call this before
importing PySide6 in OnCreate to prevent the fatal abort() that Qt
triggers when platform plugins are missing (which Python cannot catch).
Returns:
(ok: bool, error_msg: str or None)
"""
try:
import importlib.util
spec = importlib.util.find_spec("PySide6")
if spec is None or spec.origin is None:
return False, "PySide6 is not installed or not importable"
pyside6_dir = os.path.dirname(spec.origin)
plugins_dir = os.path.join(pyside6_dir, "Qt", "plugins", "platforms")
if not os.path.isdir(plugins_dir):
return False, (
f"Qt platform plugins directory not found at {plugins_dir}. "
"This usually means PySide6 is incomplete or corrupted. "
"Try: pip install --force-reinstall PySide6"
)
return True, None
except Exception as e:
return False, f"Qt platform plugin check failed: {e}"
def check_qt_environment():
"""Validate the Qt/PySide6 environment for use in IDA plugins.
Performs import tests, version logging, conflict detection, and
platform plugin checks.
Returns:
(ok: bool, diagnostics: str)
"""
diag_lines = []
# 1. Import test
try:
import PySide6
import PySide6.QtCore
except ImportError as e:
return False, f"PySide6 import failed: {e}"
# 2. Version logging
pyside_ver = PySide6.__version__
qt_ver = PySide6.QtCore.qVersion()
diag_lines.append(f"PySide6 {pyside_ver}, Qt {qt_ver}")
# 3. Conflicting install detection
pyside_path = os.path.realpath(PySide6.__file__)
if "site-packages" in pyside_path:
# Check if this looks like a pip-installed copy rather than IDA's bundled one
ida_dir = ""
if _IN_IDA:
try:
ida_dir = os.path.dirname(idaapi.get_ida_directory() or "")
except Exception:
pass
if ida_dir and not pyside_path.startswith(ida_dir):
diag_lines.append(
f"WARNING: PySide6 loaded from pip site-packages ({pyside_path}) "
"which may shadow IDA's bundled Qt and cause crashes. "
"Consider: pip uninstall PySide6"
)
# 4. Platform plugin check
ok, err = check_qt_platform_plugins()
if not ok:
diag_lines.append(f"FATAL: {err}")
return False, "; ".join(diag_lines)
# 5. QApplication check
try:
from PySide6.QtWidgets import QApplication
if QApplication.instance() is None:
diag_lines.append("Note: QApplication not yet created (may be normal during early init)")
except Exception:
pass
return True, "; ".join(diag_lines)
-6
View File
@@ -87,12 +87,6 @@ class IDAssistForm(idaapi.PluginForm):
def OnCreate(self, form):
"""Called by IDA when the form is first created."""
from src.ida_compat import check_qt_platform_plugins
ok, err = check_qt_platform_plugins()
if not ok:
log.log_error(f"Qt platform plugins missing, cannot create UI: {err}")
return
try:
from PySide6.QtWidgets import QTabWidget, QVBoxLayout, QWidget