Skip to content

Commit 34f30b6

Browse files
Clean up observers and resources in various panels to prevent memory leaks
1 parent 0fc2dfb commit 34f30b6

File tree

6 files changed

+56
-32
lines changed

6 files changed

+56
-32
lines changed

po/fr.po

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: gorfector master\n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2025-05-28 12:19-0400\n"
10+
"POT-Creation-Date: 2025-05-28 12:49-0400\n"
1111
"PO-Revision-Date: 2025-05-27 18:03-0400\n"
1212
"Last-Translator: Patrick Fournier <>\n"
1313
"Language-Team: French - Canada\n"
@@ -348,7 +348,7 @@ msgid "Scanners Settings"
348348
msgstr "Paramètres du périphérique"
349349

350350
#: ../po/../src/PresetCreateDialog.cpp:140
351-
#: ../po/../src/ScanOptionsPanel.cpp:462 scanners/scanner_strings.h:44
351+
#: ../po/../src/ScanOptionsPanel.cpp:473 scanners/scanner_strings.h:44
352352
msgid "Scan Area"
353353
msgstr "Zone de numérisation"
354354

@@ -436,7 +436,7 @@ msgstr "Inspecter le préréglage"
436436
msgid "Zoom:"
437437
msgstr "Zoom:"
438438

439-
#: ../po/../src/PreviewPanel.cpp:869
439+
#: ../po/../src/PreviewPanel.cpp:873
440440
msgid "Progress: "
441441
msgstr "Progrès: "
442442

@@ -526,55 +526,55 @@ msgstr "%%"
526526
msgid "μs"
527527
msgstr "μs"
528528

529-
#: ../po/../src/ScanOptionsPanel.cpp:416
529+
#: ../po/../src/ScanOptionsPanel.cpp:427
530530
msgid "Basic"
531531
msgstr "Basique"
532532

533-
#: ../po/../src/ScanOptionsPanel.cpp:420 scanners/scanner_strings.h:17
533+
#: ../po/../src/ScanOptionsPanel.cpp:431 scanners/scanner_strings.h:17
534534
msgid "Advanced"
535535
msgstr "Avancé"
536536

537-
#: ../po/../src/ScanOptionsPanel.cpp:425
537+
#: ../po/../src/ScanOptionsPanel.cpp:436
538538
msgid "Output"
539539
msgstr "Sortie"
540540

541-
#: ../po/../src/ScanOptionsPanel.cpp:446
541+
#: ../po/../src/ScanOptionsPanel.cpp:457
542542
msgid "Common Options"
543543
msgstr "Options communes"
544544

545-
#: ../po/../src/ScanOptionsPanel.cpp:510 ../po/../src/ScanOptionsPanel.cpp:515
545+
#: ../po/../src/ScanOptionsPanel.cpp:521 ../po/../src/ScanOptionsPanel.cpp:526
546546
msgid "Destination"
547547
msgstr "Destination"
548548

549-
#: ../po/../src/ScanOptionsPanel.cpp:530
549+
#: ../po/../src/ScanOptionsPanel.cpp:541
550550
msgid "Location"
551551
msgstr "Répertoire"
552552

553-
#: ../po/../src/ScanOptionsPanel.cpp:531
553+
#: ../po/../src/ScanOptionsPanel.cpp:542
554554
msgid "The directory where the scanned files will be saved."
555555
msgstr "Le répertoire dans lequel les images seront enregistrées."
556556

557-
#: ../po/../src/ScanOptionsPanel.cpp:546
557+
#: ../po/../src/ScanOptionsPanel.cpp:557
558558
msgid "Browse for a location."
559559
msgstr "Choisir un répertoire."
560560

561-
#: ../po/../src/ScanOptionsPanel.cpp:552
561+
#: ../po/../src/ScanOptionsPanel.cpp:563
562562
msgid "Create Missing Directories"
563563
msgstr "Créer les répertoires manquants"
564564

565-
#: ../po/../src/ScanOptionsPanel.cpp:553
565+
#: ../po/../src/ScanOptionsPanel.cpp:564
566566
msgid "Create directories if they do not exist."
567567
msgstr "Créer les répertoires qui n'existent pas."
568568

569-
#: ../po/../src/ScanOptionsPanel.cpp:562
569+
#: ../po/../src/ScanOptionsPanel.cpp:573
570570
msgid "File Name"
571571
msgstr "Nom du fichier"
572572

573-
#: ../po/../src/ScanOptionsPanel.cpp:575
573+
#: ../po/../src/ScanOptionsPanel.cpp:586
574574
msgid "If File Exists"
575575
msgstr "Si le fichier existe"
576576

577-
#: ../po/../src/ScanOptionsPanel.cpp:610
577+
#: ../po/../src/ScanOptionsPanel.cpp:621
578578
msgid "Select Destination"
579579
msgstr "Choisir la destination"
580580

po/gorfector.pot

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2025-05-28 12:19-0400\n"
11+
"POT-Creation-Date: 2025-05-28 12:49-0400\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -327,7 +327,7 @@ msgid "Scanners Settings"
327327
msgstr ""
328328

329329
#: ../po/../src/PresetCreateDialog.cpp:140
330-
#: ../po/../src/ScanOptionsPanel.cpp:462 scanners/scanner_strings.h:44
330+
#: ../po/../src/ScanOptionsPanel.cpp:473 scanners/scanner_strings.h:44
331331
msgid "Scan Area"
332332
msgstr ""
333333

@@ -415,7 +415,7 @@ msgstr ""
415415
msgid "Zoom:"
416416
msgstr ""
417417

418-
#: ../po/../src/PreviewPanel.cpp:869
418+
#: ../po/../src/PreviewPanel.cpp:873
419419
msgid "Progress: "
420420
msgstr ""
421421

@@ -505,55 +505,55 @@ msgstr ""
505505
msgid "μs"
506506
msgstr ""
507507

508-
#: ../po/../src/ScanOptionsPanel.cpp:416
508+
#: ../po/../src/ScanOptionsPanel.cpp:427
509509
msgid "Basic"
510510
msgstr ""
511511

512-
#: ../po/../src/ScanOptionsPanel.cpp:420 scanners/scanner_strings.h:17
512+
#: ../po/../src/ScanOptionsPanel.cpp:431 scanners/scanner_strings.h:17
513513
msgid "Advanced"
514514
msgstr ""
515515

516-
#: ../po/../src/ScanOptionsPanel.cpp:425
516+
#: ../po/../src/ScanOptionsPanel.cpp:436
517517
msgid "Output"
518518
msgstr ""
519519

520-
#: ../po/../src/ScanOptionsPanel.cpp:446
520+
#: ../po/../src/ScanOptionsPanel.cpp:457
521521
msgid "Common Options"
522522
msgstr ""
523523

524-
#: ../po/../src/ScanOptionsPanel.cpp:510 ../po/../src/ScanOptionsPanel.cpp:515
524+
#: ../po/../src/ScanOptionsPanel.cpp:521 ../po/../src/ScanOptionsPanel.cpp:526
525525
msgid "Destination"
526526
msgstr ""
527527

528-
#: ../po/../src/ScanOptionsPanel.cpp:530
528+
#: ../po/../src/ScanOptionsPanel.cpp:541
529529
msgid "Location"
530530
msgstr ""
531531

532-
#: ../po/../src/ScanOptionsPanel.cpp:531
532+
#: ../po/../src/ScanOptionsPanel.cpp:542
533533
msgid "The directory where the scanned files will be saved."
534534
msgstr ""
535535

536-
#: ../po/../src/ScanOptionsPanel.cpp:546
536+
#: ../po/../src/ScanOptionsPanel.cpp:557
537537
msgid "Browse for a location."
538538
msgstr ""
539539

540-
#: ../po/../src/ScanOptionsPanel.cpp:552
540+
#: ../po/../src/ScanOptionsPanel.cpp:563
541541
msgid "Create Missing Directories"
542542
msgstr ""
543543

