15MP sensor has very high pixel density, which means diffraction becomes and issue from around f/7-8. Most lenses are sharpest around f/8, while best primes are at f/5.6. The sharpness is lowest in the corners, and this will be magnified at 15mp. Btw, at the same density FF would be 38MP! 1 Ds3 has 21MP which converts to 8mp Aps-C.
You can downsize 15mp to 10-12 mp and regain the sharpness at pixel level, but not the dynamic range. The overall image sharpness will be very slightly better from 50D over 40D.
So to put this into perspective:
get 50D if you need more reach, and use PRIMES (200L, 135L, 100/2, 85L, 85/1.8, 50L, 35L, 24L) or 70-200L.
With 24-105mm 40D will give about the same resolution. It is also excellent on 5D. Most zooms will be fine on 40D.
5D either one - only L zooms or better primes.
Always use RAW converter, and optimise image very carefully (sharpness, vignetting, exposure, highlights, WB, CA correction, noise reduction, crop, dust removal). Lightroom can even fix photos taken with 17-85mm IS, while JPEGs look terrible.
I'd say processing can make far more difference than 40D vs 50D. So if you haven't done so pick a powerful converter and familiarise yourself with it. I have submitted interpolated photos from 30D to 16mp to Alamy and they were fine. So even your 350D is still very capable.