Skip to content

Commit 9fb9fad

Browse files
committed
Fix MythCommandLineParser::SetValue
Previously, this would store the new value to the CommandLineArg instance, but would not mark the instance as having been used. Thus, if the argument had not actually been used on the command line, attempting to retrieve the value would result in getting the default. This requires a version bump, so it also carries staging for a SetDeprecated method to CommandLineArg. Fixes #10083.
1 parent a63fc04 commit 9fb9fad

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

mythtv/libs/libmythbase/mythcommandlineparser.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,19 @@ const char* NamedOptType(int type)
100100
CommandLineArg::CommandLineArg(QString name, QVariant::Type type,
101101
QVariant def, QString help, QString longhelp) :
102102
ReferenceCounter(), m_given(false), m_name(name), m_group(""),
103-
m_type(type), m_default(def), m_help(help), m_longhelp(longhelp)
103+
m_deprecated(""), m_type(type), m_default(def), m_help(help),
104+
m_longhelp(longhelp)
104105
{
105106
}
106107

107108
CommandLineArg::CommandLineArg(QString name, QVariant::Type type, QVariant def)
108109
: ReferenceCounter(), m_given(false), m_name(name), m_group(""),
109-
m_type(type), m_default(def)
110+
m_deprecated(""), m_type(type), m_default(def)
110111
{
111112
}
112113

113114
CommandLineArg::CommandLineArg(QString name) :
114-
ReferenceCounter(), m_given(false), m_name(name),
115+
ReferenceCounter(), m_given(false), m_name(name), m_deprecated(""),
115116
m_type(QVariant::Invalid)
116117
{
117118
}
@@ -446,6 +447,11 @@ CommandLineArg* CommandLineArg::SetBlocks(QStringList opts)
446447
return this;
447448
}
448449

450+
CommandLineArg* CommandLineArg::SetDeprecated(QString depstr)
451+
{
452+
return this;
453+
}
454+
449455
void CommandLineArg::SetParentOf(CommandLineArg *other, bool forward)
450456
{
451457
int i;

mythtv/libs/libmythbase/mythcommandlineparser.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class MBASE_PUBLIC CommandLineArg : public ReferenceCounter
3636

3737
bool Set(QString opt);
3838
bool Set(QString opt, QString val);
39-
void Set(QVariant val) { m_stored = val; }
39+
void Set(QVariant val) { m_stored = val;
40+
m_given = true; }
4041

4142
CommandLineArg* SetParentOf(QString opt);
4243
CommandLineArg* SetParentOf(QStringList opts);
@@ -48,6 +49,7 @@ class MBASE_PUBLIC CommandLineArg : public ReferenceCounter
4849
CommandLineArg* SetRequires(QStringList opts);
4950
CommandLineArg* SetBlocks(QString opt);
5051
CommandLineArg* SetBlocks(QStringList opts);
52+
CommandLineArg* SetDeprecated(QString depstr = "");
5153

5254
static void AllowOneOf(QList<CommandLineArg*> args);
5355

@@ -70,6 +72,7 @@ class MBASE_PUBLIC CommandLineArg : public ReferenceCounter
7072
bool m_given;
7173
QString m_name;
7274
QString m_group;
75+
QString m_deprecated;
7376
QVariant::Type m_type;
7477
QVariant m_default;
7578
QVariant m_stored;

mythtv/libs/libmythbase/mythversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/// Update this whenever the plug-in API changes.
1313
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
1414
/// libmythui class methods used by plug-ins.
15-
#define MYTH_BINARY_VERSION "0.25.20111007-1"
15+
#define MYTH_BINARY_VERSION "0.25.20111009-1"
1616

1717
/** \brief Increment this whenever the MythTV network protocol changes.
1818
*

mythtv/programs/mythfilldatabase/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ int main(int argc, char *argv[])
242242
cmdline.toStringList("refresh") << "nottomorrow");
243243
if (cmdline.toBool("refreshsecond"))
244244
cmdline.SetValue("refresh",
245-
cmdline.toStringList("refresh") << "today");
245+
cmdline.toStringList("refresh") << "second");
246246
if (cmdline.toBool("refreshall"))
247247
cmdline.SetValue("refresh",
248248
cmdline.toStringList("refresh") << "all");
@@ -251,7 +251,7 @@ int main(int argc, char *argv[])
251251
cmdline.toStringList("refresh") <<
252252
QString::number(cmdline.toUInt("refreshday")));
253253

254-
QStringList sl =cmdline.toStringList("refresh");
254+
QStringList sl = cmdline.toStringList("refresh");
255255
if (!sl.isEmpty())
256256
{
257257
QStringList::const_iterator i = sl.constBegin();

0 commit comments

Comments
 (0)