Bugfix [#32492] - Part 3: Error filter now includes drivers where there are
authorJoshua Leung <aligorith@gmail.com>
Wed, 6 Mar 2013 01:59:09 +0000 (01:59 +0000)
committerJoshua Leung <aligorith@gmail.com>
Wed, 6 Mar 2013 01:59:09 +0000 (01:59 +0000)
errors with the variables/targets, even if those errors are for variables which
aren't used (and are hence "harmless" errors)

This means that the filter can be truly useful for helping locate things that
need "cleaning up". For example, previously, there could still have been drivers
where there were some of these "harmless" errors would emit warnings, but would
otherwise appear perfectly functional.

The implementation here uses a slightly slower method of checking any errors in
these driver vars. However, it's no slower than what's done when these are
evaluated, and should be less error prone than introducing yet another type of
error tagging for this one case. The problem here is that the "driver invalid"
flag, which is usually set when a target has errors, gets cleared by the
pydrivers code if nothing went wrong when evaluating the expression. Removing
this clearing step will probably open a can of worms, so unless this method
proves to be far too slow, this simpler fix will do.

source/blender/editors/animation/anim_filter.c

index ec6172d..e1ac5fa 100644 (file)
@@ -983,22 +983,39 @@ static short skip_fcurve_with_name(bDopeSheet *ads, FCurve *fcu, ID *owner_id)
 /* Check if F-Curve has errors and/or is disabled 
  * > returns: (bool) True if F-Curve has errors/is disabled
  */
-static short fcurve_has_errors(FCurve *fcu)
+static bool fcurve_has_errors(FCurve *fcu)
 {
        /* F-Curve disabled - path eval error */
        if (fcu->flag & FCURVE_DISABLED) {
-               return 1;
+               return true;
        }
        
        /* driver? */
        if (fcu->driver) {
-               /* for now, just check if the entire thing got disabled... */
-               if (fcu->driver->flag & DRIVER_FLAG_INVALID)
-                       return 1;
+               ChannelDriver *driver = fcu->driver;
+               DriverVar *dvar;
+               
+               /* error flag on driver usually means that there is an error
+                * BUT this may not hold with PyDrivers as this flag gets cleared
+                *     if no critical errors prevent the driver from working...
+                */
+               if (driver->flag & DRIVER_FLAG_INVALID)
+                       return true;
+                       
+               /* check variables for other things that need linting... */
+               // TODO: maybe it would be more efficient just to have a quick flag for this?
+               for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
+                       DRIVER_TARGETS_USED_LOOPER(dvar)
+                       {
+                               if (dtar->flag & DTAR_FLAG_INVALID)
+                                       return true;
+                       }
+                       DRIVER_TARGETS_LOOPER_END
+               }
        }
        
        /* no errors found */
-       return 0;
+       return false;
 }
 
 /* find the next F-Curve that is usable for inclusion */
@@ -1042,7 +1059,7 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, bActionGro
                                                /* error-based filtering... */
                                                if ((ads) && (ads->filterflag & ADS_FILTER_ONLY_ERRORS)) {
                                                        /* skip if no errors... */
-                                                       if (fcurve_has_errors(fcu) == 0)
+                                                       if (fcurve_has_errors(fcu) == false)
                                                                continue;
                                                }