Wireshark-dev: [Wireshark-dev] Issues with extcap arguments type radio

From: Jaap Keuter <jaap.keuter@xxxxxxxxx>
Date: Sat, 6 Aug 2022 11:55:35 +0200

Hi,

While debugging an extcap program using radio buttons I found that these always fall back to the default setting defined, rather than the selection being saved. While looking for examples there seem to be no other extcaps that use radio buttons, so there might be lingering issues there.

What I observed was that the selected value never makes it into the preferences file, the next one does.

While looking into that I found this function in extcap_argument.cpp, which I think makes a small mistake.

QString ExtArgRadio::value()
{
    int idx = 0;
    if (selectorGroup == 0 || callStrings == 0)
        return QString();

    idx = selectorGroup->checkedId();
    if (idx > -1 && callStrings->length() > idx)
        return callStrings->takeAt(idx);

    return QString();
}

It uses QList::takeAt() to retrieve the value. But according to the documentation it does:

     T t = at(i);
     remove(i);
     return t;

So it in fact removes the value from the list.

I think that call should be:

        return callStrings->at(idx);

--> Can someone confirm this, or point out that the value is indeed to be removed from the list?

With this change at least the selection appears to be properly saved in the preferences file.

What still lacks is restoring that saved setting in the dialog when it's reopened again. Let's see where that takes me.

Thanks,
Jaap