Skrim 11 Posted Friday at 02:23 PM try aDialog:=TMyDialog.Create(self); ... ... finally aDialog.Free; end; I keep getting warnings about a dialog created inside a Try/Finally, why is it bad practise? Share this post Link to post
Uwe Raabe 2046 Posted Friday at 02:45 PM Because aDialog is not assigned when an exception is raised inside TMyDialog.Create. That causes Free called for an uninitialized variable inside the finally block. A workaround would be to set aDialog to nil before the try, but the cleaner way is to move the Create outside the try-finally. 1 1 Share this post Link to post