gnome-shell crashes if a modal window closes whilst being dragged
I've noticed that if I am dragging a main window, or a modal window attached to it (such that both windows move since the modal window is attached to the main window), then if the modal window closes whilst I'm dragging, gnome-shell crashes.
When using the app Anki, which has a modal popup with a syncing progress bar, if I am dragging it when it finishes syncing, the screen freezes (mouse can still move but that's all) and it necessitates killing gnome-shell from a tty.
Since Anki is written in PyQt5, I tried to reproduce the problem with a minimal PyQt5 application, the code for which is below. With my minimal example, whilst gnome-shell still crashes, it manages to restart without losing running applications. This is different from with Anki, which i can't manage to recover from without losing running applications, so I'm just trying to remember not to idly drag windows whilst it's syncing. So the example is not replicating the exact problem, but I'm sure it's related enough to get at whatever the cause of the bug is.
Upon a crash, I see the following in syslog:
Feb 3 12:28:47 bilbo-Precision-5520 org.gnome.Shell.desktop[9691]: **
Feb 3 12:28:47 bilbo-Precision-5520 org.gnome.Shell.desktop[9691]: mutter:ERROR:core/window.c:1478:meta_window_unmanage: assertion failed: (window->display->focus_window != window)
Feb 3 12:28:47 bilbo-Precision-5520 gnome-session[9593]: gnome-session-binary[9593]: WARNING: Application 'org.gnome.Shell.desktop' killed by signal 6
Feb 3 12:28:47 bilbo-Precision-5520 gnome-session-binary[9593]: WARNING: Application 'org.gnome.Shell.desktop' killed by signal 6
This problem occurs both with X and Wayland. I am on Ubuntu 17.10 with gnome-shell 3.26.1.
Here is the minimal PyQt5 example:
#!/usr/bin/env python3
import sys
from PyQt5.QtWidgets import QLabel, QWidget, QApplication, QVBoxLayout, QMainWindow, QDialog
from PyQt5.QtCore import QTimer, Qt
app = QApplication(sys.argv)
main_window = QMainWindow()
main_window.setWindowTitle('Main window')
main_window.resize(400, 400)
main_window.show()
modal_window = QDialog(main_window)
modal_window.setWindowTitle('Modal Window')
modal_window.setWindowModality(Qt.ApplicationModal)
layout = QVBoxLayout(modal_window)
label = QLabel('drag this window')
modal_window.resize(200, 200)
layout.addWidget(label)
modal_window.show()
remaining_time = 5 # seconds
def timeout():
global remaining_time
remaining_time -= 1
label.setText('drag this window\nclosing in {}'.format(remaining_time))
if remaining_time == 0:
modal_window.close()
timer.stop()
timer = QTimer()
timer.timeout.connect(timeout)
timer.start(1000)
app.exec_()