Preheat the oven to 220 degrees C. Toss the onions with the oil, sugar and seasoning in a large bowl. Spread in a large roasting tin and drizzle with 50 ml of water. Cover with foil and roast for 30 minutes, then uncover and return to the oven for 10 minutes. Add the thyme and roast for a further 20 minutes, stirring often, until the onions are tender.
Place the roasting tin on the stove over a high heat. Add the wine and stir for 2 minutes with a wooden spoon, scraping the onions and sediment from the bottom of the tin until the wine is syrupy.
Transfer the onions and pan juices to a large saucepan. Stir in the stock, bring to the boil, then reduce the heat and simmer for 15 minutes until the flavours are blended.
Meanwhile, preheat a grill to a moderate heat. Put the bread on a baking tray and toast for 2 minutes on each side.
Ladle the soup into four heatproof bowls. Float a bread slice in each bowl and sprinkle with cheese. Place the bowls in the grill pan or a shallow roasting tin and grill on a low shelf for 2 minutes, or until the cheese is melted and bubbling. Serve immediately.