Fix a crash when creating views on the placeholder screen
When a compositor has no outputs listed Qt creates a dummy placeholder QScreen object that does not represent a wl_output. This should still be fixed in the clients to not create a view, it's wasteful and probably will still have plenty of other bugs, hence the giant warning, but it's still worth guarding. CCBUG: 439096
This commit is contained in:
		
							parent
							
								
									331505a4d2
								
							
						
					
					
						commit
						4a439143ba
					
				
					 1 changed files with 9 additions and 1 deletions
				
			
		| 
						 | 
					@ -8,6 +8,7 @@
 | 
				
			||||||
#include "interfaces/shell.h"
 | 
					#include "interfaces/shell.h"
 | 
				
			||||||
#include "qwaylandlayershell_p.h"
 | 
					#include "qwaylandlayershell_p.h"
 | 
				
			||||||
#include "qwaylandlayersurface_p.h"
 | 
					#include "qwaylandlayersurface_p.h"
 | 
				
			||||||
 | 
					#include "layershellqt_logging.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QtWaylandClient/private/qwaylandscreen_p.h>
 | 
					#include <QtWaylandClient/private/qwaylandscreen_p.h>
 | 
				
			||||||
#include <QtWaylandClient/private/qwaylandsurface_p.h>
 | 
					#include <QtWaylandClient/private/qwaylandsurface_p.h>
 | 
				
			||||||
| 
						 | 
					@ -22,7 +23,14 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShell *shell, QtWaylandC
 | 
				
			||||||
    LayerShellQt::Window *interface = Window::get(window->window());
 | 
					    LayerShellQt::Window *interface = Window::get(window->window());
 | 
				
			||||||
    Q_ASSERT(interface);
 | 
					    Q_ASSERT(interface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    init(shell->get_layer_surface(window->waylandSurface()->object(), window->waylandScreen()->output(), interface->layer(), interface->scope()));
 | 
					    // Qt will always assign a screen to a window, but if the compositor has no screens available a dummy QScreen object is created
 | 
				
			||||||
 | 
					    // this will not cast to a QWaylandScreen
 | 
				
			||||||
 | 
					    QtWaylandClient::QWaylandScreen *screen = window->waylandScreen();
 | 
				
			||||||
 | 
					    if (screen->isPlaceholder()) {
 | 
				
			||||||
 | 
					        qCWarning(LAYERSHELLQT) << "Creating a layer shell for placeholder screen. This will be positioned incorrectly";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    init(shell->get_layer_surface(window->waylandSurface()->object(), screen->isPlaceholder() ? nullptr : screen->output(), interface->layer(), interface->scope()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Window::Anchors anchors = interface->anchors();
 | 
					    Window::Anchors anchors = interface->anchors();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue