moonlight-stream/moonlight-qt

Is there a bug with getToggleOptionValue implementation?

Closed this issue · 1 comments

Hi,

I encountered an issue when using command-line parameters.

for example, when I run:
moonlight stream 192.168.1.15 "Desktop" --no-hdr
the --no-hdr option does not seem to have any effect.

After inspecting the code, I believe the problem lies in the implementation of getToggleOptionValue:

    bool getToggleOptionValue(QString name, bool defaultValue) const
    {
        static QRegularExpression re(QString("^(%1|no-%1)$").arg(name));
        QStringList options = optionNames().filter(re);
        if (options.isEmpty()) {
            return defaultValue;
        } else {
            return options.last() == name;
        }
    }

The issue appears to be that re is potentially a static variable elsewhere, which causes it to always hold the value from the first call, such as:

QRegularExpression re("^(vsync|no-vsync)$");
This prevents re from updating dynamically based on the current name parameter, leading to the --no-hdr option not functioning correctly.

Is this a bug?

Thanks!

Yep you are exactly right. Fixed in 9cb4105