修正 imagelist中bmp可能销毁导致的异常

This commit is contained in:
liujianjun 2024-07-31 14:40:02 +08:00
parent d412eb1cfc
commit ebed3be229
12 changed files with 195 additions and 36 deletions

View File

@ -1392,7 +1392,7 @@ type tsearchdir = class(TCustomControl)
inherited; inherited;
caption := "函数搜索目录:左侧为别名,右侧为-libpath目录...."; caption := "函数搜索目录:左侧为别名,右侧为-libpath目录....";
WsDlgModalFrame := true; WsDlgModalFrame := true;
//WSSizebox := true; WSSizebox := true;
visible := false; visible := false;
wsPopUp := true; wsPopUp := true;
WsSysMenu := true; WsSysMenu := true;
@ -1609,7 +1609,7 @@ type tsearchdir = class(TCustomControl)
FLists; FLists;
FBtns; FBtns;
end end
private private
function GetIcon(); function GetIcon();
begin begin
r := "0502000000060400000074797065000203000000696D670006040000006461746 r := "0502000000060400000074797065000203000000696D670006040000006461746
@ -1804,8 +1804,10 @@ type tdirviewer = class(tcustomcontrol)
bmp := new TBitmap(); bmp := new TBitmap();
bmp.readvcon(HexFormatStrToTsl(folderbmp())); bmp.readvcon(HexFormatStrToTsl(folderbmp()));
fimgs.addbmp(bmp); fimgs.addbmp(bmp);
bmp := new TBitmap();
bmp.readvcon(HexFormatStrToTsl(filebmp())); bmp.readvcon(HexFormatStrToTsl(filebmp()));
fimgs.addbmp(bmp); fimgs.addbmp(bmp);
bmp := new TBitmap();
bmp.readvcon(HexFormatStrToTsl(dllbmp())); bmp.readvcon(HexFormatStrToTsl(dllbmp()));
fimgs.addbmp(bmp); fimgs.addbmp(bmp);
ftbns := array(); ftbns := array();
@ -1813,7 +1815,8 @@ type tdirviewer = class(tcustomcontrol)
for i,v in gettbicons() do for i,v in gettbicons() do
begin begin
bt := new TToolButton(ftb); bt := new TToolButton(ftb);
bt.caption := i; bt.caption := i;
bmp := new TBitmap();
bmp.readvcon(HexFormatStrToTsl(v)); bmp.readvcon(HexFormatStrToTsl(v));
fimgs.addbmp(bmp); fimgs.addbmp(bmp);
bt.ImageId := fimgs.ImageCount-1; bt.ImageId := fimgs.ImageCount-1;

View File

@ -1079,7 +1079,7 @@ type TProjectView = class(TVCForm) //
end end
////////////////////从新构造search目录/////////////////////////////// ////////////////////从新构造search目录///////////////////////////////
global g_orig_lib_path; global g_orig_lib_path;
sdir := array(p); sdir := array(p+fio);
idx := 1; idx := 1;
hdirs := array(p:true); hdirs := array(p:true);
if ifstring(g_orig_lib_path) then if ifstring(g_orig_lib_path) then
@ -1749,7 +1749,7 @@ end
end end
private private
FMoveMnus; FMoveMnus;
FMoveMenu; FMoveMenu;
function getnodebyfilename(f,nd);//获得编辑器对应节点 function getnodebyfilename(f,nd);//获得编辑器对应节点
begin begin
if not nd then return 0; if not nd then return 0;
@ -2657,10 +2657,10 @@ type TFileTree = class(TTreeCtl)
function CreateaImageList(AOwner,imgns); function CreateaImageList(AOwner,imgns);
begin begin
imgs := New TControlImageList(AOwner); imgs := New TControlImageList(AOwner);
imgns := array(); imgns := array();
bmp := new TBitmap();
for i,v in GetIcons() do for i,v in GetIcons() do
begin begin
bmp := new TBitmap();
bmp.ReadVCon(HexFormatStrToTsl(v)); bmp.ReadVCon(HexFormatStrToTsl(v));
imgs.AddBmp(bmp); imgs.AddBmp(bmp);
imgns[i]:= k; imgns[i]:= k;

