mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
fix for issue #145
This commit is contained in:
parent
ae60065040
commit
ce5a81878c
1 changed files with 28 additions and 16 deletions
|
|
@ -491,6 +491,17 @@ fn xmain() -> ! {
|
||||||
log::debug!("trying to switch to {:?} with token {:?}", switchapp.app_name.as_str().unwrap(), switchapp.token);
|
log::debug!("trying to switch to {:?} with token {:?}", switchapp.app_name.as_str().unwrap(), switchapp.token);
|
||||||
|
|
||||||
if let Some(new_app_token) = context_mgr.find_app_token_by_name(switchapp.app_name.as_str().unwrap()) {
|
if let Some(new_app_token) = context_mgr.find_app_token_by_name(switchapp.app_name.as_str().unwrap()) {
|
||||||
|
if new_app_token != context_mgr.focused_app().unwrap_or([0, 0, 0, 0]) {
|
||||||
|
// two things:
|
||||||
|
// 1. [0, 0, 0, 0] is simply a very unlikely GID because it's a 128 bit TRNG, and this allows us to handle
|
||||||
|
// the power-on case where we have no focused app cleanly.
|
||||||
|
// 2. the `activate()` method on `context_mgr` does not handle app-to-app switches when you're the same app.
|
||||||
|
// this is because there is a rule which says if you're going to put an app on top of an app, take the old
|
||||||
|
// app and hide it, while also taking the new app and showing it. This is a race condition, and it results
|
||||||
|
// in the "same-app" switch ending up in a hidden state, because within the routine the entering state is
|
||||||
|
// set before the leaving state due to interior-mutability issues (see the block under the debug statement
|
||||||
|
// titled "resolving visibility rules"). The fix is to simply not issue a context switch if it's the same app.
|
||||||
|
// It saves CPU thrashing and also works around this problem. (see issue #145)
|
||||||
let authorized_switchers = vec![MAIN_MENU_NAME, ROOTKEY_MODAL_NAME, gam::STATUS_BAR_NAME];
|
let authorized_switchers = vec![MAIN_MENU_NAME, ROOTKEY_MODAL_NAME, gam::STATUS_BAR_NAME];
|
||||||
for switchers in authorized_switchers {
|
for switchers in authorized_switchers {
|
||||||
if let Some(auth_token) = context_mgr.find_app_token_by_name(switchers) {
|
if let Some(auth_token) = context_mgr.find_app_token_by_name(switchers) {
|
||||||
|
|
@ -513,6 +524,7 @@ fn xmain() -> ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Some(Opcode::RaiseMenu) => {
|
Some(Opcode::RaiseMenu) => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue