Last active
July 10, 2020 11:12
-
-
Save mtkennerly/a99cc41ef39395dfb89c91cc44bb80a8 to your computer and use it in GitHub Desktop.
Panic in Iced when programmatically modifying text with an active selection and immediately pasting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thread 'main' panicked at 'end drain index (is 63) should be <= len (is 8)', src\liballoc\vec.rs:1331:13 | |
stack backtrace: | |
0: backtrace::backtrace::trace_unsynchronized | |
at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.46\src\backtrace\mod.rs:66 | |
1: std::sys_common::backtrace::_print_fmt | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\sys_common\backtrace.rs:78 | |
2: std::sys_common::backtrace::_print::{{impl}}::fmt | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\sys_common\backtrace.rs:59 | |
3: core::fmt::write | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libcore\fmt\mod.rs:1069 | |
4: std::io::Write::write_fmt<std::sys::windows::stdio::Stderr> | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\io\mod.rs:1504 | |
5: std::sys_common::backtrace::_print | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\sys_common\backtrace.rs:62 | |
6: std::sys_common::backtrace::print | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\sys_common\backtrace.rs:49 | |
7: std::panicking::default_hook::{{closure}} | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:198 | |
8: std::panicking::default_hook | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:218 | |
9: std::panicking::rust_panic_with_hook | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:511 | |
10: std::panicking::begin_panic_handler | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:419 | |
11: core::panicking::panic_fmt | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libcore\panicking.rs:111 | |
12: alloc::vec::{{impl}}::drain::end_assert_failed | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\liballoc\vec.rs:1331 | |
13: alloc::vec::Vec<alloc::string::String>::drain<alloc::string::String,core::ops::range::Range<usize>> | |
at C:\Users\mtken\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\liballoc\vec.rs:1338 | |
14: alloc::vec::Vec<alloc::string::String>::splice<alloc::string::String,core::ops::range::Range<usize>,core::iter::sources::Empty<alloc::string::String>> | |
at C:\Users\mtken\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\liballoc\vec.rs:2247 | |
15: iced_native::widget::text_input::value::Value::remove_many | |
at C:\Users\mtken\.cargo\git\checkouts\iced-9e73d2fbe1fce35a\46ce3a1\native\src\widget\text_input\value.rs:120 | |
16: iced_native::widget::text_input::editor::Editor::paste | |
at C:\Users\mtken\.cargo\git\checkouts\iced-9e73d2fbe1fce35a\46ce3a1\native\src\widget\text_input\editor.rs:36 | |
17: iced_native::widget::text_input::{{impl}}::on_event<paste_panic::Message,iced_graphics::renderer::Renderer<iced_wgpu::backend::Backend>> | |
at C:\Users\mtken\.cargo\git\checkouts\iced-9e73d2fbe1fce35a\46ce3a1\native\src\widget\text_input.rs:448 | |
18: iced_native::user_interface::UserInterface<paste_panic::Message, iced_graphics::renderer::Renderer<iced_wgpu::backend::Backend>>::update<paste_panic::Message,iced_graphics::renderer::Renderer<iced_wgpu::backend::Backend>,alloc::vec::Drain<iced_native::eve | |
at C:\Users\mtken\.cargo\git\checkouts\iced-9e73d2fbe1fce35a\46ce3a1\native\src\user_interface.rs:196 | |
19: iced_native::program::state::State<iced::application::Instance<paste_panic::App>>::update<iced::application::Instance<paste_panic::App>> | |
at C:\Users\mtken\.cargo\git\checkouts\iced-9e73d2fbe1fce35a\46ce3a1\native\src\program\state.rs:123 | |
20: iced_winit::application::run::{{closure}}::{{closure}}<iced::application::Instance<paste_panic::App>,iced::executor::platform::Default,iced_wgpu::window::compositor::Compositor> | |
at C:\Users\mtken\.cargo\git\checkouts\iced-9e73d2fbe1fce35a\46ce3a1\winit\src\application.rs:188 | |
21: iced_futures::executor::Executor::enter<futures_executor::thread_pool::ThreadPool,core::option::Option<iced_futures::command::Command<paste_panic::Message>>,closure-0> | |
at C:\Users\mtken\.cargo\git\checkouts\iced-9e73d2fbe1fce35a\46ce3a1\futures\src\executor.rs:62 | |
22: iced::executor::platform::{{impl}}::enter<core::option::Option<iced_futures::command::Command<paste_panic::Message>>,closure-0> | |
at C:\Users\mtken\.cargo\git\checkouts\iced-9e73d2fbe1fce35a\46ce3a1\src\executor.rs:43 | |
23: iced_futures::runtime::Runtime<iced_native::hasher::Hasher, iced_native::event::Event, iced::executor::platform::Default, iced_winit::proxy::Proxy<paste_panic::Message>, paste_panic::Message>::enter<iced_native::hasher::Hasher,iced_native::event::Event,ic | |
at C:\Users\mtken\.cargo\git\checkouts\iced-9e73d2fbe1fce35a\46ce3a1\futures\src\runtime.rs:58 | |
24: iced_winit::application::run::{{closure}}<iced::application::Instance<paste_panic::App>,iced::executor::platform::Default,iced_wgpu::window::compositor::Compositor> | |
at C:\Users\mtken\.cargo\git\checkouts\iced-9e73d2fbe1fce35a\46ce3a1\winit\src\application.rs:187 | |
25: winit::platform_impl::platform::event_loop::{{impl}}::run_return::{{closure}}<paste_panic::Message,closure-1> | |
at C:\Users\mtken\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:200 | |
26: alloc::boxed::{{impl}}::call_mut<(winit::event::Event<paste_panic::Message>, mut winit::event_loop::ControlFlow*),FnMut<(winit::event::Event<paste_panic::Message>, mut winit::event_loop::ControlFlow*)>> | |
at C:\Users\mtken\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\liballoc\boxed.rs:1015 | |
27: winit::platform_impl::platform::event_loop::runner::{{impl}}::call_event_handler::{{closure}}<paste_panic::Message> | |
at C:\Users\mtken\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:239 | |
28: std::panic::{{impl}}::call_once<(),closure-0> | |
at C:\Users\mtken\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panic.rs:318 | |
29: std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure-0>,()> | |
at C:\Users\mtken\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panicking.rs:331 | |
30: std::panicking::try::do_catch<std::panic::AssertUnwindSafe<closure-0>,()> | |
31: std::panicking::try<(),std::panic::AssertUnwindSafe<closure-0>> | |
at C:\Users\mtken\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panicking.rs:274 | |
32: std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure-0>,()> | |
at C:\Users\mtken\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panic.rs:394 | |
33: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<paste_panic::Message>::catch_unwind<paste_panic::Message,(),closure-0> | |
at C:\Users\mtken\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:150 | |
34: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<paste_panic::Message>::call_event_handler<paste_panic::Message> | |
at C:\Users\mtken\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:233 | |
35: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<paste_panic::Message>::move_state_to<paste_panic::Message> | |
at C:\Users\mtken\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:319 | |
36: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<paste_panic::Message>::main_events_cleared<paste_panic::Message> | |
at C:\Users\mtken\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:225 | |
37: winit::platform_impl::platform::event_loop::flush_paint_messages<paste_panic::Message> | |
at C:\Users\mtken\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:663 | |
38: winit::platform_impl::platform::event_loop::thread_event_target_callback::{{closure}}<paste_panic::Message> | |
at C:\Users\mtken\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:1938 | |
39: std::panic::{{impl}}::call_once<isize,closure-0> | |
at C:\Users\mtken\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panic.rs:318 | |
40: std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure-0>,isize> | |
at C:\Users\mtken\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panicking.rs:331 | |
41: std::panicking::try::do_catch<std::panic::AssertUnwindSafe<closure-0>,()> | |
42: std::panicking::try<isize,std::panic::AssertUnwindSafe<closure-0>> | |
at C:\Users\mtken\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panicking.rs:274 | |
43: std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure-0>,isize> | |
at C:\Users\mtken\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panic.rs:394 | |
44: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<paste_panic::Message>::catch_unwind<paste_panic::Message,isize,closure-0> | |
at C:\Users\mtken\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:150 | |
45: winit::platform_impl::platform::event_loop::thread_event_target_callback<paste_panic::Message> | |
at C:\Users\mtken\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:2120 | |
46: DefSubclassProc | |
47: DefSubclassProc | |
48: CallWindowProcW | |
49: DispatchMessageW | |
50: IsWindowVisible | |
51: KiUserCallbackDispatcher | |
52: NtUserDispatchMessage | |
53: DispatchMessageW | |
54: winit::platform_impl::platform::event_loop::EventLoop<paste_panic::Message>::run_return<paste_panic::Message,closure-1> | |
at C:\Users\mtken\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:215 | |
55: winit::platform_impl::platform::event_loop::EventLoop<paste_panic::Message>::run<paste_panic::Message,closure-1> | |
at C:\Users\mtken\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:185 | |
56: winit::event_loop::EventLoop<paste_panic::Message>::run<paste_panic::Message,closure-1> | |
at C:\Users\mtken\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\event_loop.rs:149 | |
57: iced_winit::application::run<iced::application::Instance<paste_panic::App>,iced::executor::platform::Default,iced_wgpu::window::compositor::Compositor> | |
at C:\Users\mtken\.cargo\git\checkouts\iced-9e73d2fbe1fce35a\46ce3a1\winit\src\application.rs:181 | |
58: iced::application::Application::run<paste_panic::App> | |
at C:\Users\mtken\.cargo\git\checkouts\iced-9e73d2fbe1fce35a\46ce3a1\src\application.rs:229 | |
59: paste_panic::main | |
at .\src\main.rs:75 | |
60: std::rt::lang_start::{{closure}}<()> | |
at C:\Users\mtken\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\rt.rs:67 | |
61: std::rt::lang_start_internal::{{closure}} | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\rt.rs:52 | |
62: std::panicking::try::do_call | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:331 | |
63: std::panicking::try | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:274 | |
64: std::panic::catch_unwind | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panic.rs:394 | |
65: std::rt::lang_start_internal | |
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\rt.rs:51 | |
66: std::rt::lang_start<()> | |
at C:\Users\mtken\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\rt.rs:67 | |
67: main | |
68: invoke_main | |
at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:78 | |
69: __scrt_common_main_seh | |
at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283 | |
70: BaseThreadInitThunk | |
71: RtlUserThreadStart | |
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. | |
error: process didn't exit successfully: `target\debug\paste-panic.exe` (exit code: 101) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "paste-panic" | |
version = "0.1.0" | |
authors = ["mtkennerly <mtkennerly@gmail.com>"] | |
edition = "2018" | |
[dependencies] | |
# iced = "0.1.1" | |
# iced_native = "0.2.2" | |
iced = { git = "https://github.com/hecrj/iced" } | |
iced_native = { git = "https://github.com/hecrj/iced" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use iced::{executor, text_input, Application, Command, Element, Subscription, TextInput}; | |
#[derive(Debug, Clone)] | |
enum Message { | |
Edit(String), | |
Event(iced_native::Event), | |
} | |
#[derive(Default)] | |
struct App { | |
text: String, | |
input: text_input::State, | |
} | |
impl Application for App { | |
type Executor = executor::Default; | |
type Message = Message; | |
type Flags = (); | |
fn new(_flags: ()) -> (Self, Command<Message>) { | |
( | |
Self { | |
text: "Select some text near the end, press ctrl+x, then try ctrl+v and it'll panic".to_owned(), | |
..Default::default() | |
}, | |
Command::none(), | |
) | |
} | |
fn title(&self) -> String { | |
"Paste Panic".to_string() | |
} | |
fn update(&mut self, message: Message) -> Command<Message> { | |
match message { | |
Message::Edit(text) => { | |
self.text = text; | |
Command::none() | |
} | |
Message::Event(event) => { | |
if let iced_native::Event::Keyboard(key) = event { | |
// iced v0.1.1 and iced_native v0.2.2: | |
// if let iced_native::input::keyboard::Event::Input { state, key_code, modifiers } = key { | |
// if key_code == iced_native::input::keyboard::KeyCode::X && state == iced_native::input::ButtonState::Pressed && modifiers.control { | |
// self.text = "modified".to_owned(); | |
// } | |
// } | |
// iced/iced_native master: | |
if let iced_native::keyboard::Event::KeyPressed { | |
key_code, | |
modifiers, | |
} = key | |
{ | |
if key_code == iced_native::keyboard::KeyCode::X && modifiers.control { | |
self.text = "modified".to_owned(); | |
} | |
} | |
} | |
Command::none() | |
} | |
} | |
} | |
fn subscription(&self) -> Subscription<Message> { | |
iced_native::subscription::events().map(Message::Event) | |
} | |
fn view(&mut self) -> Element<Message> { | |
TextInput::new(&mut self.input, "", &self.text, Message::Edit).into() | |
} | |
} | |
fn main() { | |
App::run(iced::Settings::default()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment