This is matchpoints, so guarding against crappy breaks isn't the only consideration -- you need to make an overtrick if it's easy to do.
Assumptions (probably correct to make at matchpoints):
- LHO has the heart ace (for his vulnerable overcall). Not certain, but even if it's wrong you're not dead.
- Neither opponent has a void (or someone would have bid 5D). This is almost completely safe to assume against decent opponents.
- LHO is moderately unlikely to have a side-suit singleton. (From e.g., x Axx AKJxxx xxx he would sometimes lead his spade, preserving the possible diamond entry to his partner's hand for after he wins the trump ace and hoping for a fourth trick in a black suit.)
Ruff the diamond. Play a spade to the ace (not queen -- it's slightly harder for LHO to get a read on the suit this way, and he may misplay from Jxxx Axx AKJxx Q).
Now a heart toward the queen. If spades are 4-1, LHO has to fly with the ace and read the position to give his partner a ruff, and in that case trump must be 3-2 (or A/xxxx) so the hand is done -- win the return, ruff another diamond, draw trump, claim (losing the heart ace, a spade ruff, and a late diamond -- there may be chances for overtricks still, but let's leave that alone).
If the heart queen holds, either trump are 3-2 and you can continue with another heart, or LHO started with Axxx and you can safely play another spade. I think it would be best to play a second spade -- if it is ruffed you can win any return, ruff a second diamond, and lose only a diaond, the spade ruff, and the heart ace. This fails when RHO ruffs from an original holding of Axxx and he held up on the heart queen, but I just don't see that happening.
Playing this way, you will usually make 4, but will score an overtrick when the majors are each 3-2 or when LHO holds something like xxx A AKJxxx Jxx.
(BTW, if the majors don't break the opponents have probably missed a profitable sacrifice, so there's no particular reason to worry about overtricks in such cases.)
In your eagerness to get rid of diamond losers, you lost trump control. The opponents will often be trying to tap you in diamonds as it is -- there's nothing else for them to attack. Note also that there's a reasonable chance clubs are 3-3 (if they were 5-1 someone would have sacrificed, so only 3-3 and 4-2 are at all likely), in which case you may even be making 6 with only one diamond ruff (when opps have xxx Ax AKJxx Jxx opposite Jx xxx QTxxx Qxx or the like).
[BTW, not gospel - I'm a much better bidder than cardplayer.]