macOS: Improve layer delegate setup

We should detect the cases where there's already a delegate, and
setting up the delegate before the layer is added makes sense.

Change-Id: I67896cbc96d11ce9a3826fd8aa0e5e104a83a21c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Tor Arne Vestbø 2019-09-25 17:38:06 +02:00
parent fd49d5e315
commit cefd214b1b

View File

@ -160,8 +160,14 @@
<< "with" << layer << "due to being" << ([self layerExplicitlyRequested] ? "explicitly requested"
: [self shouldUseMetalLayer] ? "needed by surface type" : "enabled by macOS");
if (layer.delegate && layer.delegate != self) {
qCWarning(lcQpaDrawing) << "Layer already has delegate" << layer.delegate
<< "This delegate is responsible for all view updates for" << self;
} else {
layer.delegate = self;
}
[super setLayer:layer];
layer.delegate = self;
// When adding a view to a view hierarchy the backing properties will change
// which results in updating the contents scale, but in case of switching the