From 1c5e50b9d07f9f632172a4444c2a46174a2b136c Mon Sep 17 00:00:00 2001 From: David Bannon Date: Sun, 20 Oct 2024 22:19:06 +1100 Subject: [PATCH] Prevent Race Condition when saving first config (SearchTitleOnly) and supply default path for user selected path to notes --- package/package.bash | 5 ++--- source/Tomboy_NG.lpi | 4 ++-- source/mvxwindow.pas | 4 ++-- source/searchunit.pas | 5 +++-- source/settings.lfm | 8 ++++---- source/settings.pas | 41 +++++++++++++++++++---------------------- 6 files changed, 32 insertions(+), 35 deletions(-) diff --git a/package/package.bash b/package/package.bash index 26766e8..c515000 100644 --- a/package/package.bash +++ b/package/package.bash @@ -433,8 +433,7 @@ echo "----- LAZ_CONFIG is $LAZ_CONFIG ------" -# Note: because we must build Qt6 on later that U20.04 and for all others, we must build on U20.04 -# due to the libc issue, we cannot build our qt6 one all at the same time. +# Note: as of Oct 2024, we can build our Qt6 one here and now too. rm -f changelog # we build a new one from ../debian/changelog and ../whatsnew each run @@ -442,7 +441,7 @@ if [ "$2" != "" ]; then JustMakeBinary "$2" # Does not return. fi -for BIN in ReleaseLin64 ReleaseLin32 ReleaseWin64 ReleaseWin32 ReleaseRasPi ReleaseQT5; # ReleaseQt6 etc, not yet ! Must build elsewhere, bring biary here. +for BIN in ReleaseLin64 ReleaseLin32 ReleaseWin64 ReleaseWin32 ReleaseRasPi ReleaseQT5 ReleaseQt6; do BuildAMode $BIN; done diff --git a/source/Tomboy_NG.lpi b/source/Tomboy_NG.lpi index 559f3dc..23ad23d 100644 --- a/source/Tomboy_NG.lpi +++ b/source/Tomboy_NG.lpi @@ -1069,7 +1069,7 @@ - + @@ -1081,7 +1081,7 @@ - + diff --git a/source/mvxwindow.pas b/source/mvxwindow.pas index 24e9e2f..c89cf92 100644 --- a/source/mvxwindow.pas +++ b/source/mvxwindow.pas @@ -206,8 +206,8 @@ function MvXWinWorkSpace(Caption : string; WorkS : integer) : boolean; WorkS := CurrentWorkSpace(Disp, RootWin); WinID := 0; if not FindWindowCaption(Caption, Disp, RootWin, WinID) or (WinID = 0) then begin - MvXWinError := 'ERROR - Failed to find that Window !'; - writeln('MvXWinError - Failed to find that Window [', Caption, ']'); + MvXWinError := 'Info - Failed to find that Window !'; + writeln('MvXWin Info - Failed to find that Window [', Caption, ']'); XCloseDisplay(Disp); exit(false); end; diff --git a/source/searchunit.pas b/source/searchunit.pas index e90f553..6313b87 100644 --- a/source/searchunit.pas +++ b/source/searchunit.pas @@ -1304,7 +1304,7 @@ procedure TSearchForm.FormCreate(Sender: TObject); end; end; MenuItemCaseSensitive.checked := Sett.SearchCaseSensitive; - MenuItemSearchTitleOnly.Checked := Sett.SearchOnTitleOnly; + MenuItemSearchTitleOnly.Checked := Sett.SearchTitleOnly; LabelSearchTitle.Visible := MenuItemSearchTitleOnly.Checked; MenuItemSWYT.checked := Sett.AutoSearchUpdate; MenuItemImportNote.Hint := rsHelpImportFile; // Hint shows on StatusBar @@ -1997,7 +1997,8 @@ procedure TSearchForm.MenuItemSearchTitleOnlyClick(Sender : TObject); // Notebook filter is not affected by swap, so if if no active search term, // do nothing. But if we have a search term (>2char) and we are switching form // Title to content (ie expect more 'hits') RefineSearch() is NOT enough - Sett.SaveSettings(sender); + Sett.SearchTitleOnly := MenuItemSearchTitleOnly.Checked; + // Sett.SaveSettings(sender); end; procedure TSearchForm.ButtonClearSearchClick(Sender: TObject); diff --git a/source/settings.lfm b/source/settings.lfm index 7994bb8..a281ce2 100644 --- a/source/settings.lfm +++ b/source/settings.lfm @@ -24,10 +24,10 @@ object Sett: TSett Height = 488 Top = 0 Width = 726 - ActivePage = TabSync + ActivePage = TabBasic Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Bottom = 2 - TabIndex = 2 + TabIndex = 0 TabOrder = 0 OnChange = PageControl1Change object TabBasic: TTabSheet @@ -195,7 +195,7 @@ object Sett: TSett Left = 10 Height = 22 Top = 8 - Width = 158 + Width = 162 BorderSpacing.Left = 10 Caption = 'tomboy-ng Default' Checked = True @@ -1410,7 +1410,7 @@ object Sett: TSett OnClick = SpeedButHelpClick end object SelectDirectoryDialog1: TSelectDirectoryDialog - Options = [ofShareAware, ofEnableSizing] + Options = [ofShareAware, ofEnableSizing, ofForceShowHidden] Left = 408 end object OpenDialogLibrary: TOpenDialog diff --git a/source/settings.pas b/source/settings.pas index c447545..1f598ae 100644 --- a/source/settings.pas +++ b/source/settings.pas @@ -122,7 +122,7 @@ interface Buttons, ComCtrls, ExtCtrls, Menus, FileUtil, BackUpView, LCLIntf, Spin{, notifier}, base64, fpttf, LMessages, syncutils, LazUTF8 {$ifdef LCLQT5}, qt5{$endif} - {$ifdef LCLQT6}, qt6{$endif} ; + {$ifdef LCLQT6}, qt6{$endif} , Types; // Types; @@ -299,7 +299,7 @@ TSett = class(TForm) procedure SetColours; private - + fSearchTitleOnly : boolean; // memory for property SearchTitleOnly TheHomeDir : string; SyncTimingFileIndex, SyncTimingGithubIndex : integer; // Holds ComboBox index for each particular sync SyncTimingFileLast, SyncTimingGitHubLast : TDateTime; // The time the last indicated sync was run (manual or auto). @@ -385,6 +385,7 @@ TSett = class(TForm) function fHomeDir : string; procedure fSetCaseSensitive(IsIt : boolean); //function ZipDate: string; + procedure fSetSearchTitleOnly(ItIs : boolean); public HelpNotesPath : string; // expected path to help note directories for this OS @@ -427,7 +428,7 @@ TSett = class(TForm) { Indicates Spell is configured and LabelLibrary and LabelDic should contain valid full file names.} SpellConfig : boolean; - SearchOnTitleOnly : boolean; +// SearchOnTitleOnly : boolean; // Checks to ensure no threads are running. Will hold // up an App exits for up to 5 seconds. procedure CloseNowPlease(); @@ -444,6 +445,8 @@ TSett = class(TForm) // Does not appear to be implemented property ExportPath : ANSIString Read fExportPath write fExportPath; + property SearchTitleOnly : boolean read fSearchTitleOnly write fSetSearchTitleOnly; + // Returns users home dir inc trailing slash property HomeDir : String Read fHomeDir; @@ -625,6 +628,13 @@ procedure TSett.fSetCaseSensitive(IsIt : boolean); WriteConfigFile(); end; +procedure TSett.fSetSearchTitleOnly(ItIs : boolean); +begin + fSearchTitleOnly := ItIs; + if Not MaskSettingsChanged then + WriteConfigFile(); +end; + procedure TSett.PageControl1Change(Sender: TObject); begin // if NoteDirectory = '' then ButtDefaultNoteDirClick(self); @@ -879,6 +889,7 @@ procedure TSett.FormCreate(Sender: TObject); i : integer; begin // gTTFontCache.ReadStandardFonts; // we do this in Kmemo2PDR now. + fSearchTitleOnly := False; NotesSavedAtClose := 0; // Inc'ed in Main FormClose, dec'ed when a note save finshes (at close time) Caption := 'tomboy-ng Settings'; ButtonSetNotePath.Enabled := False; @@ -1044,7 +1055,7 @@ procedure TSett.ReadConfigFile; ('true' = ConfigFile.readstring('BasicSettings', 'UseUndo', 'true')); SearchCaseSensitive := ('true' = Configfile.readstring('BasicSettings', 'CaseSensitive', 'false')); - SearchOnTitleOnly := + SearchTitleOnly := ('true' = Configfile.readstring('BasicSettings', 'SearchOnTitle', 'false')); CheckShowSplash.Checked := ('true' = Configfile.ReadString('BasicSettings', 'ShowSplash', 'true')); @@ -1207,6 +1218,7 @@ function TSett.MyBoolStr(const InBool : boolean) : string; end; function TSett.WriteConfigFile(IgnoreMask : boolean = false; WriteLastSync : boolean = false) : boolean; +// Warning, this gets called before Sett is created with a new installation. var ConfigFile : TINIFile; i : integer; @@ -1221,7 +1233,7 @@ function TSett.WriteConfigFile(IgnoreMask : boolean = false; WriteLastSync : boo ConfigFile.writestring('BasicSettings', 'NotesPath', NoteDirectory); Configfile.writestring('BasicSettings', 'ManyNotebooks', MyBoolStr(CheckManyNoteBooks.checked)); Configfile.writestring('BasicSettings', 'CaseSensitive', MyBoolStr(SearchCaseSensitive)); - Configfile.writestring('BasicSettings', 'SearchOnTitle', MyBoolStr(SearchForm.MenuItemSearchTitleOnly.Checked)); + Configfile.writestring('BasicSettings', 'SearchOnTitle', MyBoolStr(SearchTitleOnly)); ConfigFile.writestring('BasicSettings', 'ShowIntLinks', MyBoolStr(CheckShowIntLinks.Checked)); ConfigFile.writestring('BasicSettings', 'ShowExtLinks', MyBoolStr(CheckShowExtLinks.Checked)); ConfigFile.WriteString('BasicSettings', 'ShowSplash', MyBoolStr(CheckShowSplash.Checked)); @@ -1456,27 +1468,12 @@ procedure TSett.ButtonSetNotePathClick(Sender: TObject); APath : string; begin if not DidCleanAndLockSync() then exit; // Also flush notes + SelectDirectoryDialog1.InitialDir := LabelNotesPath.Caption; if SelectDirectoryDialog1.Execute then begin APath := TrimFilename(SelectDirectoryDialog1.FileName + PathDelim); SetNotePath(APath); - -(* if CheckDirectory(NoteDirectory) then begin - if not FindFirst(NoteDirectory + '*.note', faAnyFile and faDirectory, Info)=0 then begin - showmessage(rsDirHasNoNotes); - end; - FindClose(Info); - CheckShowIntLinks.enabled := true; // Why is this here ???? - // CheckReadOnly.enabled := true; - // SyncFileAuto := False; - // SyncGithubAuto := False; - ComboSyncTypeChange(self); - WriteConfigFile(); - SyncSettings(); - SearchForm.IndexNotes(True); - end else - NoteDirectory := LabelNotesPath.caption; *) end; - + SelectDirectoryDialog1.InitialDir := ''; end; { Colors - most colors will be right, as set instructed by the OS. However, the