# Buggy code
def __init__(self, *, win_id, private, parent=None):
    if private:
        assert not qtutils.is_single_process()
    super().__init__(parent)
    self.widget = tabwidget.TabWidget(win_id, parent=self)
    self._win_id = win_id
    self._tab_insert_idx_left = 0
    self._tab_insert_idx_right = -1
    self.shutting_down = False
    self.widget.tabCloseRequested.connect(  # type: ignore
        self.on_tab_close_requested
    )
    self.widget.new_tab_requested.connect(self.tabopen)
    self.widget.currentChanged.connect(  # type: ignore
        self._on_current_changed
    )
    self.cur_fullscreen_requested.connect(self.widget.tabBar().maybe_hide)
    self.widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

    # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-65223
    if qtutils.version_check("5.10", compiled=False):
        self.cur_load_finished.connect(self._leave_modes_on_load)
    else:
        self.cur_load_started.connect(self._leave_modes_on_load)

    # This init is never used, it is immediately thrown away in the next
    # line.
    self._undo_stack = collections.deque()  # type: typing.MutableSequence[typing.MutableSequence[UndoEntry]]
    self._update_stack_size()
    self._filter = signalfilter.SignalFilter(win_id, self)
    self._now_focused = None
    self.search_text = None
    self.search_options = {}  # type: typing.Mapping[str, typing.Any]
    self._local_marks = {}  # type: typing.MutableMapping[QUrl, typing.MutableMapping[str, int]]
    self._global_marks = {}  # type: typing.MutableMapping[str, typing.Tuple[int, QUrl]]
    self.default_window_icon = self.widget.window().windowIcon()
    self.is_private = private
    self.tab_deque = TabDeque()
    config.instance.changed.connect(self._on_config_changed)


# Traceback (subprocess.CalledProcessError)
10:46:58 DEBUG    init       app:process_pos_args:299 Startup cmd ':later 500 quit'
10:46:58 DEBUG    commands   command:run:541 command called: later ['500', 'quit']
10:46:58 DEBUG    commands   command:run:556 Calling qutebrowser.misc.utilcmds.later(500, 'quit', 0)
10:46:58 DEBUG    init       app:_process_args:243 Init finished after 11.500216s
10:46:58 DEBUG    init       app:init:199 Init done!
10:46:58 DEBUG    webview    browsertab:_set_load_status:927 load status for <qutebrowser.browser.webengine.webenginetab.WebEngineTab tab_id=0 url='about:blank'>: LoadStatus.loading
10:46:58 DEBUG    signals    signalfilter:_filter_signals:88 emitting: cur_load_status_changed(<LoadStatus.loading: 6>) (tab 0)
10:46:58 DEBUG    signals    signalfilter:_filter_signals:88 emitting: cur_load_started() (tab 0)
10:46:58 DEBUG    commands   command:run:541 command called: quit
10:46:58 DEBUG    commands   argparser:multitype_conv:158 Trying to parse None as <class 'NoneType'>
10:46:58 DEBUG    commands   command:run:556 Calling qutebrowser.app.Quitter.quit(<qutebrowser.app.Quitter object at 0x0000021F46BED9D8>, False, None)
10:46:58 DEBUG    destroy    app:shutdown:721 Shutting down with status 0, session None...
10:46:58 DEBUG    prompt     prompt:shutdown:139 Shutting down with loops []
10:46:58 DEBUG    destroy    app:_shutdown:749 Stage 2 of shutting down...
10:46:58 DEBUG    ipc        ipc:shutdown:404 Shutting down IPC (socket 0x7ff9d7453ce0)
10:46:58 DEBUG    save       savemanager:save:97 Save of yaml-config requested - dirty False, save_on_exit False, is_exit True, force False -> False
10:46:58 DEBUG    save       savemanager:save:97 Save of state-config requested - dirty False, save_on_exit True, is_exit True, force False -> True
10:46:58 DEBUG    save       savemanager:save:97 Save of command-history requested - dirty False, save_on_exit False, is_exit True, force False -> False
10:46:59 DEBUG    save       savemanager:save:97 Save of quickmark-manager requested - dirty False, save_on_exit False, is_exit True, force False -> False
10:46:59 DEBUG    save       savemanager:save:97 Save of bookmark-manager requested - dirty False, save_on_exit False, is_exit True, force False -> False
10:46:59 DEBUG    save       savemanager:save:97 Save of cookies requested - dirty False, save_on_exit False, is_exit True, force False -> False
10:46:59 DEBUG    destroy    app:_shutdown:764 Deferring QApplication::exit...
10:46:59 DEBUG    destroy    app:exit:828 Now calling QApplication::exit.
10:46:59 DEBUG    destroy    objreg:on_destroyed:125 schedule removal: download-model
10:46:59 DEBUG    destroy    objreg:on_destroyed:125 schedule removal: quitter
10:46:59 DEBUG    destroy    objreg:on_destroyed:125 schedule removal: command-history
10:46:59 DEBUG    destroy    objreg:on_destroyed:125 schedule removal: 0
10:46:59 DEBUG    destroy    objreg:on_destroyed:125 schedule removal: main-window
10:46:59 DEBUG    destroy    objreg:on_destroyed:125 schedule removal: last-focused-main-window
10:46:59 DEBUG    destroy    objreg:on_destroyed:125 schedule removal: last-visible-main-window
10:46:59 DEBUG    destroy    objreg:on_destroyed:125 schedule removal: message-bridge
10:46:59 DEBUG    destroy    objreg:on_destroyed:125 schedule removal: tabbed-browser
10:46:59 DEBUG    destroy    objreg:on_destroyed:125 schedule removal: status-command
10:46:59 DEBUG    destroy    objreg:on_destroyed:125 schedule removal: 0
10:46:59 DEBUG    destroy    objreg:on_destroyed:125 schedule removal: tab
10:46:59 DEBUG    misc       eventfilter:eventFilter:80 <PyQt5.QtWidgets.QWidget object at 0x0000021F4CAD3A68>: removed child <PyQt5.QtCore.QObject object at 0x0000021F4C9C8A68>
10:46:59 DEBUG    misc       eventfilter:eventFilter:80 <PyQt5.QtWidgets.QWidget object at 0x0000021F4CAD3A68>: removed child <PyQt5.QtWidgets.QWidget object at 0x0000021F4C8C1288>
Windows fatal exception: access violation

Current thread 0x00001ef0 (most recent call first):
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python37-x64\lib\subprocess.py", line 512, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['py', '-3', '-m', 'qutebrowser', '--temp-basedir', '--nowindow', '--debug', 'about:blank', ':later 500 quit']' returned non-zero exit status 3221225477.

# Fixed code
def __init__(self, *, win_id, private, parent=None):
    if private:
        assert not qtutils.is_single_process()
    super().__init__(parent)
    self.widget = tabwidget.TabWidget(win_id, parent=self)
    self._win_id = win_id
    self._tab_insert_idx_left = 0
    self._tab_insert_idx_right = -1
    self.shutting_down = False
    self.widget.tabCloseRequested.connect(  # type: ignore
        self.on_tab_close_requested
    )
    self.widget.new_tab_requested.connect(self.tabopen)
    self.widget.currentChanged.connect(  # type: ignore
        self._on_current_changed
    )
    self.cur_fullscreen_requested.connect(self.widget.tabBar().maybe_hide)
    self.widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

    # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-65223
    if qtutils.version_check("5.10", compiled=False):
        self.cur_load_finished.connect(self._leave_modes_on_load)
    else:
        self.cur_load_started.connect(self._leave_modes_on_load)

    # This init is never used, it is immediately thrown away in the next
    # line.
    self._undo_stack = collections.deque()  # type: typing.MutableSequence[typing.MutableSequence[UndoEntry]]
    self._update_stack_size()
    self._filter = signalfilter.SignalFilter(win_id, self)
    self._now_focused = None
    self.search_text = None
    self.search_options = {}  # type: typing.Mapping[str, typing.Any]
    self._local_marks = {}  # type: typing.MutableMapping[QUrl, typing.MutableMapping[str, int]]
    self._global_marks = {}  # type: typing.MutableMapping[str, typing.Tuple[int, QUrl]]
    self.default_window_icon = self.widget.window().windowIcon()
    self.is_private = private
    self.tab_deque = TabDeque()
    config.instance.changed.connect(self._on_config_changed)
    quitter.instance.shutting_down.connect(self.shutdown)