[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] Early dispose()

Title: Early dispose()

This code works on Windows XP, but to ensure cross platform portability, shouldn't it throw an execption :

        Color color1 = new Color(e.display,100,0,50);
        Color color2 = new Color(e.display,100,255,50);
        Pattern pattern = new Pattern(e.display,0,0,200,200,color1,color2);
        color1.dispose();
        color2.dispose(); // is it too early ???
               
        gc.setBackgroundPattern(pattern);
        pattern.dispose(); // THE PATTERN IS STILL IN USE
        gc.fillRectangle(0, 0, e.width, e.height);

On Windows, .dispose calls DeleteObject, and according to MSND, the objects assigned to GC should not be deleted. Windows XP is robust enough to resists such misuse. I don't know if Windows 98 of GTK can handle it.

A safe behavior of SWT would be to record that the pattern is in use by the GC, and when you try to dispose the pattern, either you get an exception or you dipose the GC causing the .fillRectangle() to throw an exception.

ATTENTION Le message contenu dans cet email ainsi que dans tout fichier attaché est destiné exclusivement aux personnes dont le nom figure ci-dessus. Il peut contenir des informations confidentielles ou protégées par le secret professionnel et dont la divulgation est strictement prohibée. Si vous avez reçu cet email par erreur,détruisez-en le contenu. Vous n'êtes pas autorisé, dans cette hypothèse, à copier, distribuer ou conserver ce message. Merci.

WARNING This information in this mail and in any attachments is intended for the above-mentioned addressees only. It may contain privileged or confidential informationthe review, dissemination or disclosure of which is strictly prohibited. If you have received this email by error, please destroy it. In this case, you are not authorisedto disclose, copy, distribute, or retain this message or any part of it. Thank you.