This fixes a memory access issue in dropdown code: if the selected value is invalid for whatever reason (including -1, a 'legitimate' use), then the code can crash by trying to access invalid memory. This caused #6225.
The most common culprit were color dropdown, see #5598. Those are buggy since at least rP25077, but #5598 predates that so it seems like it could fail in some rare cases earlier. I fix it so that opening the color dropdown will select the correct color.
C++ bug introduced in rP12319.
Reported by: tuxayo, newbay, freemint