From d2f253087b95b1d55e01706056e3a63e61249cd5 Mon Sep 17 00:00:00 2001
From: Mauro Cavalcanti
Date: Sat, 16 Sep 2023 17:24:11 -0300
Subject: [PATCH] Fixed access violantion errors
---
dtp/Especies.lpi | 3 +-
dtp/Especies.lps | 123 +++++++++++++++++++++++++----------------------
dtp/Especies.res | Bin 12168 -> 12168 bytes
dtp/biows.pas | 16 +++---
dtp/main.pas | 39 +++++++++------
5 files changed, 99 insertions(+), 82 deletions(-)
diff --git a/dtp/Especies.lpi b/dtp/Especies.lpi
index d67678a..834d060 100644
--- a/dtp/Especies.lpi
+++ b/dtp/Especies.lpi
@@ -18,7 +18,7 @@
-
+
@@ -75,6 +75,7 @@
+
diff --git a/dtp/Especies.lps b/dtp/Especies.lps
index 28c9424..469c06a 100644
--- a/dtp/Especies.lps
+++ b/dtp/Especies.lps
@@ -4,13 +4,13 @@
-
+
-
+
@@ -19,10 +19,11 @@
-
-
-
+
+
+
+
@@ -33,7 +34,7 @@
-
+
@@ -56,131 +57,139 @@
-
-
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
diff --git a/dtp/Especies.res b/dtp/Especies.res
index add97981f69c3e9d93273a8fdc861136563b1f78..b54ca00c079b5001381cdf2c9ccdf333be507987 100644
GIT binary patch
delta 20
bcmeB(?}*>v#m>k!*_-_v#m>k&*_-_Wx4tI3`Nn8d{
diff --git a/dtp/biows.pas b/dtp/biows.pas
index 5353c5a..09438c4 100644
--- a/dtp/biows.pas
+++ b/dtp/biows.pas
@@ -326,7 +326,7 @@ destructor TWikiSearch.Destroy;
inherited Destroy;
end;
-(*function TWikiSearch.Snippet(const searchStr: string): string;
+function TWikiSearch.Snippet(const searchStr: string): string;
var
JsonData: TJsonData;
Client: TFPHttpClient;
@@ -346,9 +346,9 @@ destructor TWikiSearch.Destroy;
JsonData.Free;
Client.Free;
end;
-end;*)
+end;
-function TWikiSearch.Snippet(const searchStr: string): string;
+(*function TWikiSearch.Snippet(const searchStr: string): string;
var
JsonData: TJsonData;
queryStr: string;
@@ -374,9 +374,9 @@ function TWikiSearch.Snippet(const searchStr: string): string;
JsonData.Free;
Client.Free;
end;
-end;
+end;*)
-(*{ Search images from Wikimedia Commons }
+{ Search images from Wikimedia Commons }
function TWikiSearch.Images(const searchStr: string; limit: integer = 10): TStringList;
var
JsonData, JsonItem, JsonItems: TJsonData;
@@ -412,9 +412,9 @@ function TWikiSearch.Images(const searchStr: string; limit: integer = 10): TStri
JsonData.Free;
Client.Free;
end;
-end; *)
+end;
-function TWikiSearch.Images(const searchStr: string; limit: integer = 10): TStringList;
+(*function TWikiSearch.Images(const searchStr: string; limit: integer = 10): TStringList;
var
JsonData, JsonItem, JsonItems: TJsonData;
i, Count: integer;
@@ -454,7 +454,7 @@ function TWikiSearch.Images(const searchStr: string; limit: integer = 10): TStri
JsonData.Free;
Client.Free;
end;
-end;
+end;*)
{ TFFSearch methods }
diff --git a/dtp/main.pas b/dtp/main.pas
index bee7530..8661b9a 100644
--- a/dtp/main.pas
+++ b/dtp/main.pas
@@ -32,6 +32,8 @@
{ Wikipedia }
{ Version 1.05, 17th Aug 23 - Changed the code for retrieving data from }
{ FiveFilters and NCBI }
+{ Version 1.06, 14th Sep 23 - Fixed access violation errors when handling }
+{ Wikipedia redirections }
{===============================================================================}
unit main;
@@ -204,6 +206,7 @@ procedure TMainForm.DoSearch(const queryStr: string);
urlWiki, tagWord, tagHTML, refUrl, imgUrl, taxUrl, urlId, UrlNuc,
urlProt, itemStr, baseMapUrl, pointsUrl: string;
targetDir: string;
+ s: string;
key, taxId, nucNum, protNum: integer;
i, nrecs: integer;
linkOut, linkIn, imgs, tags, pubs: TStringList;
@@ -261,21 +264,26 @@ procedure TMainForm.DoSearch(const queryStr: string);
snippet := WikiSearch.Snippet(queryStr);
Application.ProcessMessages;
StatusBar.SimpleText := 'Building keyword list...';
- FFSearch := TFFSearch.Create;
- tags := FFSearch.termExtract(snippet, 10);
- tagHTML := '';
- Results.Add('Text tags
');
- for i := 0 to tags.Count - 1 do
+ if Length(snippet) = 0 then
+ Results.Add('No text tags')
+ else
begin
- tagWord := tags[i];
- tagWord := StringReplace(tagWord, ' ', ' ', [rfReplaceAll]);
- if Length(tagWord) > 0 then
- tagHTML := tagHTML +
- ''
- + tagWord + ' ' + '';
+ FFSearch := TFFSearch.Create;
+ tags := FFSearch.termExtract(snippet, 10);
+ tagHTML := '';
+ Results.Add('Text tags
');
+ for i := 0 to tags.Count - 1 do
+ begin
+ tagWord := tags[i];
+ tagWord := StringReplace(tagWord, ' ', ' ', [rfReplaceAll]);
+ if Length(tagWord) > 0 then
+ tagHTML := tagHTML +
+ ''
+ + tagWord + ' ' + '';
+ end;
+ Results.Add(tagHTML);
+ FFSearch.Destroy;
end;
- Results.Add(tagHTML);
- FFSearch.Destroy;
urlWiki := 'http://en.wikipedia.org/wiki/' +
StringReplace(queryStr, ' ', '_', [rfReplaceAll]);
@@ -351,9 +359,8 @@ 'https://api.gbif.org/v2/map/occurrence/density/0/0/0@1x.png?style=classic
DeleteFile(targetDir + 'points.png');
taxUrl := '';
Results.Add('' + taxUrl + IntToStr(nrecs) + ' record(s)
');
- Results.Add(taxUrl +
- '');
+ Results.Add(taxUrl + '');
end;
Application.ProcessMessages;