Darren Salt wrote: > I demand that Klaus Schmidinger may or may not have written... > > >>Darren Salt wrote: >> >>>I demand that Dr. Werner Fink may or may not have written... >>> >>>>On Mon, Apr 10, 2006 at 02:50:35AM +0100, Darren Salt wrote: > > [snip] > >>>>>Full patch attached. On enabling the "set time from broadcast" function, >>>>>default to the first available channel. >>>> >>>>Hmmm... strdup() can return NULL if the system is low at or out of >>>>memory. >>> >>>True, but that probably doesn't matter here: something's going to fail >>>anyway if that happens. Perhaps a wrapper is needed? > > >>Memory is allocated and freed throughout the program all the time. I don't >>see how it could reasonably be made to cope with running out of memory. > > > </AOL>, though that's not the reason for the wrapper: Sorry, from Werner's remark "strdup() can return NULL if the system is low at or out of memory" I (apparently wrongfully) assumed that your answer was going in that direction. > char *my_strdup (const char *str) > { > return str ? strdup (str) : NULL; > } > > would do very nicely. > > >>Back to the original problem. >>I prefer this fix: > > >>--- menuitems.c 2006/04/09 13:10:02 1.36 >>+++ menuitems.c 2006/04/10 06:31:02 >>@@ -572,7 +572,7 @@ >> snprintf(buf, sizeof(buf), "%d %s", *value, channel ? channel->Name() : ""); >> SetValue(buf); >> } >>- else >>+ else if (noneString) >> SetValue(noneString); >> } > > > That still leaves no selected multiplex when "set time from broadcast" is > initially enabled (i.e. TimeSource = 0, TimeTransponder = 0) - and your > preferred fix will cause cMenuEditChanItem::Set() to do nothing. Is this > intended? If not, then you should consider the second part of my patch. Well, the actual fix for the initial problem was the mising check for noneString != NULL. With the new "NoneString" parameter of cMenuEditChanItem we could do cMenuEditTranItem::cMenuEditTranItem(const char *Name, int *Value, int *Source) :cMenuEditChanItem(Name, &number, "-") so that there is actually a visible indication that no transponder for setting the time has been selected , yet. Automatically setting the transponder to the first available one is IMHO not a good idea - I prefer to have the user explicitly select his/her poison ;-). > BTW, what should happen to that setting when all entries for the channels in > that multiplex are deleted? Well, in that case the system time will no longer be set, because ISTRANSPONDER(Transponder(), Setup.TimeTransponder) will never match. And when the user opens the setup menu, the "Use time from transponder" entry will be empty (or "-" with the above change). Klaus