From cec97bd2d04cbb602b6d04797e6ce6c375d05c0e Mon Sep 17 00:00:00 2001 From: SDXC Date: Fri, 6 Sep 2019 17:47:07 +0200 Subject: [PATCH] Fixed performance problems on startup while sorting the download list (Issue #383) --- baseunits/uDownloadsManager.pas | 3 --- baseunits/uSilentThread.pas | 4 +++- mangadownloader/forms/frmMain.pas | 6 ++++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/baseunits/uDownloadsManager.pas b/baseunits/uDownloadsManager.pas index d8a4edff3..7e25c45bf 100644 --- a/baseunits/uDownloadsManager.pas +++ b/baseunits/uDownloadsManager.pas @@ -1114,9 +1114,6 @@ procedure TTaskContainer.SetEnabled(AValue: Boolean); constructor TTaskContainer.Create; begin inherited Create; - - if OptionSortDownloadsWhenAddingNewDownloadTasks then - DLManager.Sort(DLManager.SortColumn); DlId := -1; InitCriticalSection(CS_Container); diff --git a/baseunits/uSilentThread.pas b/baseunits/uSilentThread.pas index 5a7dfc171..68f2eafb5 100644 --- a/baseunits/uSilentThread.pas +++ b/baseunits/uSilentThread.pas @@ -16,7 +16,7 @@ interface uses SysUtils, fgl, uBaseUnit, uData, uDownloadsManager, - WebsiteModules, FMDOptions, httpsendthread, BaseThread, LazFileUtils; + WebsiteModules, FMDOptions, httpsendthread, BaseThread, LazFileUtils, MultiLog; type @@ -185,6 +185,8 @@ procedure TSilentThreadManager.Add(AType: TMetaDataType; finally LeaveCriticalsection(FCS_META); end; + if OptionSortDownloadsWhenAddingNewDownloadTasks then + DLManager.Sort(DLManager.SortColumn); end; end; diff --git a/mangadownloader/forms/frmMain.pas b/mangadownloader/forms/frmMain.pas index 359bd5eae..3b93d222e 100644 --- a/mangadownloader/forms/frmMain.pas +++ b/mangadownloader/forms/frmMain.pas @@ -2521,8 +2521,8 @@ procedure TMainForm.btDownloadClick(Sender: TObject); CurrentDownloadChapterPtr:=0; SaveToDB(newdl); end; - if OptionSortDownloadsWhenAddingNewDownloadTasks then - DLManager.Sort(DLManager.SortColumn); + if OptionSortDownloadsWhenAddingNewDownloadTasks then + DLManager.Sort(DLManager.SortColumn); end; DLManager.DownloadedChapters.Chapters[mangaInfo.website+mangaInfo.link]:=links.Text; FavoriteManager.AddToDownloadedChaptersList(mangaInfo.website,mangaInfo.link,links); @@ -4067,7 +4067,9 @@ procedure TMainForm.vtDownloadDragDrop(Sender : TBaseVirtualTree; vtDownloadMoveItems(vtDownload.DropTargetNode^.Index, Mode); end else + begin AddSilentThread(frmDropTarget.GetDropURLs(DataObject), MD_DownloadAll); + end; end; procedure TMainForm.vtDownloadDragOver(Sender : TBaseVirtualTree;