Bizzare JUCE Graphics glitch


I’ve been on the receiving end of a really bizarre bug in JUCE. I have a component that is supposed to repaint itself when I click it. If I click, it should change an underlying variable. And call repaint. The paint method will see the change in that variable, and draw things differently. For hours now, I was trying to figure out why the change was not being reflected immediately in the display. If I exit the screen and then come back to it, the graphical components will begin to acknowledge the change and display correctly. But this is the only way that I can update the display, which is not ideal.

The bizarre thing, however, is that if I move the app to my other monitor, the graphical components instantly appear exactly like they’re supposed to. And then when I move the app back to the original monitor, it goes back to showing the wrong thing.

I have tried using debug mode to see what was happening and the paint function is definitely receiving the correct data and calling the correct methods that should result in it drawing correctly. But the app window seems to be drawing from different blocks of memory depending on which monitor I put the app on. If I load the screen while the app is on my left monitor, then the screen will only work properly on my right monitor. Then if I exit the screen and load it again whilst on my right monitor, the screen will only work properly on my left monitor. This is driving me mad!

I’m using Mac OS/X, with the latest version of JUCE and second most recent update of XCode. (The latest version only came available several hours ago).


I found a reasonable solution to the problem. The problem seems to be related to the fact that I am using several Graphics contexts that draw directly onto images, and then when I’ve finished drawing to those images, I draw the images onto the component.

Originally, when I wanted to start drawing to those Graphics contexts, I would start by calling fillAll(Colours::white). But now, I realise that the problem goes away if instead of filling with white on the Graphics object, I now run the clear method directly on the image.