bugfix
[blender.git] / source / blender / python / api2_2x / Scene.c
index 7ef351b112751349d96ba610ceb716c927829ae2..eba951b88133b434ce0946e226fba18ae65ea9bb 100644 (file)
@@ -1355,16 +1355,29 @@ static PyObject *SceneObSeq_item( BPy_SceneObSeq * self, int i )
                for (base= scene->base.first; base && i!=index; base= base->next, index++) {}
        /* selected */
        else if (self->mode==EXPP_OBSEQ_SELECTED) {
-               for (base= scene->base.first; base && i!=index; base= base->next)
-                       if (base->flag & SELECT)
-                               index++;
+               for (base= scene->base.first; base; base= base->next) {
+                       if (base->flag & SELECT) {
+                               if (i==index) {
+                                       break;
+                               } else {
+                                       index++;
+                               }
+                       }
+               }
        }
        /* context */
        else if (self->mode==EXPP_OBSEQ_CONTEXT) {
-               if (G.vd)
-                       for (base= scene->base.first; base && i!=index; base= base->next)
-                               if TESTBASE(base)
-                                       index++;
+               if (G.vd) {
+                       for (base= scene->base.first; base; base= base->next) {
+                               if (TESTBASE(base)) {
+                                       if (i==index) {
+                                               break;
+                                       } else {
+                                               index++;
+                                       }
+                               }
+                       }
+               }
        }
        
        if (!(base))