fpvectorial: Fix compilation and crash of fpcorelexplorer sample project.

This commit is contained in:
wp_xyz 2023-01-02 17:46:57 +01:00
parent 19662131eb
commit e9a6b95bef
3 changed files with 31 additions and 33 deletions

View File

@ -6,12 +6,12 @@ object formCorelExplorer: TformCorelExplorer
Caption = 'FP Corel Explorer' Caption = 'FP Corel Explorer'
ClientHeight = 345 ClientHeight = 345
ClientWidth = 466 ClientWidth = 466
LCLVersion = '0.9.31' LCLVersion = '2.3.0.0'
object Label1: TLabel object Label1: TLabel
Left = 8 Left = 8
Height = 18 Height = 15
Top = 40 Top = 40
Width = 158 Width = 133
Caption = 'Location of the Input file:' Caption = 'Location of the Input file:'
ParentColor = False ParentColor = False
end end
@ -28,34 +28,36 @@ object formCorelExplorer: TformCorelExplorer
object shellInput: TShellTreeView object shellInput: TShellTreeView
Left = 8 Left = 8
Height = 272 Height = 272
Top = 64 Top = 65
Width = 224 Width = 224
FileSortType = fstFoldersFirst FileSortType = fstFoldersFirst
ReadOnly = True
TabOrder = 0 TabOrder = 0
OnSelectionChanged = shellInputSelectionChanged OnSelectionChanged = shellInputSelectionChanged
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
ObjectTypes = [otFolders, otNonFolders] ObjectTypes = [otFolders, otNonFolders]
end end
object labelFilename: TLabel object labelFilename: TLabel
Left = 256 Left = 256
Height = 18 Height = 15
Top = 65 Top = 65
Width = 62 Width = 51
Caption = 'Filename:' Caption = 'Filename:'
ParentColor = False ParentColor = False
end end
object labelVersion: TLabel object labelVersion: TLabel
Left = 256 Left = 256
Height = 18 Height = 15
Top = 88 Top = 88
Width = 52 Width = 41
Caption = 'Version:' Caption = 'Version:'
ParentColor = False ParentColor = False
end end
object labelSize: TLabel object labelSize: TLabel
Left = 256 Left = 256
Height = 18 Height = 15
Top = 112 Top = 112
Width = 32 Width = 23
Caption = 'Size:' Caption = 'Size:'
ParentColor = False ParentColor = False
end end

View File

@ -53,6 +53,7 @@ var
lFormat: TvVectorialFormat; lFormat: TvVectorialFormat;
lChunk, lCurChunk: TCDRChunk; lChunk, lCurChunk: TCDRChunk;
Str: string; Str: string;
path: String;
begin begin
// First check the in input // First check the in input
if not CheckInput() then Exit; if not CheckInput() then Exit;
@ -60,9 +61,10 @@ begin
// Now read the data from the input file // Now read the data from the input file
Reader := TvCDRVectorialReader.Create; Reader := TvCDRVectorialReader.Create;
try try
Reader.ExploreFromFile(shellInput.GetSelectedNodePath(), lChunk); path := shellInput.GetPathFromNode(shellInput.Selected);
Reader.ExploreFromFile(path, lChunk);
labelFilename.Caption := 'Filename: ' + shellInput.GetSelectedNodePath(); labelFilename.Caption := 'Filename: ' + path;
if (lChunk.ChildChunks <> nil) and (lChunk.ChildChunks.First <> nil) then if (lChunk.ChildChunks <> nil) and (lChunk.ChildChunks.First <> nil) then
begin begin
// Version Chunk // Version Chunk
@ -71,7 +73,7 @@ begin
labelVersion.Caption := 'Version: ' + Str; labelVersion.Caption := 'Version: ' + Str;
// Main data // Main data
lCurChunk := TCDRChunk(lChunk.ChildChunks.Items[1]); lCurChunk := TCDRChunk(lChunk.ChildChunks.Items[0]); // wp: was [1]
//labelSize.Caption := 'Size: ' + ; //labelSize.Caption := 'Size: ' + ;
end; end;
finally finally
@ -83,7 +85,7 @@ function TformCorelExplorer.CheckInput(): Boolean;
var var
lPath: String; lPath: String;
begin begin
lPath := shellInput.GetSelectedNodePath(); lPath := shellInput.GetPathFromNode(shellInput.Selected);
Result := (ExtractFileExt(lPath) = STR_CORELDRAW_EXTENSION); Result := (ExtractFileExt(lPath) = STR_CORELDRAW_EXTENSION);
end; end;

View File

@ -1,11 +1,13 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="UTF-8"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="9"/> <Version Value="12"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<General> <General>
<Flags>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="fpcorelexplorer"/> <Title Value="fpcorelexplorer"/>
<UseXPManifest Value="True"/> <UseXPManifest Value="True"/>
<Icon Value="0"/> <Icon Value="0"/>
@ -13,21 +15,17 @@
<i18n> <i18n>
<EnableI18N LFM="False"/> <EnableI18N LFM="False"/>
</i18n> </i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1"> <BuildModes Count="1">
<Item1 Name="default" Default="True"/> <Item1 Name="default" Default="True"/>
</BuildModes> </BuildModes>
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions> </PublishOptions>
<RunParams> <RunParams>
<local> <FormatVersion Value="2"/>
<FormatVersion Value="1"/> <Modes Count="1">
</local> <Mode0 Name="default"/>
</Modes>
</RunParams> </RunParams>
<RequiredPackages Count="2"> <RequiredPackages Count="2">
<Item1> <Item1>
@ -42,14 +40,13 @@
<Unit0> <Unit0>
<Filename Value="fpcorelexplorer.lpr"/> <Filename Value="fpcorelexplorer.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="fpcorelexplorer"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
<Filename Value="fpce_mainform.pas"/> <Filename Value="fpce_mainform.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<ComponentName Value="formCorelExplorer"/> <ComponentName Value="formCorelExplorer"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="fpce_mainform"/>
</Unit1> </Unit1>
</Units> </Units>
</ProjectOptions> </ProjectOptions>
@ -64,18 +61,15 @@
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths> </SearchPaths>
<Linking> <Linking>
<Debugging>
<DebugInfoType Value="dsDwarf3"/>
</Debugging>
<Options> <Options>
<Win32> <Win32>
<GraphicApplication Value="True"/> <GraphicApplication Value="True"/>
</Win32> </Win32>
</Options> </Options>
</Linking> </Linking>
<Other>
<CompilerMessages>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions> </CompilerOptions>
<Debugging> <Debugging>
<Exceptions Count="4"> <Exceptions Count="4">