The wait cursor was being called during editmode enter and exit for meshes.
This was a problem for several reasons. First of all, python modules like
Mesh now make use of editmode features. These methods that wrap editmode
tools may be called many times during the execution of a script
and lead to the wait cursor rapidly flickering on and off.
The other problem was that the wait cursor wasn't being called for editmode
enter and exit of all data types. This is unified now.
-New Arguments
enter_editmode() should be passed a nonzero integer or simply EM_WAITCURSOR
if the wait cursor is desired. Currently only the python API passes a '0'
to enter_editmode()
exit_editmode() has several options and they are passed in as the bitflags
EM_FREEDATA, EM_FREEUNDO and EM_WAITCURSOR. These flags are defined in
BDR_editobject.h.
int test_parent_loop(struct Object *par, struct Object *ob);
void make_parent(void);
-void exit_editmode(int freedata);
+#define EM_WAITCURSOR (1 << 0)
+#define EM_FREEDATA (1 << 1)
+#define EM_FREEUNDO (1 << 2)
+
+void exit_editmode(int flag);
void check_editmode(int type);
-void enter_editmode(void);
+void enter_editmode(int wc);
void docentre(int centremode);
void docentre_new(void);
}
if( G.obedit )
- exit_editmode( 1 );
+ exit_editmode(EM_FREEDATA);
if (G.background) { /* background mode */
if (is_blend_file)
EXPP_allqueue( REDRAWVIEW3D, 0 );
if (ob && G.obedit) { /* prevents a crash when a new object is created */
- exit_editmode(1);
- enter_editmode();
+ exit_editmode(EM_FREEDATA);
+ enter_editmode(0);
}
// @OK...this requires some explanation:
/* exit editmode so join can be done */
if( G.obedit )
- exit_editmode( 1 );
+ exit_editmode( EM_FREEDATA );
temp_scene = add_scene( "Scene" ); /* make the new scene */
temp_scene->lay= 1; /* first layer on */
if( status >= 0 ) {
if( status ) {
if( !G.obedit )
- enter_editmode( );
+ enter_editmode(0);
} else if( G.obedit ) {
if( do_undo && U.undosteps != 0 ) {
if( undo_str_len > 63 )
undo_str[63] = '\0'; /* 64 is max */
undo_push_mesh( undo_str ); /* use better solution after 2.34 */
}
- exit_editmode( 1 );
+ exit_editmode( EM_FREEDATA );
}
}
/* ending all modes */
if( G.obedit)
- exit_editmode(2);
+ exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
if(G.f & G_FACESELECT)
set_faceselect();
/* Put the active armature into editmode and join the bones from the other one*/
- enter_editmode();
+ enter_editmode(EM_WAITCURSOR);
for (base=FIRSTBASE; base; base=nextbase) {
nextbase = base->next;
DAG_scene_sort(G.scene); // because we removed object(s)
- exit_editmode(1);
+ exit_editmode(EM_FREEDATA|EM_WAITCURSOR);
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWOOPS, 0);
return 1;
DAG_scene_sort(G.scene); // because we removed object(s), call before editmode!
- enter_editmode();
- exit_editmode(1);
+ enter_editmode(EM_WAITCURSOR);
+ exit_editmode(EM_FREEDATA|EM_WAITCURSOR);
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWBUTSEDIT, 0);
}
make_editText();
- exit_editmode(1);
+ exit_editmode(EM_FREEDATA|EM_WAITCURSOR);
allqueue(REDRAWVIEW3D, 0);
}
cu->pos= cu->len;
make_editText();
- exit_editmode(1);
+ exit_editmode(EM_FREEDATA|EM_WAITCURSOR);
linenum++;
curline = curline->next;
cu->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "textbox");
cu->tb[0].w = cu->tb[0].h = 0.0;
- enter_editmode();
+ enter_editmode(EM_WAITCURSOR);
allqueue(REDRAWALL, 0);
}
return;
}
- waitcursor(1);
/* initialize fastmalloc for editmesh */
init_editmesh_fastmalloc(G.editMesh, me->totvert, me->totedge, me->totface);
countall();
- waitcursor(0);
}
/* makes Mesh out of editmesh */
int i, a, ototvert, totedge=0;
MDeformVert *dvert;
- waitcursor(1);
#ifdef WITH_VERSE
if(em->vnode) {
}
mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
- waitcursor(0);
}
void remake_editMesh(void)
setcursor_space(SPACE_VIEW3D, CURSOR_STD);
if ELEM3(curarea->spacetype, SPACE_VIEW3D, SPACE_BUTS, SPACE_INFO) {
- if (G.obedit) exit_editmode(2); // freedata, and undo
+ if (G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); // freedata, and undo
ob= add_object(type);
set_active_base(BASACT);
base_init_from_view3d(BASACT, G.vd);
}
-void enter_editmode(void)
+void enter_editmode(int wc)
{
Base *base;
Object *ob;
return;
}
+ if(wc) waitcursor(1);
+
if(ob->type==OB_MESH) {
me= get_mesh(ob);
if( me==0 ) return;
}
else G.obedit= NULL;
-
+
+ if(wc) waitcursor(0);
+
scrarea_queue_headredraw(curarea);
}
-void exit_editmode(int freedata) /* freedata==0 at render, 1= freedata, 2= do undo buffer too */
+void exit_editmode(int flag) /* freedata==0 at render, 1= freedata, 2= do undo buffer too */
{
Object *ob;
-
+ int freedata = flag & EM_FREEDATA, freeundo = flag & EM_FREEUNDO;
+
if(G.obedit==NULL) return;
+ if(flag & EM_WAITCURSOR) waitcursor(1);
if(G.obedit->type==OB_MESH) {
/* temporal */
scrarea_queue_headredraw(curarea);
- if(G.obedit==NULL && freedata==2)
+ if(G.obedit==NULL && flag & EM_FREEUNDO)
BIF_undo_push("Editmode");
+
+ if(flag & EM_WAITCURSOR) waitcursor(0);
}
void check_editmode(int type)
if (G.obedit==0 || G.obedit->type==type) return;
- exit_editmode(2); // freedata, and undo
+ exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); // freedata, and undo
}
/* 0 == do centre, 1 == centre new, 2 == centre cursor */
/* texspace and normals */
BASACT= base;
- enter_editmode();
- exit_editmode(1); // freedata, but no undo
+ enter_editmode(EM_WAITCURSOR);
+ exit_editmode(EM_FREEDATA|EM_WAITCURSOR); // freedata, but no undo
BASACT= basact;
}
}
/* So we can see the wireframe */
BASACT= basen;
- enter_editmode();
- exit_editmode(1); // freedata, but no undo
+ enter_editmode(EM_WAITCURSOR);
+ exit_editmode(EM_FREEDATA|EM_WAITCURSOR); // freedata, but no undo
BASACT= basact;
/* If the original object is active then make this object active */
/* texspace and normals */
BASACT= base;
- enter_editmode();
+ enter_editmode(EM_WAITCURSOR);
BIF_undo_push("Applied object"); // editmode undo itself
- exit_editmode(1); // freedata, but no undo
+ exit_editmode(EM_FREEDATA|EM_WAITCURSOR); // freedata, but no undo
BASACT= basact;
}
/* texspace and normals */
BASACT= base;
- enter_editmode();
+ enter_editmode(EM_WAITCURSOR);
BIF_undo_push("Applied object"); // editmode undo itself
- exit_editmode(1); // freedata, but no undo
+ exit_editmode(EM_FREEDATA|EM_WAITCURSOR); // freedata, but no undo
BASACT= basact;
}
}
if(okee("Delete current scene")) {
/* exit modes... could become single call once */
- exit_editmode(1);
+ exit_editmode(EM_FREEDATA|EM_WAITCURSOR);
if(G.f & G_VERTEXPAINT) set_vpaint(); /* Switch off vertex paint */
if(G.f & G_TEXTUREPAINT) set_texturepaint(); /* Switch off tex paint */
if(G.f & G_WEIGHTPAINT) set_wpaint(); /* Switch off weight paint */
if(G.f & G_WEIGHTPAINT) set_wpaint(); /* Switch off weight paint */
if(G.f & G_FACESELECT) set_faceselect(); /* Switch off face select */
if(ob) exit_posemode(); /* exit posemode for active object */
- if(G.obedit) exit_editmode(2); /* exit editmode and undo */
+ if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */
}
else if (G.vd->modeselect == V3D_EDITMODE_SEL) {
if(!G.obedit) {
if(G.f & G_TEXTUREPAINT) set_texturepaint(); /* Switch off tex paint */
if(G.f & G_WEIGHTPAINT) set_wpaint(); /* Switch off weight paint */
- enter_editmode();
+ enter_editmode(EM_WAITCURSOR);
BIF_undo_push("Original"); /* here, because all over code enter_editmode is abused */
}
}
else if (G.vd->modeselect == V3D_FACESELECTMODE_SEL) {
if ((G.obedit) && (G.f & G_FACESELECT)) {
- exit_editmode(2); /* exit editmode and undo */
+ exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */
} else if ((G.f & G_FACESELECT) && (G.f & G_VERTEXPAINT)) {
if(G.f & G_VERTEXPAINT) set_vpaint(); /* Switch off vertex paint */
} else if ((G.f & G_FACESELECT) && (G.f & G_TEXTUREPAINT)) {
if(G.f & G_VERTEXPAINT) set_vpaint(); /* Switch off vertex paint */
if(G.f & G_TEXTUREPAINT) set_texturepaint(); /* Switch off tex paint */
if(G.f & G_WEIGHTPAINT) set_wpaint(); /* Switch off weight paint */
- if (G.obedit) exit_editmode(2); /* exit editmode and undo */
+ if (G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */
set_faceselect();
}
G.vd->flag &= ~V3D_MODE;
if(G.f & G_TEXTUREPAINT) set_texturepaint(); /* Switch off tex paint */
if(G.f & G_WEIGHTPAINT) set_wpaint(); /* Switch off weight paint */
- if(G.obedit) exit_editmode(2); /* exit editmode and undo */
+ if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */
set_vpaint();
}
G.vd->flag &= ~V3D_MODE;
if(G.f & G_VERTEXPAINT) set_vpaint(); /* Switch off vertex paint */
if(G.f & G_WEIGHTPAINT) set_wpaint(); /* Switch off weight paint */
- if(G.obedit) exit_editmode(2); /* exit editmode and undo */
+ if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */
set_texturepaint();
}
G.vd->flag &= ~V3D_MODE;
if(G.f & G_VERTEXPAINT) set_vpaint(); /* Switch off vertex paint */
if(G.f & G_TEXTUREPAINT) set_texturepaint(); /* Switch off tex paint */
- if(G.obedit) exit_editmode(2); /* exit editmode and undo */
+ if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */
set_wpaint();
}
if (ob) {
G.vd->flag &= ~V3D_MODE;
- if(G.obedit) exit_editmode(2); /* exit editmode and undo */
+ if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */
enter_posemode();
}
DAG_scene_sort(G.scene); // removed objects, need to rebuild dag before editmode call
- enter_editmode();
- exit_editmode(1); // freedata, but no undo
+ enter_editmode(EM_WAITCURSOR);
+ exit_editmode(EM_FREEDATA|EM_WAITCURSOR); // freedata, but no undo
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWBUTSSHADING, 0);
sce= (Scene *)outliner_search_back(soops, te, ID_SCE);
if(sce && G.scene != sce) {
- if(G.obedit) exit_editmode(2);
+ if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
set_scene(sce);
}
allqueue(REDRAWINFO, 1);
}
- if(ob!=G.obedit) exit_editmode(2);
+ if(ob!=G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
}
static int tree_element_active_material(SpaceOops *soops, TreeElement *te, int set)
if(set) { // make new scene active
if(sce && G.scene != sce) {
- if(G.obedit) exit_editmode(2);
+ if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
set_scene(sce);
}
}
Object *ob= (Object *)tselem->id;
if(set) {
- if(G.obedit) exit_editmode(2);
+ if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
if(ob->flag & OB_POSEMODE) exit_posemode();
else enter_posemode();
}
/* editmode? */
if(te->idcode==ID_SCE) {
if(G.scene!=(Scene *)tselem->id) {
- if(G.obedit) exit_editmode(2);
+ if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
set_scene((Scene *)tselem->id);
}
}
else if(ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) {
- if(G.obedit) exit_editmode(2);
+ if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
else {
- enter_editmode();
+ enter_editmode(EM_WAITCURSOR);
extern_set_butspace(F9KEY, 0);
}
}
if(base==NULL) base= object_in_scene((Object *)tselem->id, G.scene);
if(base) {
// check also library later
- if(G.obedit==base->object) exit_editmode(2);
+ if(G.obedit==base->object) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
if(base==BASACT) {
G.f &= ~(G_VERTEXPAINT+G_FACESELECT+G_TEXTUREPAINT+G_WEIGHTPAINT);
return;
}
- if (G.obedit) exit_editmode(1);
+ if (G.obedit) exit_editmode(EM_FREEDATA|EM_WAITCURSOR);
G.f &= ~(G_VERTEXPAINT | G_FACESELECT | G_TEXTUREPAINT | G_WEIGHTPAINT);
}
else if(G.vd) {
/* also when Alt-E */
if(G.obedit==NULL) {
- enter_editmode();
+ enter_editmode(EM_WAITCURSOR);
if(G.obedit) BIF_undo_push("Original"); // here, because all over code enter_editmode is abused
}
else
- exit_editmode(2); // freedata, and undo
+ exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); // freedata, and undo
}
return 0;
}
}
else if(G.qual==LR_SHIFTKEY) { // ??
if(G.obedit)
- exit_editmode(2); // freedata, and undo
+ exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); // freedata, and undo
if(G.f & G_FACESELECT)
set_faceselect();
if(G.f & G_VERTEXPAINT)
if(G.qual==LR_ALTKEY) {
if(G.vd && textspace==0) {
if(G.obedit==0) {
- enter_editmode();
+ enter_editmode(EM_WAITCURSOR);
BIF_undo_push("Original");
}
else
- exit_editmode(2); // freedata, and undo
+ exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); // freedata, and undo
return 0;
}
}
if(vnode->type != V_NT_OBJECT) return;
if(G.obedit && G.obedit->vnode == (void*)vnode)
- exit_editmode(2);
+ exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
/* create mesh data */
while(vlink){