544-
#: ../po/../src/ScanOptionsPanel.cpp:553
544+
#: ../po/../src/ScanOptionsPanel.cpp:564
545545
msgid "Create directories if they do not exist."
546546
msgstr ""
547547

548-
#: ../po/../src/ScanOptionsPanel.cpp:562
548+
#: ../po/../src/ScanOptionsPanel.cpp:573
549549
msgid "File Name"
550550
msgstr ""
551551

552-
#: ../po/../src/ScanOptionsPanel.cpp:575
552+
#: ../po/../src/ScanOptionsPanel.cpp:586
553553
msgid "If File Exists"
554554
msgstr ""
555555

556-
#: ../po/../src/ScanOptionsPanel.cpp:610
556+
#: ../po/../src/ScanOptionsPanel.cpp:621
557557
msgid "Select Destination"
558558
msgstr ""
559559

src/PreferencesView.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,12 @@ namespace Gorfector
265265
m_Dispatcher.UnregisterHandler<SetTiffJpegQuality>();
266266
m_Dispatcher.UnregisterHandler<SetPngCompressionLevel>();
267267
m_Dispatcher.UnregisterHandler<SetJpegQuality>();
268+
m_Dispatcher.UnregisterHandler<SetDumpSaneOptions>();
268269

269270
m_App->GetObserverManager()->RemoveObserver(m_ViewUpdateObserver);
270271
delete m_ViewUpdateObserver;
272+
273+
m_ViewUpdateObserver = nullptr;
271274
}
272275

273276
/**

src/PresetPanel.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,13 @@ namespace Gorfector
126126
m_App->GetObserverManager()->RemoveObserver(m_ViewUpdateObserver);
127127
m_App->GetObserverManager()->RemoveObserver(m_CurrentDeviceObserver);
128128

129+
delete m_ViewUpdateObserver;
130+
delete m_CurrentDeviceObserver;
129131
delete m_PresetPanelState;
132+
133+
m_ViewUpdateObserver = nullptr;
134+
m_CurrentDeviceObserver = nullptr;
135+
m_PresetPanelState = nullptr;
130136
}
131137

132138
[[nodiscard]] PresetPanelState *GetState() const

src/PreviewPanel.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,12 @@ Gorfector::PreviewPanel::~PreviewPanel()
8989
m_Dispatcher.UnregisterHandler<SetZoomCommand>();
9090

9191
m_App->GetObserverManager()->RemoveObserver(m_ViewUpdateObserver);
92+
9293
delete m_ViewUpdateObserver;
9394
delete m_PreviewState;
95+
96+
m_ViewUpdateObserver = nullptr;
97+
m_PreviewState = nullptr;
9498
}
9599

96100
void Gorfector::PreviewPanel::OnResized(GtkWidget *widget, void *data, void *)

src/ScanOptionsPanel.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,21 @@ Gorfector::ScanOptionsPanel::~ScanOptionsPanel()
377377
m_Dispatcher.UnregisterHandler<ChangeOptionCommand<int>>();
378378
m_Dispatcher.UnregisterHandler<ChangeOptionCommand<std::string>>();
379379

380+
m_Dispatcher.UnregisterHandler<SetOutputDestinationCommand>();
381+
m_Dispatcher.UnregisterHandler<SetOutputDirectoryCommand>();
382+
m_Dispatcher.UnregisterHandler<SetCreateMissingDirectoriesCommand>();
383+
m_Dispatcher.UnregisterHandler<SetOutputFileNameCommand>();
384+
m_Dispatcher.UnregisterHandler<SetFileExistsActionCommand>();
385+
380386
m_App->GetObserverManager()->RemoveObserver(m_OptionUpdateObserver);
381387
delete m_OptionUpdateObserver;
382388

383389
delete m_DeviceOptions;
390+
delete m_OutputOptions;
391+
392+
m_OptionUpdateObserver = nullptr;
393+
m_DeviceOptions = nullptr;
394+
m_OutputOptions = nullptr;
384395
}
385396

386397
void Gorfector::ScanOptionsPanel::BuildUI()

0 commit comments

Comments
 (0)