Skip to content

Conversation

DonLakeFlyer
Copy link
Contributor

This is a replacement for #11990. I was crazy hard to get my head around all the back and forth of status text between vehicle and StatusTextHandler. So I created the most minimal set of changes I could come up with to fix the problem. I tested it and it works as far as I can tell.

The basic idea is that status text which flows through the system should not be html escaped until the very last place when it needs to be output to a rich text control. This is critical vehicle error popups and the message indicator dropdown. Status text which flows from Vehicle should raw for people connecting to that signaling.

@stepan14511 Can you test as well.

void StatusTextHandler::handleTextMessage(MAV_COMPONENT compId, MAV_SEVERITY severity, const QString &text, const QString &description)
{
QString htmlText(text);
QString htmlText(text.toHtmlEscaped());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with escaping here is that it will be escaped twice in case of the events code path from https://github.com/mavlink/qgroundcontrol/blob/master/src/Vehicle/Vehicle.cc#L1230

That's why I originally did it outside, but did not consider that calibration was affected.
The simplest would be to add a flag as argument to indicate if it's escaped already. But I do agree, would be good to simplify this and avoid the back and forth.

Copy link
Contributor Author

@DonLakeFlyer DonLakeFlyer Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding from code inspection are these path(s):

  • StatusTextHandler::mavlinkMessageReceived is the only thing which sucks up status text messages from mavlink
    • It eventually emits StatusTextHandler::textMessageReceived
    • Only connection I can find to this is on Vehicle
  • Vehicle catches StatusTextHandler::textMessageReceived and calls Vehicle::_textMessageReceived which...
    • Emits Vehicle::textMessageReceived
      • This is unescaped status text
      • This is the signal other parts of QGC like Calibration connects to
    • Calls StatusTextHandler::handleTextMessage which...
      • emits newErrorMessage which is escaped text
      • Stuffs escaped text into the message list
  • Events come in through Vehicle::_handleEvent - not sure how that gets called. Which then...
    • Also calls StatusTextHandler::handleTextMessage

I don't see how you end up going through StatusTextHandler::handleTextMessage twice. I also don't see how to test this since I don't know how to generate an event.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Escaping for the events is done here:

return QString::fromStdString(str).toHtmlEscaped().toStdString(); };
.
This is because they can contain URL's which should not be escaped.

If you connect to PX4 SITL and do a takeoff you should get some events.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok. I get it now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bkueng I think I have this correct now. Can you take a look again?

  • Status text coming in from events is known to already be escaped
  • Regular textMessageReceived signal is not escaped
  • StatusTextHandler::handleTextMessage -> StatusTextHandler::handleHTMLEscapedText name change which assumes escaped text on the way in
  • Raw status text from vehicle is escaped before call to StatusTextHandler::handleHTMLEscapedText

I haven't had time to test yet. Take me a bit to get a SITL setup to work again on OSX arm.

@stepan14511
Copy link

For me it works the same good, as in the #11990. Tested all the ways I know and use the QGC, nothing broke.

But, for the history, I will remind you that we decided to fix the signals the other way.

Regular status text messages should move around system un-formatted

Add missing textMessageReceived signaling
Copy link
Member

@bkueng bkueng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this looks correct

@DonLakeFlyer DonLakeFlyer merged commit 4165a0d into master Oct 17, 2024
7 checks passed
@DonLakeFlyer DonLakeFlyer deleted the StatusText branch October 17, 2024 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants