"Arming denied: switch to manual mode first"

I’m starting the drone in takeoff mode, QGC shows that it’s ready to arm, I switch the arming switch, and arming is denied with error message “Arming denied: switch to manual mode first”.
What can be the problem?

Or is it impossible to arm while in takeoff mode?

You have to switch to manual mode first, e.g. Manual, Altitude control, or position control. Otherwise you can’t arm using the switch.

Here is the conditional line that does this btw

in Commander.cpp