Revert part of fd993d0b52
Only keep the change in `evaluate` to fix the leak.
We can't destroy the nodes in mark_dirty as destroying them while
iterating lead to crash
The dependency nodes would be leaked.
(This was particularly bad for the ones from the Flickable's bounds
change tracker since that one has many dependencies, while most change
tracker only have one)
Fixes#8768
Don't drop the ChangeTracker's BindingHolder if it is currently being
evaluated as we still need it later.
There was also a bug in DependencyListHead::clear as it was not properly
updating all the field, and the use of for_each was problematic if nodes
gets delete as we iterate.
Fixes#8741
This is a hacky approach, but does help a lot with the tedious fixes.
See https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_map_or
```
__CARGO_FIX_YOLO=1 cargo clippy --fix --all-targets --workspace --exclude gstreamer-player --exclude i-slint-backend-linuxkms --exclude uefi-demo --exclude ffmpeg -- -A clippy::all -W clippy::unnecessary_map_or
cargo fmt --all
```
And call `extern crate std` when the feature is enabled.
I've read this is the good practice on how to do it.
So that the std prelude is no longer included automatically.
There is then less difference between std and and no-std build which
should avoid surprises in the CI when we use things from the prelude.
The downside is that there is a bit of churn in the tests
Updated the version from 1.1 to 1.2
Renamed the header to "Slint Royalty-free Desktop, Mobile, and Web Applications License"
Added definition of "Mobile Application" and grant of right
Moved "Limitations" to 3rd section and "License Conditions - Attributions" to 2nd section
Added flexibility to choose between showing "MadeWithSlint" as a dialog/splash screen or on a public webpage
Moved the para on copyright notices to section under "Limitations"
Fix binding a two-way bound property to another property: The value of
the first bproperty was used here, while it is documented to use the
value of the second.
Add test cases for two-way bindings in first, second an in both places
when creating another two-way binding to make sure everything works and
stays that way :-)
* Configure clippy to not report about type complexity until *much*
later
* Configure clippy to only complain about more than 10 function
arguments
* Properly format safety sections
* Allow unnecessary main functions in doctests in the slint API crate
* AccessKit: Move big block of code before if condition
When updating multiple models between frames, it's possible
that multiple bindings will be marked dirty many times.
In diamond dependencies, marking one binding could also
end up affecting another binding through multiple intermediate
dependencies.
The process can then be quite expensive even for medium scenes.
If a binding is already marked dirty we can however assume
that all of its dependencies are already marked dirty.
This reduces the complexity of marking large dependency
branches multiple times.
States are never constant because the generated state binding depend on
the time as it register the time it was set for the pottential animation
Also adjust the assert so it assert correctly which the right message
Fixes: #2274
The const detection for two way binding was not detecting change if one
of the property was set to a const value in a component using it.
This would cause the compiler to generate call set_content on one of the
property in a two way bindings, and later, the "const sentinel" be
present in the dependency list, causing crash.
To avoid segfault for similar bug in the future, added added an assert!
in the property system to detect that.
Fixes#2185
This can be reproduced with this example:
```
import { TabWidget } from "std-widgets.slint";
App := Window {
preferred-width: 700px;
preferred-height: 500px;
HorizontalLayout {
side-bar := TouchArea {
property <int> current-item: 1;
clicked => { current-item = current-item == 0 ? 1 : 0 ; }
}
if(side-bar.current-item == 0) : TabWidget { }
}
}
```
With the native style. (click on the window, then resize)
This will result in a stack overflow, because we have a cycle in the
dependency graph and they are marked dirty forever.
The NativeTabWidget will create two way binding internally. And it will
be crated as a result of the layout cache property because that's when
the model will be evaluated and created. This will inatvertently create
a dependency between the layout cache property, and the two way link.
During the rendering, if an area is clipped, it will not be rendered and
therefore will not be rendered as a dependency.
Consider this example:
```
HorizontalBox {
Rectangle {
TouchArea{
Rectangle { background: parent.pressed ? red : blue; }
}
}
Rectangle {
clip: true;
TouchArea{
Rectangle { background: parent.pressed ? red: blue; }
}
}
}
}
```
Clicking on the first rectangle will make that area dirty and it will be
redrawn, but since the second one is clipped away, the renderer will not
visit the child items. And clicking on the second rectangle will not
make it re-drawn.
This patch makes sure we rejuster ad dependency of the window tracker
the non-dirty areas
This fix the printerdemo_mcu stopping to render in some cases
```
warning: unused return value of `alloc::boxed::Box::<T>::from_raw` that must be used
Warning: --> internal/core/properties.rs:382:9
|
382 | Box::from_raw(_self as *mut BindingHolder<B>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: call `drop(from_raw(ptr))` if you intend to drop the `Box`
```
Just do what the note says
... via two ways bindings
Otherwise we could be in a case where we have an unbounded number of "shared" property
which might not be shared anymore if the original property goes out of scope
When resetting the binding, we need to mark dependent property as dirty.
It just hapenned that the current implementation always set all bindings
before starting to query the properties, so this problem was not seen
before. But there is an exception when setting the two_way bindings,
then we may set the binding after the property was querried because
setting a two way binding actually queries the property
The README.md contains the warning that used to be in lib.rs.
Add README.md files to all internal crates
... pointing to the official public crate to use instead.
Rename internal crates
fixup: README files
fixup rename