# Buggy code
def perform_files_request(self):
    direct = not self.dialog_widget.anon_download_checkbox.isChecked()
    request = f"torrentinfo?uri={quote_plus_unicode(self.download_uri)}"
    if direct is True:
        request = request + f"&hops=0"
    self.rest_request = TriblerNetworkRequest(
        request, self.on_received_metainfo, capture_core_errors=False
    )

    if self.metainfo_retries <= METAINFO_MAX_RETRIES:
        fetch_mode = "directly" if direct else "anonymously"
        loading_message = f"Loading torrent files {fetch_mode}..."
        timeout_message = f"Timeout in fetching files {fetch_mode}. Retrying ({self.metainfo_retries}/{METAINFO_MAX_RETRIES})"

        self.dialog_widget.loading_files_label.setText(
            loading_message if not self.metainfo_retries else timeout_message
        )
        self.metainfo_fetch_timer = QTimer()
        connect(self.metainfo_fetch_timer.timeout, self.perform_files_request)
        self.metainfo_fetch_timer.setSingleShot(True)
        self.metainfo_fetch_timer.start(METAINFO_TIMEOUT)

        self.metainfo_retries += 1


# 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 perform_files_request(self):
    if self.closed:
        return

    direct = not self.dialog_widget.anon_download_checkbox.isChecked()
    request = f"torrentinfo?uri={quote_plus_unicode(self.download_uri)}"
    if direct is True:
        request = request + f"&hops=0"
    self.rest_request = TriblerNetworkRequest(
        request, self.on_received_metainfo, capture_core_errors=False
    )

    if self.metainfo_retries <= METAINFO_MAX_RETRIES:
        fetch_mode = "directly" if direct else "anonymously"
        loading_message = f"Loading torrent files {fetch_mode}..."
        timeout_message = f"Timeout in fetching files {fetch_mode}. Retrying ({self.metainfo_retries}/{METAINFO_MAX_RETRIES})"

        self.dialog_widget.loading_files_label.setText(
            loading_message if not self.metainfo_retries else timeout_message
        )
        self.metainfo_fetch_timer = QTimer()
        connect(self.metainfo_fetch_timer.timeout, self.perform_files_request)
        self.metainfo_fetch_timer.setSingleShot(True)
        self.metainfo_fetch_timer.start(METAINFO_TIMEOUT)

        self.metainfo_retries += 1