cloudhead / rx

👾 Modern and minimalist pixel editor
https://discord.gg/xHggPjfsS9
GNU General Public License v3.0
3.09k stars 109 forks source link

init.rx: fatal: no active view #51

Closed pop closed 4 years ago

pop commented 4 years ago

When loading config options from ~/.config/rx/init.rx I'm getting the following errors:

[2020-01-04T23:46:09Z DEBUG rx::session] source: /home/pop/.config/rx/init.rx
[2020-01-04T23:46:09Z DEBUG rx::session] command: Set("checker", Bool(true))
[2020-01-04T23:46:09Z DEBUG rx::session] set `checker`: off -> on
[2020-01-04T23:46:09Z DEBUG rx::session] command: Set("grid/spacing", U32Tuple(4, 4))
[2020-01-04T23:46:09Z DEBUG rx::session] set `grid/spacing`: 8,8 -> 4,4
[2020-01-04T23:46:09Z DEBUG rx::session] command: ResizeFrame(64, 64)
thread 'main' panicked at 'fatal: no active view', src/session.rs:1293:9

Not every setting triggers this crash, but these do:

Seems like any command that calls self.active_view_mut() triggers the crash. Maybe the active view needs to be initialized before config files are loaded?

Without those config options set rx starts and runs well.

I'd love to contribute to the project. If I could get some direction on what changes should be made and where to make them I'd be more than happy to put together a pull request.


System details:

Let me know if you need more system deets.

cloudhead commented 4 years ago

Thanks for opening this!

I think loading a view before loading the config makes sense as a fix.


lib.rs is the entry point, and session::init is where init.rx gets loaded. session::blank is how the initial blank view is created, which is done in lib.rs after ::init.

The desired behavior is that a blank view is created only if rx wasn't started with a file name, eg. rx hero.png. So the blank view creation is under the if session.views.is_empty() conditional.

I think the first thing to try would be to just move the blank view creation before the ::init, and see what happens.

Let me know if you run into any trouble.

pop commented 4 years ago

@cloudhead That worked! PR open, I'd love some feedback. It's definitely a first draft.

cloudhead commented 4 years ago

Great, will have a look tomorrow!

pop commented 4 years ago

~Hmm. I just checked master and this seems like it's still broken. I'm digging into why but we may want to re-open this.~ EDIT: my PATH was messed up and I was using the wrong rx. Keep this closed. :sweat_smile: