Backport deleteLater fix for Manuscript tools from 2.5 release

This commit is contained in:
Veronica Berglyd Olsen
2024-05-30 16:43:47 +02:00
parent 6cb330b06c
commit f34cb567e4
3 changed files with 27 additions and 13 deletions
+13 -1
View File
@@ -27,11 +27,23 @@ from __future__ import annotations
from PyQt5.QtCore import QSize, Qt
from PyQt5.QtGui import QWheelEvent
from PyQt5.QtWidgets import QComboBox, QDoubleSpinBox, QSpinBox, QToolButton, QWidget
from PyQt5.QtWidgets import QComboBox, QDialog, QDoubleSpinBox, QSpinBox, QToolButton, QWidget
from novelwriter import SHARED
class NDialog(QDialog):
def softDelete(self) -> None:
"""Since calling deleteLater is sometimes not safe from Python,
as the C++ object can be deleted before the Python process is
done with the object, we instead set the dialog's parent to None
so that it gets garbage collected when it runs out of scope.
"""
self.setParent(None) # type: ignore
return
class NComboBox(QComboBox):
def __init__(self, parent: QWidget | None = None) -> None: