-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when resizing the window #1
Comments
This error is not happening on my code, could you send me the code you're trying to do with it? |
So i was trying to fix the code and looks like the pixmap variable on the uwindow.rs is broken. The variable has a length and the length of the variable (that is a &[u8]) is smaller then you are actually trying to access on: for index in 0..(width * height) as usize {
buffer[index] = pixmap[index * 4 + 2] as u32
| (pixmap[index * 4 + 1] as u32) << 8
| (pixmap[index * 4] as u32) << 16;
} |
So i tried removing this block of code and it started working properly... When you have free time, post an explanation of what this does! |
Screencast.2024-02-11.20.08.30.webmAs shown in the video, when you change the size of the window, the location of the button changes as required, but sometimes the error mentioned previously appears. |
I appreciate your suggestion, but I don't think this is the desired solution The problem lies in this block: WindowEvent::CursorMoved { position,device_id , modifiers }
=> {
let x = position.x as i32;
let y = position.y as i32;
if (x <= screenoff_buffer.image_info().bounds().width()) &&(y <= screenoff_buffer.image_info().bounds().height()) && (x>0) && (y>0){
_current_pixel = screenoff_buffer.peek_pixels().unwrap().get_color((x,y));
}
if last_pixel != _current_pixel {
last_pixel = _current_pixel;
println!("mouse pixel: {last_pixel:?}"); The current possible solution is to add a condition to prevent the pixel color from being read when the window size is changed, but the problem remains that the buffer with the window does not change quickly enough (I do not know if this is due to the LXDE desktop environment for Linux, or due to a problem with the code structure). I have added some information in the read.me file if you want to know briefly how the code works |
When I resize the window, sometimes get this message:
my_gui_v0.01/target/debug/examples/simple_window` mouse pixel: Color(4294967295) thread 'main' panicked at 'assertion failed: p.x >= 0 && p.x < self.width()', /home/admin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/skia-safe-0.68.0/src/core/pixmap.rs:161:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
After some modifications I got this:
thread 'main' panicked at 'index out of bounds: the len is 1114280 but the index is 1114282', ....../my_gui_v0.01/src/uwindow.rs:147:69 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
After some other modifications :
thread 'main' panicked at 'index out of bounds: the len is 787920 but the index is 787922', ......./my_gui_v0.01/src/uwindow.rs:147:69 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The text was updated successfully, but these errors were encountered: