Ver Fonte

UPD: Hide invalid props (#1832)

j2969719 há 1 ano atrás
pai
commit
9e26803e53

+ 1 - 0
src/filesources/wcxarchive/uwcxarchivefilesource.pas

@@ -476,6 +476,7 @@ begin
         SizeProperty := TFileSizeProperty.Create(WcxHeader.UnpSize);
         SizeProperty.IsValid := (WcxHeader.UnpSize >= 0);
         CompressedSizeProperty := TFileCompressedSizeProperty.Create(WcxHeader.PackSize);
+        CompressedSizeProperty.IsValid := (WcxHeader.PackSize >= 0);
       end;
     ModificationTimeProperty := TFileModificationDateTimeProperty.Create(WcxHeader.DateTime);
     ModificationTimeProperty.IsValid := (WcxHeader.DateTime <= SysUtils.MaxDateTime);

+ 15 - 3
src/fpackinfodlg.pas

@@ -133,7 +133,9 @@ begin
   begin
     lblPackedOrgSize.Caption := IntToStr(aFile.Size);
     lblPackedPackedSize.Caption := IntToStr(aFile.CompressedSize);
-    if aFile.Size > 0 then
+    lblPackedOrgSize.Visible := aFile.SizeProperty.IsValid;
+    lblPackedPackedSize.Visible := aFile.CompressedSizeProperty.IsValid;
+    if (aFile.Size > 0) and aFile.CompressedSizeProperty.IsValid then
     begin
       lblPackedCompression.Caption := IntToStr(100 - (aFile.CompressedSize * 100 div aFile.Size)) + '%';
       lblPackedCompression.Visible := True;
@@ -141,8 +143,16 @@ begin
   end;
 
   // DateTime and Attributes
-  lblPackedDate.Caption:= DateToStr(aFile.ModificationTime);
-  lblPackedTime.Caption:= TimeToStr(aFile.ModificationTime);
+  if not aFile.ModificationTimeProperty.IsValid then
+  begin
+    lblPackedDate.Visible:= False;
+    lblPackedTime.Visible:= False;
+  end
+  else
+  begin
+    lblPackedDate.Caption:= DateToStr(aFile.ModificationTime);
+    lblPackedTime.Caption:= TimeToStr(aFile.ModificationTime);
+  end;
   lblPackedAttr.Caption:= aFile.AttributesProperty.AsString;
 
   // Hide labels for not visible values.
@@ -150,6 +160,8 @@ begin
   lblPackedSize.Visible       := lblPackedPackedSize.Visible;
   lblCompressionRatio.Visible := lblPackedCompression.Visible;
   lblMethod.Visible           := lblPackedMethod.Visible;
+  lblDate.Visible             := lblPackedDate.Visible;
+  lblTime.Visible             := lblPackedTime.Visible;
 
   // Controls from the dividing line to top.
   upperInfoControls[0] := lblMethod;

+ 3 - 3
src/platform/uinfotooltip.pas

@@ -86,13 +86,13 @@ function GetFileInfoToolTip(aFileSource: IFileSource; const aFile: TFile): Strin
   function GetDefaultToolTip(const Hint: String): String;
   begin
     Result:= Hint;
-    if fpModificationTime in aFile.SupportedProperties then
+    if (fpModificationTime in aFile.SupportedProperties) and aFile.ModificationTimeProperty.IsValid then
       with (aFile.Properties[fpModificationTime] as TFileModificationDateTimeProperty) do
       Result:= IfThen(Result = EmptyStr, EmptyStr, Result + LineEnding) + GetDescription + #58#32 +  AsString;
-    if fpSize in aFile.SupportedProperties then
+    if (fpSize in aFile.SupportedProperties) and aFile.SizeProperty.IsValid then
       with (aFile.Properties[fpSize] as TFileSizeProperty) do
       Result:= IfThen(Result = EmptyStr, EmptyStr, Result + LineEnding) + GetDescription + #58#32 + AsString;
-    if fpCompressedSize in aFile.SupportedProperties then
+    if (fpCompressedSize in aFile.SupportedProperties) and aFile.CompressedSizeProperty.IsValid then
       with (aFile.Properties[fpCompressedSize] as TFileCompressedSizeProperty) do
       Result:= IfThen(Result = EmptyStr, EmptyStr, Result + LineEnding) + GetDescription + #58#32 + AsString;
   end;