lazarus交叉编译riscv64应用时自带的memdataset/lazreporr等控件如果使用到formeditingintf.pas时链接时出现出类以下提示的错误:
这是fpc引起的问题,也提交给lazarus/fpc官方,不知道啥能修复(希望官方最快修复这个Bug)。
以下是网友英分享的修复方法(但本方法部分控件还存在链接问题),常用的控件已可正常编译运行,基本满足用lazarus编写riscv64的应用需求。
1、打开lazarus\components\ideintf\unitresources.pas
添加红色代码部位
class function TCustomLFMUnitResourceFileFormat.DefaultComponentClass: TComponentClass; begin {$if defined(cpuriscv64) } Result:=nil; {$else} Result := FormEditingHook.StandardDesignerBaseClasses[DesignerBaseClassId_TForm]; {$endif} end; class function TCustomLFMUnitResourceFileFormat.FindComponentClass( aClassName: string): TComponentClass; begin {$if defined(cpuriscv64) } Result:=nil; {$else} if CompareText(aClassName,'TForm')=0 then Result:=FormEditingHook.StandardDesignerBaseClasses[DesignerBaseClassId_TForm] else if CompareText(aClassName,'TFrame')=0 then Result:=FormEditingHook.StandardDesignerBaseClasses[DesignerBaseClassId_TFrame] else if CompareText(aClassName,'TDataModule')=0 then Result:=FormEditingHook.StandardDesignerBaseClasses[DesignerBaseClassId_TDataModule] else Result:=nil; {$endif} end;
2、打开lazarus\components\ideintf\collectionpropeditform.pas
添加红色代码
procedure TCollectionPropertyEditorForm.SelectionChanged(NewOwnerPersistent: TPersistent); var AGrid: TOICustomPropertyGrid; AEditor: TPropertyEditor; NewCollection: TCollection; begin // DebugLn('TCollectionPropertyEditorForm.SelectionChanged Old: ', DbgSName(OwnerPersistent), ' New: ', DbgSName(NewOwnerPersistent)); {$if not defined(cpuriscv64) } AGrid := FormEditingHook.GetCurrentObjectInspector.GridControl[oipgpProperties]; {$endif} AEditor := AGrid.PropertyEditorByName(PropertyName); if not Assigned(AEditor) then Exit; NewCollection := TCollection(AEditor.GetObjectValue); if NewCollection = nil then raise Exception.Create('NewCollection=nil'); SetCollection(NewCollection, NewOwnerPersistent, PropertyName); end;
3、打开lazarus\components\ideintf\formeditingintf.pas
添加红色代码:
{ ***************************************************************************** See the file COPYING.modifiedLGPL.txt, included in this distribution, for details about the license. ***************************************************************************** Author: Shane Miller, Mattias Gaertner Abstract: Methods to access the form editing of the IDE. } unit FormEditingIntf; {$mode objfpc}{$H+} interface uses Classes, TypInfo, types, Math, // LCL LCLClasses, Forms, Controls, // LazUtils CompWriterPas, LazLoggerBase, // IdeIntf ComponentEditors, ObjectInspector, UnitResources; const ComponentPaletteImageWidth = 24; ComponentPaletteImageHeight = 24; ComponentPaletteBtnWidth = ComponentPaletteImageWidth + 3; ComponentPaletteBtnHeight = ComponentPaletteImageHeight + 3; DesignerBaseClassId_TForm = 0; DesignerBaseClassId_TDataModule = 1; DesignerBaseClassId_TFrame = 2; NonControlProxyDesignerFormId = 0; FrameProxyDesignerFormId = 1; {$if not defined(cpuriscv64) } type TDMCompAtPosFlag = ( dmcapfOnlyVisible, dmcapfOnlySelectable ); TDMCompAtPosFlags = set of TDMCompAtPosFlag; TDesignerMediator = class; INonFormDesigner = interface ['{244DEC6B-80FB-4B28-85EF-FE613D1E2DD3}']
移到最后添加红色代码
procedure TDesignerMediator.GetObjInspNodeImageIndex(APersistent: TPersistent; var AIndex: integer); begin end; initialization IsFormDesign := @IsFormDesignFunction; {$endif} end.
最后重新编译lazarus(不重新编译也没问题)
这是用unidac+sqlite编译的Demo:
标签:riscv64,FormEditingHook,取巧,DesignerBaseClassId,编译,lazarus,Result,NewCollection From: https://www.cnblogs.com/qiufeng2014/p/18409553