浏览代码

* Add IsUniqueGlobalComponentName

Michaël Van Canneyt 1 年之前
父节点
当前提交
8f8ce13b41
共有 2 个文件被更改,包括 15 次插入2 次删除
  1. 8 0
      rtl/objpas/classes/classes.inc
  2. 7 2
      rtl/objpas/classes/classesh.inc

+ 8 - 0
rtl/objpas/classes/classes.inc

@@ -1462,6 +1462,14 @@ function FindGlobalComponent(const Name: string): TComponent;
       end;
   end;
 
+function IsUniqueGlobalComponentName(const aName: string): Boolean;
+
+begin
+  if Assigned(IsUniqueGlobalComponentNameProc) then
+    Result:=IsUniqueGlobalComponentNameProc(aName)
+  else 
+    Result:=Not Assigned(FindGlobalComponent(aName));
+end;
 
 procedure RegisterInitComponentHandler(ComponentClass: TComponentClass;   Handler: TInitComponentHandler);
 Var

+ 7 - 2
rtl/objpas/classes/classesh.inc

@@ -2829,9 +2829,13 @@ procedure RegisterNoIcon(ComponentClasses: array of TComponentClass);
 procedure RegisterNonActiveX(ComponentClasses: array of TComponentClass;
   AxRegType: TActiveXRegType);
 
+Type
+  TIsUniqueGlobalComponentName = function(const Name: string): Boolean;
+
 var
   GlobalNameSpace: IReadWriteSync;
-
+  IsUniqueGlobalComponentNameProc: TIsUniqueGlobalComponentName;
+  
 { Object filing routines }
 
 type
@@ -2844,7 +2848,7 @@ type
   TIntToIdent = function(Int: Longint; var Ident: string): Boolean;
   TFindGlobalComponent = function(const Name: string): TComponent;
   TInitComponentHandler = function(Instance: TComponent; RootAncestor : TClass): boolean;
-
+  
 var
   MainThreadID: TThreadID;
 
@@ -2858,6 +2862,7 @@ function FindIdentToInt(AIntegerType: Pointer): TIdentToInt;
 procedure RegisterFindGlobalComponentProc(AFindGlobalComponent: TFindGlobalComponent);
 procedure UnregisterFindGlobalComponentProc(AFindGlobalComponent: TFindGlobalComponent);
 function FindGlobalComponent(const Name: string): TComponent;
+function IsUniqueGlobalComponentName(const aName: string): Boolean;
 
 function InitInheritedComponent(Instance: TComponent; RootAncestor: TClass): Boolean;
 function InitComponentRes(const ResName: string; Instance: TComponent): Boolean;