Skrim 11 Posted October 18 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 2059 Posted October 18 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