Repository: pyqtgraph/pyqtgraph

Issue:
Segfault when exiting Command Line Usage Example
<!-- In the following, please describe your issue in detail! -->
<!-- If some of the sections do not apply, just remove them. -->

### Short description
When Running the command line example, and closing the window, I get a segmentation fault

### Code to reproduce
<!-- Please provide a minimal working example that reproduces the issue in the code block below.
     Ideally, this should be a full example someone else could run without additional setup. -->
```bash
python -m pyqtgraph.examples
```

Run the command line usage example, and close out the window.


### Expected behavior
Window closes

### Real behavior
Window closes, generates a segfault

```
/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py:125: RuntimeWarning: 'pyqtgraph.examples.__main__' found in sys.modules after import of package 'pyqtgraph.examples', but prior to execution of 'pyqtgraph.examples.__main__'; this may result in unpredictable behaviour
  warn(RuntimeWarning(msg))
qt.qpa.fonts: Populating font family aliases took 246 ms. Replace uses of missing font family "FreeMono" with one that exists to avoid this cost.
Using PyQt5 (default graphics system)
Fatal Python error: Segmentation fault

Current thread 0x000000010840bdc0 (most recent call first):
  File "/Users/ognyan/Developer/pyqtgraph/.venv/lib/python3.7/site-packages/pyqtgraph/examples/CLIexample.py", line 26 in <module>
```

### Tested environment(s)

 * PyQtGraph version: 0.11
 * Qt Python binding: PySide2 5.15.0 and PyQt5 5.15.0
 * Python version: 3.7.7
 * NumPy version: 1.18.4
 * Operating system: macOS Catalina
 * Installation method: pip

### Additional context

This is not an issue with 0.11.rc0


Discussion:
Using git-bisect (I'm a noob at it, so I may have screwed it up), this commit appears to be the culprit:

https://github.com/pyqtgraph/pyqtgraph/commit/983cc1695e1b011e961a9d92a062355697010405



Resolving patch:
diff --git a/pyqtgraph/graphicsWindows.py b/pyqtgraph/graphicsWindows.py
--- a/pyqtgraph/graphicsWindows.py
+++ b/pyqtgraph/graphicsWindows.py
@@ -55,10 +55,14 @@ class PlotWindow(PlotWidget):
     """
     def __init__(self, title=None, **kargs):
         mkQApp()
+        self.win = QtGui.QMainWindow()
         PlotWidget.__init__(self, **kargs)
+        self.win.setCentralWidget(self)
+        for m in ['resize']:
+            setattr(self, m, getattr(self.win, m))
         if title is not None:
-            self.setWindowTitle(title)
-        self.show()
+            self.win.setWindowTitle(title)
+        self.win.show()
 
     def closeEvent(self, event):
         PlotWidget.closeEvent(self, event)
@@ -73,14 +77,20 @@ class ImageWindow(ImageView):
     """
     def __init__(self, *args, **kargs):
         mkQApp()
-        ImageView.__init__(self)
+        self.win = QtGui.QMainWindow()
+        self.win.resize(800,600)
         if 'title' in kargs:
-            self.setWindowTitle(kargs['title'])
+            self.win.setWindowTitle(kargs['title'])
             del kargs['title']
+        ImageView.__init__(self, self.win)
         if len(args) > 0 or len(kargs) > 0:
             self.setImage(*args, **kargs)
-        self.show()
-
+        
+        self.win.setCentralWidget(self)
+        for m in ['resize']:
+            setattr(self, m, getattr(self.win, m))
+        self.win.show()
+    
     def closeEvent(self, event):
         ImageView.closeEvent(self, event)
         self.sigClosed.emit(self)


Test patch: