From f576be7604b725b0e9db695056384cd56106c61d Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 22 Feb 2022 11:45:47 +0100 Subject: [PATCH 1/2] Fix parenting of save prompt QMessageBox - Setting the windowFlags without the original messagebox.windowFlags() was the culprit as to why the messagebox previously wouldn't show when parented. Likely because then it's missing the Dialog window flag and thus would try to embed itself into the parent UI, which you then cannot exec() (cherry picked from commit 290e2b601d0e20f4aaba356d4f053bf733de406b) --- openpype/tools/workfiles/app.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/openpype/tools/workfiles/app.py b/openpype/tools/workfiles/app.py index 4b5bf07b470..27ffb768a34 100644 --- a/openpype/tools/workfiles/app.py +++ b/openpype/tools/workfiles/app.py @@ -544,10 +544,6 @@ def __init__(self, parent=None): # file on a refresh of the files model. self.auto_select_latest_modified = True - # Avoid crash in Blender and store the message box - # (setting parent doesn't work as it hides the message box) - self._messagebox = None - files_view = FilesView(self) # Create the Files model @@ -726,9 +722,9 @@ def open_file(self, filepath): self.file_opened.emit() def save_changes_prompt(self): - self._messagebox = messagebox = QtWidgets.QMessageBox() - - messagebox.setWindowFlags(QtCore.Qt.FramelessWindowHint) + messagebox = QtWidgets.QMessageBox(parent=self) + messagebox.setWindowFlags(messagebox.windowFlags() | + QtCore.Qt.FramelessWindowHint) messagebox.setIcon(messagebox.Warning) messagebox.setWindowTitle("Unsaved Changes!") messagebox.setText( @@ -739,10 +735,6 @@ def save_changes_prompt(self): messagebox.Yes | messagebox.No | messagebox.Cancel ) - # Parenting the QMessageBox to the Widget seems to crash - # so we skip parenting and explicitly apply the stylesheet. - messagebox.setStyle(self.style()) - result = messagebox.exec_() if result == messagebox.Yes: return True From bb105209e8bc34a63e2e04bc8de42a603f3368d4 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 22 Feb 2022 15:28:05 +0100 Subject: [PATCH 2/2] Revert storing of messagebox - This is NOT done because the original crash was reproducible - but just out of pure legacy reasons for if the error might still occur. It would be worth looking into whether the crash can still be reproduced in recent Blender versions without this logic. --- openpype/tools/workfiles/app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openpype/tools/workfiles/app.py b/openpype/tools/workfiles/app.py index 27ffb768a34..3a772a038c9 100644 --- a/openpype/tools/workfiles/app.py +++ b/openpype/tools/workfiles/app.py @@ -544,6 +544,10 @@ def __init__(self, parent=None): # file on a refresh of the files model. self.auto_select_latest_modified = True + # Avoid crash in Blender and store the message box + # (setting parent doesn't work as it hides the message box) + self._messagebox = None + files_view = FilesView(self) # Create the Files model @@ -722,7 +726,7 @@ def open_file(self, filepath): self.file_opened.emit() def save_changes_prompt(self): - messagebox = QtWidgets.QMessageBox(parent=self) + self._messagebox = messagebox = QtWidgets.QMessageBox(parent=self) messagebox.setWindowFlags(messagebox.windowFlags() | QtCore.Qt.FramelessWindowHint) messagebox.setIcon(messagebox.Warning)