Fix Ubuntu File Browser crash
This commit is contained in:
parent
5faf1e6d14
commit
72d22acc5b
@ -235,7 +235,13 @@ def _setup_logging() -> None:
|
|||||||
def _setup_linux_platform() -> None:
|
def _setup_linux_platform() -> None:
|
||||||
"""Ensure correct Qt platform plugin on Linux."""
|
"""Ensure correct Qt platform plugin on Linux."""
|
||||||
import os
|
import os
|
||||||
if sys.platform != "linux" or os.environ.get("QT_QPA_PLATFORM"):
|
if sys.platform != "linux":
|
||||||
|
return
|
||||||
|
# Disable xdg-desktop-portal and GVfs UDisks2 volume monitor to prevent
|
||||||
|
# file dialog crashes / hangs caused by D-Bus service timeouts.
|
||||||
|
os.environ.setdefault("QT_DISABLE_XDG_DESKTOP_PORTAL", "1")
|
||||||
|
os.environ.setdefault("GIO_USE_VOLUME_MONITOR", "unix")
|
||||||
|
if os.environ.get("QT_QPA_PLATFORM"):
|
||||||
return
|
return
|
||||||
if os.environ.get("WAYLAND_DISPLAY"):
|
if os.environ.get("WAYLAND_DISPLAY"):
|
||||||
os.environ["QT_QPA_PLATFORM"] = "wayland;xcb"
|
os.environ["QT_QPA_PLATFORM"] = "wayland;xcb"
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
@ -274,7 +275,13 @@ class DeviceTabController(QObject):
|
|||||||
# Command list playback ----------------------------------------------------
|
# Command list playback ----------------------------------------------------
|
||||||
def _browse_cmdlist(self) -> None:
|
def _browse_cmdlist(self) -> None:
|
||||||
from PySide6.QtWidgets import QFileDialog
|
from PySide6.QtWidgets import QFileDialog
|
||||||
path, _ = QFileDialog.getOpenFileName(self.view, "Command list", "", "Text files (*.txt);;All files (*)")
|
dlg = QFileDialog(self.view, "Command list", "", "Text files (*.txt);;All files (*)")
|
||||||
|
dlg.setFileMode(QFileDialog.FileMode.ExistingFile)
|
||||||
|
if sys.platform == "linux":
|
||||||
|
dlg.setOption(QFileDialog.Option.DontUseNativeDialog, True)
|
||||||
|
if dlg.exec() != QFileDialog.DialogCode.Accepted or not dlg.selectedFiles():
|
||||||
|
return
|
||||||
|
path = dlg.selectedFiles()[0]
|
||||||
if path:
|
if path:
|
||||||
self.view.cmdlist_path_edit.setText(path)
|
self.view.cmdlist_path_edit.setText(path)
|
||||||
self._save_session()
|
self._save_session()
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Callable, List, Optional, Tuple, TYPE_CHECKING
|
from typing import Callable, List, Optional, Tuple, TYPE_CHECKING
|
||||||
|
|
||||||
@ -54,9 +55,12 @@ class FlashManager:
|
|||||||
self._connected_baud = baud
|
self._connected_baud = baud
|
||||||
|
|
||||||
def browse_file(self, title: str, target: QLineEdit, file_filter: str = "Binary files (*);;All files (*)") -> None:
|
def browse_file(self, title: str, target: QLineEdit, file_filter: str = "Binary files (*);;All files (*)") -> None:
|
||||||
path, _ = QFileDialog.getOpenFileName(self.view, title, "", file_filter)
|
dlg = QFileDialog(self.view, title, "", file_filter)
|
||||||
if path:
|
dlg.setFileMode(QFileDialog.FileMode.ExistingFile)
|
||||||
target.setText(path)
|
if sys.platform == "linux":
|
||||||
|
dlg.setOption(QFileDialog.Option.DontUseNativeDialog, True)
|
||||||
|
if dlg.exec() == QFileDialog.DialogCode.Accepted and dlg.selectedFiles():
|
||||||
|
target.setText(dlg.selectedFiles()[0])
|
||||||
self._save_session()
|
self._save_session()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import sys
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Callable, Deque, List, Optional, Tuple, TYPE_CHECKING
|
from typing import Callable, Deque, List, Optional, Tuple, TYPE_CHECKING
|
||||||
@ -103,7 +104,13 @@ class LogManager(QObject):
|
|||||||
self.view.log_view.set_matches([], -1)
|
self.view.log_view.set_matches([], -1)
|
||||||
|
|
||||||
def save(self) -> None:
|
def save(self) -> None:
|
||||||
path, _ = QFileDialog.getSaveFileName(self.view, "Save Log", str(Path.home() / "ameba_log.txt"))
|
dlg = QFileDialog(self.view, "Save Log", str(Path.home() / "ameba_log.txt"))
|
||||||
|
dlg.setAcceptMode(QFileDialog.AcceptMode.AcceptSave)
|
||||||
|
if sys.platform == "linux":
|
||||||
|
dlg.setOption(QFileDialog.Option.DontUseNativeDialog, True)
|
||||||
|
if dlg.exec() != QFileDialog.DialogCode.Accepted or not dlg.selectedFiles():
|
||||||
|
return
|
||||||
|
path = dlg.selectedFiles()[0]
|
||||||
if not path:
|
if not path:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -13,7 +13,11 @@ def _bootstrap_path() -> None:
|
|||||||
|
|
||||||
def _setup_linux_platform() -> None:
|
def _setup_linux_platform() -> None:
|
||||||
"""Set Qt platform plugin for Linux X11/Wayland compatibility."""
|
"""Set Qt platform plugin for Linux X11/Wayland compatibility."""
|
||||||
if sys.platform != "linux" or os.environ.get("QT_QPA_PLATFORM"):
|
if sys.platform != "linux":
|
||||||
|
return
|
||||||
|
os.environ.setdefault("QT_DISABLE_XDG_DESKTOP_PORTAL", "1")
|
||||||
|
os.environ.setdefault("GIO_USE_VOLUME_MONITOR", "unix")
|
||||||
|
if os.environ.get("QT_QPA_PLATFORM"):
|
||||||
return
|
return
|
||||||
if os.environ.get("WAYLAND_DISPLAY"):
|
if os.environ.get("WAYLAND_DISPLAY"):
|
||||||
os.environ["QT_QPA_PLATFORM"] = "wayland;xcb"
|
os.environ["QT_QPA_PLATFORM"] = "wayland;xcb"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user