fix [#26685] Cannot exit from "edit mode"

this does not fix the underlying problem that once in this state you cant exit editmode, only that the layer key bindings dont let the state come about.

Looked into fixing properly but its not so simple since currently object mode operators all use "active_object" which is supposed not to be set when in a hidden layer.
This commit is contained in:
2011-03-30 15:28:38 +00:00
parent 9ba57b6518
commit 4f29bc2594

View File

@@ -147,6 +147,21 @@ static void handle_view3d_lock(bContext *C)
- uiTemplateLayers in interface/ code for buttons
- ED_view3d_scene_layer_set for RNA
*/
static void view3d_layers_editmode_ensure(Scene *scene, View3D *v3d)
{
/* sanity check - when in editmode disallow switching the editmode layer off since its confusing
* an alternative would be to always draw the editmode object. */
if(scene->obedit && (scene->obedit->lay & v3d->lay)==0) {
int bit;
for(bit=0; bit<32; bit++) {
if(scene->obedit->lay & (1<<bit)) {
v3d->lay |= 1<<bit;
break;
}
}
}
}
static int view3d_layers_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
@@ -166,7 +181,10 @@ static int view3d_layers_exec(bContext *C, wmOperator *op)
if (toggle && v3d->lay == ((1<<20)-1)) {
/* return to active layer only */
v3d->lay = v3d->layact;
} else {
view3d_layers_editmode_ensure(scene, v3d);
}
else {
v3d->lay |= (1<<20)-1;
}
}
@@ -181,19 +199,10 @@ static int view3d_layers_exec(bContext *C, wmOperator *op)
v3d->lay |= (1<<nr);
} else {
v3d->lay = (1<<nr);
/* sanity check - when in editmode disallow switching the editmode layer off since its confusing
* an alternative would be to always draw the editmode object. */
if(scene->obedit && (scene->obedit->lay & v3d->lay)==0) {
for(bit=0; bit<32; bit++) {
if(scene->obedit->lay & (1<<bit)) {
v3d->lay |= 1<<bit;
break;
}
}
}
}
view3d_layers_editmode_ensure(scene, v3d);
/* set active layer, ensure to always have one */
if(v3d->lay & (1<<nr))
v3d->layact= 1<<nr;