View File

@ -1880,7 +1880,6 @@ type TEditer=class(TCustomcontrol) //
FImages := new TControlImageList(self); FImages := new TControlImageList(self);
FImages.Width := 24; FImages.Width := 24;
FImages.Height := 24; FImages.Height := 24;
bmp := new TBitmap();
imgs := GetEditIcons(); imgs := GetEditIcons();
id := 0; id := 0;
FToolbtns := array(); FToolbtns := array();
@ -1895,6 +1894,7 @@ type TEditer=class(TCustomcontrol) //
continue; continue;
end else end else
begin begin
bmp := new TBitmap();
bmp.Readvcon(HexFormatStrToTsl(v)); bmp.Readvcon(HexFormatStrToTsl(v));
FImages.addbmp(bmp); FImages.addbmp(bmp);
bt.OnClick := thisfunction(ToolClick); bt.OnClick := thisfunction(ToolClick);

View File

@ -2298,9 +2298,10 @@ type TTsfFileParser = class() //
ClearCache(FFindDirs?true:false); ClearCache(FFindDirs?true:false);
end end
end end
function DirSet(d); //ÉèÖÃ function DirSet(d_); //ÉèÖÃ
begin begin
if not ifarray(d) then return FFindDirs; if not ifarray(d_) then return FFindDirs;
d := format_dirs(d_);
if d=FFindDirs then return d; if d=FFindDirs then return d;
r := FFindDirs; r := FFindDirs;
FFinddirsseted := true; FFinddirsseted := true;
@ -2312,6 +2313,22 @@ type TTsfFileParser = class() //
end end
return r; return r;
end end
function format_dirs(d);
begin
r := array();
idx := 0;
for i,v in d do
begin
if ifstring(v) and v then
begin
vlen := length(v);
if v[vlen]=fiofs then r[idx] := v[1:(vlen-1)];
else r[idx] := v;
idx++;
end
end
return r;
end
function ClearCache(cl); //헌왕뻠닸 function ClearCache(cl); //헌왕뻠닸
begin begin
if cl then if cl then

View File

@ -666,7 +666,8 @@ public //
if ifobj(otype)then if ifobj(otype)then
begin begin
iv := otype.UnformatEdit(v); //·´×ª»» iv := otype.UnformatEdit(v); //·´×ª»»
if FChangedProperties[n]=vi then continue; //没有改变 //if FChangedProperties[n]=vi then continue; //没有改变
if FChangedProperties[n]=iv then continue; //没有改变
SetChangedPublish(n,iv,pp); //±£´æ SetChangedPublish(n,iv,pp); //±£´æ
if n="visible" or n="wspopup" or n="enabled" then if n="visible" or n="wspopup" or n="enabled" then
begin begin

View File

@ -310,6 +310,7 @@ BFC6105000000097048597300000EC300000EC301C76FA8640000010D49444154
bmp := new TcustomBitmap(); bmp := new TcustomBitmap();
bmp.readvcon(HexFormatStrToTsl(getsxbmp())); bmp.readvcon(HexFormatStrToTsl(getsxbmp()));
fsplitterdragimglist.addbmp(bmp); fsplitterdragimglist.addbmp(bmp);
bmp := new TcustomBitmap();
bmp.readvcon(HexFormatStrToTsl(getzybmp())); bmp.readvcon(HexFormatStrToTsl(getzybmp()));
fsplitterdragimglist.addbmp(bmp); fsplitterdragimglist.addbmp(bmp);
end end

View File

@ -2094,7 +2094,9 @@ type TWinControl = class(tcontrol)
FTRACKMOUSEEVENT.dwflags := TME_CANCEL .| TME_HOVER .| TME_LEAVE; FTRACKMOUSEEVENT.dwflags := TME_CANCEL .| TME_HOVER .| TME_LEAVE;
_wapi.TrackMouseEvent(FTRACKMOUSEEVENT._getptr_); _wapi.TrackMouseEvent(FTRACKMOUSEEVENT._getptr_);
end } end }
bv := FVisible;
_wapi.DestroyWindow(self.Handle); _wapi.DestroyWindow(self.Handle);
FVisible := bv;
end end
FHandle := 0; FHandle := 0;
end end

View File

@ -1975,8 +1975,8 @@ type tsgtkapi = class(tgtkapis)
cairo_fill(dc); cairo_fill(dc);
cairo_move_to(dc,LPRECT[0]+x+2,LPRECT[1]+y+(LPRECT[3]-LPRECT[1])/3); cairo_move_to(dc,LPRECT[0]+x+2,LPRECT[1]+y+(LPRECT[3]-LPRECT[1])/3);
cairo_line_to(dc,LPRECT[0]+x+(LPRECT[2]-LPRECT[0])/3,LPRECT[3]-2); cairo_line_to(dc,LPRECT[0]+x+(LPRECT[2]-LPRECT[0])/3,y+LPRECT[3]-2);
cairo_line_to(dc,LPRECT[2]-2,LPRECT[1]+y+(LPRECT[3]-LPRECT[1])/4); cairo_line_to(dc,LPRECT[2]+x-2,LPRECT[1]+y+(LPRECT[3]-LPRECT[1])/4);
cairo_set_source_rgb(dc,100/255,100/255,100/255); cairo_set_source_rgb(dc,100/255,100/255,100/255);
cairo_set_line_width(dc,4); cairo_set_line_width(dc,4);
cairo_stroke(dc); cairo_stroke(dc);

View File

@ -412,6 +412,7 @@ type tcustomcoolbar=class(tcustomcontrol)
bmp := new TcustomBitmap(); bmp := new TcustomBitmap();
bmp.readvcon(HexFormatStrToTsl(getmovebmp())); bmp.readvcon(HexFormatStrToTsl(getmovebmp()));
FDRageimglist.addbmp(bmp); FDRageimglist.addbmp(bmp);
bmp := new TcustomBitmap();
bmp.readvcon(HexFormatStrToTsl(getsizebmp())); bmp.readvcon(HexFormatStrToTsl(getsizebmp()));
FDRageimglist.addbmp(bmp); FDRageimglist.addbmp(bmp);
end end

View File

@ -1928,13 +1928,16 @@ type TCustomImageList=class(tcomponent)
addIcon(bmp.ToIcon()); addIcon(bmp.ToIcon());
if FimageCount>ct then if FimageCount>ct then
begin begin
FBmpItems.push(bmp);
//////////////¿½±´bitamp²»Ïú»Ù/////////////////// //////////////¿½±´bitamp²»Ïú»Ù///////////////////
{
nbmp := new tcustombitmap(); nbmp := new tcustombitmap();
bmp.AutoDestroy := false; bmp.AutoDestroy := false;
nbmp.Handle := bmp.Handle; nbmp.Handle := bmp.Handle;
nbmp.AutoDestroy := true; nbmp.AutoDestroy := true;
//////////////////////////////
FBmpItems.push(nbmp); FBmpItems.push(nbmp);
//////////////////////////////
}
end end
finally finally
FBmpAdding := false; FBmpAdding := false;

View File

