-> Sanity Check for Selection History
authorGeoffrey Bantle <hairbat@yahoo.com>
Thu, 28 Sep 2006 02:37:35 +0000 (02:37 +0000)
committerGeoffrey Bantle <hairbat@yahoo.com>
Thu, 28 Sep 2006 02:37:35 +0000 (02:37 +0000)
Some operations like edge loop deselect would cause selection history
to become invalid. Added a sanity check to countall() to try and catch
these when they happen.

source/blender/include/BIF_editmesh.h
source/blender/src/edit.c
source/blender/src/editmesh_lib.c

index 7c5554de19878854d5851003c1eff2dbb38afbde..fc52405198b89e1a4925242a4a836c52cfb8cc94 100644 (file)
@@ -93,6 +93,7 @@ extern void EM_selectmode_flush(void); // when selection changes
 extern void EM_convertsel(short oldmode, short selectmode);
 extern void EM_remove_selection(void *data, int type);
 extern void EM_store_selection(void *data, int type);
+extern void EM_validate_selections(void);
 
 extern int EM_nfaces_selected(void);
 extern int EM_nvertices_selected(void);
index 914ddffb528dd45bffe4974187a718cfd2cded54..576b9c665d4e147cdc4b3f6fcb33018193254be4 100644 (file)
@@ -612,7 +612,7 @@ void countall()
                                if(efa->f & SELECT) G.totfacesel++;
                        }
                        
-                       /*add code to strip editselections*/
+                       EM_validate_selections();
                }
                else if (G.obedit->type==OB_ARMATURE){
                        for (ebo=G.edbo.first;ebo;ebo=ebo->next){
index 3234ddb758914dd84ed6795ea88d62f79eaf05c8..2f742d8e985820394023ff560a0db183e0b238cb 100644 (file)
@@ -71,7 +71,7 @@ editmesh_lib: generic (no UI, no menus) operations/evaluators for editmesh data
 
 #include "editmesh.h"
 
-/* ********* Selection ************ */
+/* ********* Selection History ************ */
 static int EM_check_selection(void *data)
 {
        EditSelection *ese;
@@ -105,6 +105,20 @@ void EM_store_selection(void *data, int type)
        }
 }
 
+void EM_validate_selections(void)
+{
+       EditSelection *ese, *nextese;
+       EditMesh *em = G.editMesh;
+       ese = em->selected.first;
+       while(ese){
+               nextese = ese->next;
+               if(ese->type == EDITVERT && !(((EditVert*)ese->data)->f & SELECT)) BLI_freelinkN(&(em->selected), ese);
+               else if(ese->type == EDITEDGE && !(((EditEdge*)ese->data)->f & SELECT)) BLI_freelinkN(&(em->selected), ese);
+               else if(ese->type == EDITFACE && !(((EditFace*)ese->data)->f & SELECT)) BLI_freelinkN(&(em->selected), ese);
+               ese = nextese;
+       }
+}
+
 static void EM_strip_selections(void)
 {
        EditSelection *ese, *nextese;