# Buggy code
def close_dialog(self, checked=False):
    if self.rest_request:
        self.rest_request.cancel_request()

    # Loading files label is a clickable label with pyqtsignal which could leak,
    # so delete the widget while closing the dialog.
    if self.dialog_widget and self.dialog_widget.loading_files_label:
        try:
            self.dialog_widget.loading_files_label.deleteLater()
        except RuntimeError:
            logging.debug("Deleting loading files widget in the dialog widget failed.")

    super(StartDownloadDialog, self).close_dialog()


# Traceback (RuntimeError)
Traceback (most recent call last):
File "/home/<user>/src/tribler/src/run_tribler.py", line 154, in <module>
sys.exit(app.exec_())
File "/home/<user>/src/tribler/src/tribler-gui/tribler_gui/utilities.py", line 382, in trackback_wrapper
callback(*args, **kwargs)
File "/home/<user>/src/tribler/src/tribler-gui/tribler_gui/widgets/lazytableview.py", line 42, in <lambda>
connect(self.doubleClicked, lambda item: self.on_table_item_clicked(item, doubleclick=True))
File "/home/<user>/src/tribler/src/tribler-gui/tribler_gui/widgets/lazytableview.py", line 94, in on_table_item_clicked
self.torrent_doubleclicked.emit(data_item)
File "/home/<user>/src/tribler/src/tribler-gui/tribler_gui/utilities.py", line 382, in trackback_wrapper
callback(*args, **kwargs)
File "/home/<user>/src/tribler/src/tribler-gui/tribler_gui/widgets/lazytableview.py", line 127, in start_download_from_dataitem
self.window().start_download_from_uri(data_item2uri(data_item))
File "/home/<user>/src/tribler/src/tribler-gui/tribler_gui/tribler_window.py", line 822, in start_download_from_uri
self.dialog = StartDownloadDialog(self, self.download_uri)
File "/home/<user>/src/tribler/src/tribler-gui/tribler_gui/dialogs/startdownloaddialog.py", line 124, in __init__
self.perform_files_request()
File "/home/<user>/src/tribler/src/tribler-gui/tribler_gui/dialogs/startdownloaddialog.py", line 162, in perform_files_request
self.rest_request = TriblerNetworkRequest(request, self.on_received_metainfo, capture_core_errors=False)
File "/home/<user>/src/tribler/src/tribler-gui/tribler_gui/tribler_request_manager.py", line 176, in __init__
connect(self.received_json, self.reply_callback)
tribler_gui.utilities.CreationTraceback
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/<user>/src/tribler/src/tribler-gui/tribler_gui/utilities.py", line 385, in trackback_wrapper
raise exc from source_exc
File "/home/<user>/src/tribler/src/tribler-gui/tribler_gui/utilities.py", line 382, in trackback_wrapper
callback(*args, **kwargs)
File "/home/<user>/src/tribler/src/tribler-gui/tribler_gui/dialogs/startdownloaddialog.py", line 192, in on_received_metainfo
self.perform_files_request()
File "/home/<user>/src/tribler/src/tribler-gui/tribler_gui/dialogs/startdownloaddialog.py", line 158, in perform_files_request
direct = not self.dialog_widget.anon_download_checkbox.isChecked()
RuntimeError: wrapped C/C++ object of type QCheckBox has been deleted

# Fixed code
def close_dialog(self, checked=False):
    if self.rest_request:
        self.rest_request.cancel_request()

    if self.metainfo_fetch_timer:
        self.metainfo_fetch_timer.stop()

    # Loading files label is a clickable label with pyqtsignal which could leak,
    # so delete the widget while closing the dialog.
    if self.dialog_widget and self.dialog_widget.loading_files_label:
        try:
            self.dialog_widget.loading_files_label.deleteLater()
        except RuntimeError:
            logging.debug("Deleting loading files widget in the dialog widget failed.")

    super(StartDownloadDialog, self).close_dialog()