File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ TEventBase = class(TRefCountedObject)
6161 procedure SetOnChanged (const value : TNotifyEvent);
6262 procedure SetUseFreeNotification (const value : Boolean);
6363 { $ENDREGION}
64- procedure EnsureNotificationHandler ; inline;
64+ procedure EnsureNotificationHandler ;
6565 procedure HandleNotification (component: TComponent; operation: TOperation);
6666 protected
6767 fInvoke: TMethodPointer;
@@ -166,11 +166,15 @@ destructor TEventBase.Destroy;
166166end ;
167167
168168procedure TEventBase.EnsureNotificationHandler ;
169+ var
170+ notificationHandler: TNotificationHandler;
169171begin
170172 if fNotificationHandler = nil then
171173 begin
172- fNotificationHandler := TNotificationHandler.Create(nil );
173- fNotificationHandler.OnNotification := HandleNotification;
174+ notificationHandler := TNotificationHandler.Create(nil );
175+ notificationHandler.OnNotification := HandleNotification;;
176+ if AtomicCmpExchange(Pointer(fNotificationHandler), Pointer(notificationHandler), nil ) <> nil then
177+ notificationHandler.Free;
174178 end ;
175179end ;
176180
You can’t perform that action at this time.
0 commit comments