Confusions in AudioPluginHost

Starting at line 1190 of GraphEditorPanel.cpp (https://github.com/juce-framework/JUCE/blob/master/extras/AudioPluginHost/Source/UI/GraphEditorPanel.cpp#L1190), there is the code shown below:

if (isOnTouchDevice())
{
    if (isOnTouchDevice())
    {
        titleBarComponent.reset (new TitleBarComponent (*this));
        addAndMakeVisible (titleBarComponent.get());
    }

    pluginListBoxModel.reset (new PluginListBoxModel (pluginListBox, pluginList));

    pluginListBox.setModel (pluginListBoxModel.get());
    pluginListBox.setRowHeight (40);

    pluginListSidePanel.setContent (&pluginListBox, false);

    mobileSettingsSidePanel.setContent (new AudioDeviceSelectorComponent (deviceManager,
                                                                          0, 2, 0, 2,
                                                                          true, true, true, false));

    if (isOnTouchDevice())
    {
        addAndMakeVisible (pluginListSidePanel);
        addAndMakeVisible (mobileSettingsSidePanel);
    }
}

My question is, is the second and third “inOnTouchDevice” judgment in this code necessary?
Continue to analyze in depth, the implementation of “isOnTouchDevice” is in line 152 of HostStartup.cpp (https://github.com/juce-framework/JUCE/blob/master/extras/AudioPluginHost/Source/HostStartup.cpp#L152):

bool isOnTouchDevice() { return Desktop::getInstance().getMainMouseSource().isTouch(); }

The list of mouse sources is constructed by the code “mouseSources (new MouseInputSource::SourceList())” when creating an instance of Desktop.
Then the constructor of MouseInputSource::SourceList is just as follows:

SourceList()
{
   #if JUCE_ANDROID || JUCE_IOS
    auto mainMouseInputType = MouseInputSource::InputSourceType::touch;
   #else
    auto mainMouseInputType = MouseInputSource::InputSourceType::mouse;
   #endif

    addSource (0, mainMouseInputType);
}

So it seems that the main mouse source is always a mouse on the desktop platform and always a touch on the mobile platform.
So back to the original question, is the second and third judgment of “isOnTouchDevice” necessary? Or are there other conditions that may cause the main mouse source to be changed at runtime?

I would go with the simplest answer and guess the developer who did that code in the AudioPluginHost, simply made a mistake. (Even the Juce developers are not infallible.)

I found this code was added by @ed95 in this commit: https://github.com/juce-framework/JUCE/commit/5527cd8ca1a7b83078404d1abe0303733e0e5a72#diff-ed16ad623dd8283ad34092a0e8c18278
@ed95 , can you explain the reason here?

I wish I could tell you that there is some highly complex, nuanced reason for those checks to be there but no, it is just a silly mistake. I’ll get that cleaned up, thanks for the heads up!