Lead bullets cause leading when the alloy strength is exceeded by the chamber pressure and/or when the bullet size is under throat/groove diameter of the barrel. Lead alloys will pressure melt when the pressure exceeds about 1450Xbullet Brenell Hardness Number. Simply put BHN 20 will begin to lead if chamber pressures exceed 29,000psi. Some bullet lubes will allow you to push this a bit higher. The 40S&W runs about 28-35,000psi. There is no reason why lead bullets of the correct hardness cannot be used in the smooth Glock factory barrel. The Glock barrel's internal smoothness is a plus, not a minus when it comes to leading.
Lead bullets under groove diameter "may" obturate and fill the grooves but usually the hot early powder gas squirts down the unfilled grooves and melts lead off the sides of the slug, blowing this down the barrel. Bullets then run over these lead dropletts and irons them into the bore. Accuracy goes to He## and pressures rise. At low chamber pressures like .38 Spl and .45 Colt, alloys with BHN 8-12 will obturate despite being slightly undersize at 8-10,000psi and not leave leading.
I have shot a lot of "hard" cast bullets from my factory .40 S&W Glock 23 barrel. I size them to .402" and lube with Lee Liquid Alox. They are water dropped wheel weight alloy of BHN 24+. I use a load that produces almost exactly 28,000psi. Leading is non-existant. However, not water-drop-quenching these bullets results in a BHN of 12 which leads like crazy with this same load. Copper jacketed bullets do not have these problems because cooper melts at four times the temperature of lead and is much harder. Also, undersize copper jacketed bullets will self center in the bore despite being slightly undersize.