You've already forked lazarus-ccr
LazMapViewer: Disable creating the cache directory at designtime. Partial sync with main full_demo project.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8840 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -18,7 +18,6 @@ object MainForm: TMainForm
|
|||||||
Top = 0
|
Top = 0
|
||||||
Width = 608
|
Width = 608
|
||||||
Align = alClient
|
Align = alClient
|
||||||
CachePath = '../../../../cache/'
|
|
||||||
Cyclic = True
|
Cyclic = True
|
||||||
DefaultTrackColor = clBlue
|
DefaultTrackColor = clBlue
|
||||||
DefaultTrackWidth = 3
|
DefaultTrackWidth = 3
|
||||||
|
@ -145,12 +145,10 @@ type
|
|||||||
const
|
const
|
||||||
MAX_LOCATIONS_HISTORY = 50;
|
MAX_LOCATIONS_HISTORY = 50;
|
||||||
MAP_PROVIDER_FILENAME = 'map-providers.xml';
|
MAP_PROVIDER_FILENAME = 'map-providers.xml';
|
||||||
HOMEDIR = '../../../../';
|
|
||||||
USE_DMS = true;
|
USE_DMS = true;
|
||||||
|
|
||||||
var
|
var
|
||||||
PointFormatSettings: TFormatsettings;
|
PointFormatSettings: TFormatsettings;
|
||||||
CacheDir: String = HOMEDIR + 'cache/'; // share the cache in both example projects
|
|
||||||
|
|
||||||
function CalcIniName: String;
|
function CalcIniName: String;
|
||||||
begin
|
begin
|
||||||
@ -438,6 +436,8 @@ end;
|
|||||||
|
|
||||||
procedure TMainForm.FormCreate(Sender: TObject);
|
procedure TMainForm.FormCreate(Sender: TObject);
|
||||||
var
|
var
|
||||||
|
homeDir: String;
|
||||||
|
cacheDir: String;
|
||||||
fn: String;
|
fn: String;
|
||||||
begin
|
begin
|
||||||
cInputQueryEditSizePercents := 0;
|
cInputQueryEditSizePercents := 0;
|
||||||
@ -454,15 +454,16 @@ begin
|
|||||||
POIImage.LoadFromFile(fn);
|
POIImage.LoadFromFile(fn);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
CacheDir := HOMEDIR + 'cache/';
|
homeDir := Application.Location + '../../../'; // this should be the "examples" folder
|
||||||
if not ForceDirectories(CacheDir) then
|
cacheDir := homeDir + 'cache/';
|
||||||
|
if not ForceDirectories(cacheDir) then
|
||||||
begin
|
begin
|
||||||
CacheDir := GetAppConfigDir(false) + 'cache/';
|
cacheDir := GetAppConfigDir(false) + 'cache/';
|
||||||
ForceDirectories(CacheDir);
|
ForceDirectories(cacheDir);
|
||||||
end;
|
end;
|
||||||
MapView.CachePath := CacheDir;
|
MapView.CachePath := cacheDir;
|
||||||
MapView.GetMapProviders(CbProviders.Items);
|
MapView.GetMapProviders(CbProviders.Items);
|
||||||
CbProviders.ItemIndex := CbProviders.Items.Indexof(MapView.MapProvider);
|
CbProviders.ItemIndex := CbProviders.Items.IndexOf(MapView.MapProvider);
|
||||||
MapView.DoubleBuffered := true;
|
MapView.DoubleBuffered := true;
|
||||||
MapView.Zoom := 1;
|
MapView.Zoom := 1;
|
||||||
CbZoomToCursor.Checked := MapView.ZoomToCursor;
|
CbZoomToCursor.Checked := MapView.ZoomToCursor;
|
||||||
|
@ -151,7 +151,6 @@ type
|
|||||||
|
|
||||||
const
|
const
|
||||||
MAX_LOCATIONS_HISTORY = 50;
|
MAX_LOCATIONS_HISTORY = 50;
|
||||||
HOMEDIR = '../../../../../'; // share the cache in both fulldemo projects
|
|
||||||
MAP_PROVIDER_FILENAME = 'map-providers.xml';
|
MAP_PROVIDER_FILENAME = 'map-providers.xml';
|
||||||
USE_DMS = true;
|
USE_DMS = true;
|
||||||
|
|
||||||
@ -409,6 +408,8 @@ end;
|
|||||||
procedure TMainForm.FormCreate(Sender: TObject);
|
procedure TMainForm.FormCreate(Sender: TObject);
|
||||||
var
|
var
|
||||||
fn: String;
|
fn: String;
|
||||||
|
homeDir: String;
|
||||||
|
cacheDir: String;
|
||||||
begin
|
begin
|
||||||
cInputQueryEditSizePercents := 0;
|
cInputQueryEditSizePercents := 0;
|
||||||
|
|
||||||
@ -424,8 +425,14 @@ begin
|
|||||||
POIImage.LoadFromFile(fn);
|
POIImage.LoadFromFile(fn);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ForceDirectories(HOMEDIR + 'cache/');
|
homeDir := Application.Location + '../../../'; // this should be the "examples" folder
|
||||||
MapView.CachePath := HOMEDIR + 'cache/';
|
cacheDir := homeDir + 'cache/';
|
||||||
|
if not ForceDirectories(cacheDir) then
|
||||||
|
begin
|
||||||
|
cacheDir := GetAppConfigDir(false) + 'cache/';
|
||||||
|
ForceDirectories(cacheDir);
|
||||||
|
end;
|
||||||
|
MapView.CachePath := cacheDir;
|
||||||
MapView.GetMapProviders(CbProviders.Items);
|
MapView.GetMapProviders(CbProviders.Items);
|
||||||
CbProviders.ItemIndex := CbProviders.Items.IndexOf(MapView.MapProvider);
|
CbProviders.ItemIndex := CbProviders.Items.IndexOf(MapView.MapProvider);
|
||||||
MapView.DoubleBuffered := true;
|
MapView.DoubleBuffered := true;
|
||||||
@ -593,9 +600,11 @@ begin
|
|||||||
HERE_AppID := ini.ReadString('HERE', 'APP_ID', '');
|
HERE_AppID := ini.ReadString('HERE', 'APP_ID', '');
|
||||||
HERE_AppCode := ini.ReadString('HERE', 'APP_CODE', '');
|
HERE_AppCode := ini.ReadString('HERE', 'APP_CODE', '');
|
||||||
OpenWeatherMap_ApiKey := ini.ReadString('OpenWeatherMap', 'API_Key', '');
|
OpenWeatherMap_ApiKey := ini.ReadString('OpenWeatherMap', 'API_Key', '');
|
||||||
|
ThunderForest_ApiKey := ini.ReadString('ThunderForest', 'API_Key', '');
|
||||||
|
|
||||||
if ((HERE_AppID <> '') and (HERE_AppCode <> '')) or
|
if ((HERE_AppID <> '') and (HERE_AppCode <> '')) or
|
||||||
(OpenWeatherMap_ApiKey <> '') then
|
(OpenWeatherMap_ApiKey <> '') or
|
||||||
|
(ThunderForest_ApiKey <> '') then
|
||||||
begin
|
begin
|
||||||
MapView.Engine.ClearMapProviders;
|
MapView.Engine.ClearMapProviders;
|
||||||
MapView.Engine.RegisterProviders;
|
MapView.Engine.RegisterProviders;
|
||||||
@ -766,6 +775,9 @@ begin
|
|||||||
if OpenWeatherMap_ApiKey <> '' then
|
if OpenWeatherMap_ApiKey <> '' then
|
||||||
ini.WriteString('OpenWeatherMap', 'API_Key', OpenWeatherMap_ApiKey);
|
ini.WriteString('OpenWeatherMap', 'API_Key', OpenWeatherMap_ApiKey);
|
||||||
|
|
||||||
|
if ThunderForest_ApiKey <> '' then
|
||||||
|
ini.WriteString('ThunderForest', 'API_Key', ThunderForest_ApiKey);
|
||||||
|
|
||||||
ini.EraseSection('Locations');
|
ini.EraseSection('Locations');
|
||||||
for i := 0 to CbLocations.Items.Count-1 do
|
for i := 0 to CbLocations.Items.Count-1 do
|
||||||
ini.WriteString('Locations', 'Item'+IntToStr(i), CbLocations.Items[i]);
|
ini.WriteString('Locations', 'Item'+IntToStr(i), CbLocations.Items[i]);
|
||||||
|
@ -1282,6 +1282,11 @@ begin
|
|||||||
if FActive = AValue then Exit;
|
if FActive = AValue then Exit;
|
||||||
FActive := AValue;
|
FActive := AValue;
|
||||||
|
|
||||||
|
// One problem at designtime is that the control is creating cache directories
|
||||||
|
// at unexpected places when Cache.BasePath is relative
|
||||||
|
if csDesigning in ComponentState then
|
||||||
|
exit;
|
||||||
|
|
||||||
if not FActive then
|
if not FActive then
|
||||||
Queue.CancelAllJob(self)
|
Queue.CancelAllJob(self)
|
||||||
else begin
|
else begin
|
||||||
@ -1305,7 +1310,6 @@ end;
|
|||||||
|
|
||||||
procedure TMapViewerEngine.SetCachePath(AValue: String);
|
procedure TMapViewerEngine.SetCachePath(AValue: String);
|
||||||
begin
|
begin
|
||||||
ForceDirectories(aValue);
|
|
||||||
Cache.BasePath := aValue;
|
Cache.BasePath := aValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user