![]() |
|
SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
![]() |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
Attributes/Themes evaluated regardless of conditionals?
I am seeing some behavior which I can't quit figure out but seems that attributes and themes are evaluated regardless of the conditional to reach them? Is that correct?
For example: if( Evaluates_To_True ) true Do Something else attribute=Blah Even if, the if clause evaluates to true, my attribute is being set. In my specific scenario this is inside a table, and the the attribute set to the result of a method call. The method call is now failing because an unexpected object is being passed in as the result of the conditional being ignored. Has anyone seen this?
__________________
Host: ESXi 6.5 w/ Intel Core i7 2.8GHZ 8GB Ram Guest: Ubuntu 16.04 with Sage v9 in Docker Tuners: 2 HDHR (OTA); Extenders: HD300 connected to a Samsung 56" DLP HDTV; HD300 connected to a Sharp 42" LCD Storage: OmniOS w/6 1TB Samsung Spinpoint in a RaidZ2 configuration in a 20 bay SATA hotswap case. |
#2
|
||||
|
||||
Widget evaluation is a multipass process. The first pass happens when the menu is loaded, and instantiates every widget in every branch, including all of their widget properties. In the case of Attribute widget values, or any widget property with a dynamic value (i.e. one set to =expression), those expressions are evaluated as part of the widget instantiation. Conditional evaluation kicks in only during the actual rendering pass (for blue UI widgets) or action pass (for green process chains).
Bottom line is that you have to be prepared for your property expressions to be evaluated regardless of any conditionals guarding them.
__________________
-- Greg |
#3
|
|||
|
|||
Quote:
__________________
Host: ESXi 6.5 w/ Intel Core i7 2.8GHZ 8GB Ram Guest: Ubuntu 16.04 with Sage v9 in Docker Tuners: 2 HDHR (OTA); Extenders: HD300 connected to a Samsung 56" DLP HDTV; HD300 connected to a Sharp 42" LCD Storage: OmniOS w/6 1TB Samsung Spinpoint in a RaidZ2 configuration in a 20 bay SATA hotswap case. |
#4
|
||||
|
||||
One trick I sometimes use is to replace a property value with an expression like this:
Code:
=If(true, value, DebugLog("message")) (If you're not familiar with the console window, it's a real-time display of the debug log in a DOS window; see p. 230 of the V7 manual. I highly recommend enabling it for any Studio or Java plugin work.)
__________________
-- Greg |
#5
|
|||
|
|||
Will inner expressions of conditionals inside of a theme widget also be evaluated regardless of the result of the outer condition? My testing says yes, but I can't quite figure out why.
For example, inside my theme widget I have the following for fontcolor: =If(tvbrowser_Episodes_IsEpisode(SeasonEpisode),If(tvbrowser_Episodes_IsRecording(SeasonEpisode), "0xFF0000",gColorBasicWhite),gColorBasicWhite) It seems like that inner If is evaluated inside the theme widget even if the first if is false. Just trying to verify it will go through any widgets evaluate everything, regardless of conditions inside the widgets themselves?
__________________
Host: ESXi 6.5 w/ Intel Core i7 2.8GHZ 8GB Ram Guest: Ubuntu 16.04 with Sage v9 in Docker Tuners: 2 HDHR (OTA); Extenders: HD300 connected to a Samsung 56" DLP HDTV; HD300 connected to a Sharp 42" LCD Storage: OmniOS w/6 1TB Samsung Spinpoint in a RaidZ2 configuration in a 20 bay SATA hotswap case. |
#6
|
|||
|
|||
You could also just adjust your method to handle the first pass or invalid object(which is probably null). I did that will some of my calls and logged it to be sure it was only doing it on first pass.
Another thing before it bites you like it did me beforemenuload loads after the attribute widget pass and such as well. ![]() |
#7
|
||||
|
||||
Bear in mind that there's nothing magic about If(); it's just a normal API call. And like any Java method call, all arguments are evaluated before being passed in to the method (which in this case, just returns one and discards the other). In that sense, If() is not equivalent to Java's ?: operator.
Less obvious is the fact that && and || in widget expressions always evaluate both operands. They do not short-circuit as their Java or C counterparts do.
__________________
-- Greg |
#8
|
||||
|
||||
We should probably put together a list of the common "gotcha's" of studio programming. Probably every one of us has been bitten by the "multipass" behavior as well as the BeforeMenuLoad hook behavior.
Greg - I have a challenge for you ![]()
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#9
|
||||
|
||||
Quote:
For subtle errors of the sort we've been discussing in this thread (such as whether it's safe to evaluate both sides of a conditional) it would take some pretty hard-core program-flow analysis to detect those.
__________________
-- Greg |
#10
|
||||
|
||||
Quote:
![]()
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Modifying attributes on AfterMenuLoad hook | castylx | SageTV Studio | 16 | 02-10-2007 11:22 PM |
Problem with file attributes ? 320x240 ? | nerys | SageTV Software | 1 | 06-27-2005 04:47 AM |