@ -527,6 +527,8 @@ type tfm = class(tvcform)
end end
} }
function point_in_rgn(p,rgn_); //判断点是否在区域中 function point_in_rgn(p,rgn_); //判断点是否在区域中
function graph_paint_lines(cvs,linestyle,xys,closed,ifo); //根据给定点绘制线
function graph_paint_points(mk,cvs,xys); //根据点信息绘制点
type tg_WinControl = class(tcustomcontrol,tg_const) //绘图窗口 type tg_WinControl = class(tcustomcontrol,tg_const) //绘图窗口
function create(AOwner); function create(AOwner);
begin begin
@ -3748,12 +3750,13 @@ type tg_Polyline = class(tg_graph) //
end end
end end
type tg_line_info = class(tg_const) //线型信息 type tg_line_info = class(tg_const) //线型信息
function create(); function create(awer);
begin begin
fcolor := 0; fcolor := 0;
FWidth := 1; FWidth := 1;
FStyle := tgc_PS_SOLID; FStyle := tgc_PS_SOLID;
fbkcolor := nil; fbkcolor := nil;
fonwer := awer;
end end
function clone(); function clone();
begin begin
@ -3765,24 +3768,64 @@ type tg_line_info = class(tg_const) //
r.bkcolor := fbkcolor; r.bkcolor := fbkcolor;
return r; return r;
end end
property Style read FStyle write FStyle; property style index "style" read FStyle write setpropid;
property width read FWidth write fwidth; property width index "width" read FWidth write setpropid;
property size read FWidth write fwidth; property size index "size" read FWidth write setpropid;
property color read fcolor write fcolor; property color index "color" read fcolor write setpropid;
property bkcolor read fbkcolor write fbkcolor; property bkcolor index "bkcolor" read fbkcolor write setpropid;
private private
fwidth; fwidth;
fcolor; fcolor;
FStyle; FStyle;
fbkcolor; fbkcolor;
function setpropid(id,v);
begin
case id of
"style":
begin
if FStyle<>v and ifnumber(v) then
begin
FStyle := v;
if fonwer then fonwer.invalidate();
end
end
"width","size":
begin
if FWidth<>v and ifnumber(v) then
begin
FWidth := v;
if fonwer then fonwer.invalidate();
end
end
"color":
begin
if fcolor<>v and ifnumber(v) then
begin
fcolor := v;
if fonwer then fonwer.invalidate();
end
end
"bkcolor":
begin
if fbkcolor<>v and ifnumber(v) then
begin
fbkcolor := v;
if fonwer then fonwer.invalidate();
end
end
end;
end
[weakref]fonwer;
end end
type tg_font_info = class(tg_const) //字体信息 type tg_font_info = class(tg_const) //字体信息
function create(); function create(awner);
begin begin
fstyle := nil; fstyle := nil;
fsize := 7; fsize := 7;
fforeground := 0; fforeground := 0;
fbackground := nil; fbackground := nil;
fonwer := awner;
end end
function clone(); function clone();
begin begin
@ -3793,25 +3836,65 @@ type tg_font_info = class(tg_const) //
r.bkcolor := fbackground; r.bkcolor := fbackground;
return r; return r;
end end
property style read fstyle write fstyle; property style index "style" read fstyle write setpropid;
property size read fsize write fsize; property size index "size" read fsize write setpropid;
property color read fforeground write fforeground; property color index "color" read fforeground write setpropid;
property bkcolor read fbackground write fbackground; property bkcolor index "bkcolor" read fbackground write setpropid;
private private
fstyle; fstyle;
fsize; fsize;
fsize_unit; fsize_unit;
fforeground; fforeground;
fbackground; fbackground;
[weakref]fonwer;
function setpropid(id,v);
begin
case id of
"style":
begin
if FStyle<>v and ifnumber(v) then
begin
FStyle := v;
if fonwer then fonwer.invalidate();
end
end
"size":
begin
if fsize<>v and ifnumber(v) then
begin
fsize := v;
if fonwer then fonwer.invalidate();
end
end
"color":
begin
if fforeground<>v and ifnumber(v) then
begin
fforeground := v;
if fonwer then fonwer.invalidate();
end
end
"bkcolor":
begin
if fbackground<>v and ifnumber(v) then
begin
fbackground := v;
if fonwer then fonwer.invalidate();
end
end
end;
end
end end
type tg_mark_info = class(tg_const) //标记信息 type tg_mark_info = class(tg_const) //标记信息
function create(); function create(awner);
begin begin
fstyle := tgc_mks_dot; fstyle := tgc_mks_dot;
fsize := 0; fsize := 0;
fsize_unit := tgc_mk_point; fsize_unit := tgc_mk_point;
fforeground := 0; fforeground := 0;
fbackground := 0xffffff; fbackground := 0xffffff;
fonwer := awner;
end end
function clone(); function clone();
begin begin
@ -3823,17 +3906,55 @@ type tg_mark_info = class(tg_const) //
r.bkcolor := fbackground; r.bkcolor := fbackground;
return r; return r;
end end
property style read fstyle write fstyle; property style index "style" read fstyle write setpropid;
property size read fsize write fsize; property size index "size" read fsize write setpropid;
property size_unit read fsize_unit write fsize_unit; property size_unit read fsize_unit write fsize_unit;
property color read fforeground write fforeground; property color index "color" read fforeground write setpropid;
property bkcolor read fbackground write fbackground; property bkcolor index "bkcolor" read fbackground write setpropid;
private private
fstyle; fstyle;
fsize; fsize;
fsize_unit; fsize_unit;
fforeground; fforeground;
fbackground; fbackground;
[weakref]fonwer;
function setpropid(id,v);
begin
case id of
"style":
begin
if FStyle<>v and ifnumber(v) then
begin
FStyle := v;
if fonwer then fonwer.invalidate();
end
end
"size":
begin
if fsize<>v and ifnumber(v) then
begin
fsize := v;
if fonwer then fonwer.invalidate();
end
end
"color":
begin
if fforeground<>v and ifnumber(v) then
begin
fforeground := v;
if fonwer then fonwer.invalidate();
end
end
"bkcolor":
begin
if fbackground<>v and ifnumber(v) then
begin
fbackground := v;
if fonwer then fonwer.invalidate();
end
end
end;
end
end end
type tg_evet_conainter = class(tg_const) //带消息的绘图基类 type tg_evet_conainter = class(tg_const) //带消息的绘图基类
function create(); function create();
@ -3872,9 +3993,9 @@ type tg_base = class(TNode,tg_evet_conainter) //
fenabled := tgc_on; fenabled := tgc_on;
fline_mode := tgc_off; fline_mode := tgc_off;
fmark_mode := tgc_off; fmark_mode := tgc_off;
flineinfo := new tg_line_info(); flineinfo := new tg_line_info(self(true));
fmarkinfo := new tg_mark_info(); fmarkinfo := new tg_mark_info(self(true));
ffontinfo := new tg_font_info(); ffontinfo := new tg_font_info(self(true));
end end
function axes_mapping(x,y,z,_x,_y);virtual; // function axes_mapping(x,y,z,_x,_y);virtual; //
begin begin
@ -3973,6 +4094,7 @@ type tg_base = class(TNode,tg_evet_conainter) //
end end
function invalidate(); //刷新 function invalidate(); //刷新
begin begin
if tgc_off=fvisibe then return ;
if fchange_locked then return ; if fchange_locked then return ;
axs := get_axes(); axs := get_axes();
if axs then if axs then
@ -4388,6 +4510,14 @@ begin
_x := x*cos(ag)+y*sin(ag); _x := x*cos(ag)+y*sin(ag);
_y := -x*sin(ag)+y*cos(ag); _y := -x*sin(ag)+y*cos(ag);
end end
function graph_paint_lines(cvs,pls,xys,cls,ifo);
begin
return paint_lines(cvs,pls,xys,cls,ifo);
end
function graph_paint_points(mk,dc,xys);
begin
return paint_marks(mk,dc,xys);
end
function paint_lines(cvs,pls,xys,cls,ifo);//划线 function paint_lines(cvs,pls,xys,cls,ifo);//划线
begin begin
o := static new tg_const(); o := static new tg_const();
@ -4493,7 +4623,7 @@ begin
end end
end end
end end
function paint_marks(mk,dc,xys); //ťćÖĆľă function paint_marks(mk,dc,xys); //绘制marks;
begin begin
o := static new tg_const(); o := static new tg_const();
tp := mk.Style; tp := mk.Style;

View File

@ -937,6 +937,7 @@ type TTmfParser = class(TTmfParserbase)
public public
property Script write SetScript; property Script write SetScript;
property ScriptPath write SetScriptPath; property ScriptPath write SetScriptPath;
property tokens read FTokens; //获得token数据
{** {**
@param(Script)(string) 设置脚本文件 %% @param(Script)(string) 设置脚本文件 %%
@param(ScriptPath)(string) 脚本路径 %% @param(ScriptPath)(string) 脚本路径 %%