Confusions in AudioPluginHost

Starting at line 1190 of GraphEditorPanel.cpp (, 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 (

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:

    auto mainMouseInputType = MouseInputSource::InputSourceType::touch;
    auto mainMouseInputType = MouseInputSource::InputSourceType::mouse;

    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:
@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!