mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Do not panic if the document contains a global but no normal component
Fixes #2005 (Unfortunately, we can't make a driver test for this becasue the behavior with the interpreter is different than with the compilers. The interpreter errors out, while the compiler should just generate nothing)
This commit is contained in:
parent
3d171320e9
commit
af50c2c2c2
3 changed files with 18 additions and 6 deletions
|
@ -287,7 +287,7 @@ mod cpp_ast {
|
|||
}
|
||||
|
||||
use crate::expression_tree::{BuiltinFunction, EasingCurve};
|
||||
use crate::langtype::{NativeClass, Type};
|
||||
use crate::langtype::{ElementType, NativeClass, Type};
|
||||
use crate::layout::Orientation;
|
||||
use crate::llr::{
|
||||
self, EvaluationContext as llr_EvaluationContext, ParentCtx as llr_ParentCtx,
|
||||
|
@ -583,6 +583,14 @@ pub fn generate(doc: &Document) -> impl std::fmt::Display {
|
|||
}
|
||||
}
|
||||
|
||||
if matches!(
|
||||
doc.root_component.root_element.borrow().base_type,
|
||||
ElementType::Error | ElementType::Global
|
||||
) {
|
||||
// empty document, nothing to generate
|
||||
return file;
|
||||
}
|
||||
|
||||
let llr = llr::lower_to_item_tree::lower_to_item_tree(&doc.root_component);
|
||||
|
||||
// Forward-declare the root so that sub-components can access singletons, the window, etc.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue