(self, event: QtGui.QCloseEvent)
| 443 | self.save_geometry() |
| 444 | |
| 445 | def closeEvent(self, event: QtGui.QCloseEvent) -> None: |
| 446 | self.save_geometry() |
| 447 | self.settings.settings.sync() |
| 448 | |
| 449 | if self.folder_watcher: |
| 450 | try: |
| 451 | self.folder_watcher.task_found.disconnect() |
| 452 | if len(self.folder_watcher.directories()) > 0: |
| 453 | self.folder_watcher.removePaths(self.folder_watcher.directories()) |
| 454 | except Exception as e: |
| 455 | logging.warning(f"Error cleaning up folder watcher: {e}") |
| 456 | |
| 457 | try: |
| 458 | self.transcriber_worker.task_started.disconnect() |
| 459 | self.transcriber_worker.task_progress.disconnect() |
| 460 | self.transcriber_worker.task_download_progress.disconnect() |
| 461 | self.transcriber_worker.task_error.disconnect() |
| 462 | self.transcriber_worker.task_completed.disconnect() |
| 463 | except Exception as e: |
| 464 | logging.warning(f"Error disconnecting signals: {e}") |
| 465 | |
| 466 | self.transcriber_worker.stop() |
| 467 | self.transcriber_thread.quit() |
| 468 | |
| 469 | if self.transcriber_thread.isRunning(): |
| 470 | if not self.transcriber_thread.wait(10000): |
| 471 | logging.warning("Transcriber thread did not finish within 10s timeout, terminating") |
| 472 | self.transcriber_thread.terminate() |
| 473 | if not self.transcriber_thread.wait(2000): |
| 474 | logging.error("Transcriber thread could not be terminated") |
| 475 | |
| 476 | if self.transcription_viewer_widget is not None: |
| 477 | self.transcription_viewer_widget.close() |
| 478 | |
| 479 | try: |
| 480 | from buzz.widgets.application import Application |
| 481 | app = Application.instance() |
| 482 | if app and hasattr(app, 'close_database'): |
| 483 | app.close_database() |
| 484 | except Exception as e: |
| 485 | logging.warning(f"Error closing database: {e}") |
| 486 | |
| 487 | logging.debug("MainWindow closeEvent completed") |
| 488 | |
| 489 | super().closeEvent(event) |
| 490 | |
| 491 | def save_geometry(self): |
| 492 | self.settings.begin_group(Settings.Key.MAIN_WINDOW) |
nothing calls this directly
no test coverage detected