GDB printers: don't call QUrl::toString() when d is null
A default-constructed QUrl
is invalid, its d
-pointer is null. After
QUrlPrinter
repeatedly dereferences the null pointer, eventually (at the
line of the first QStringPrinter
call on my system) an exception is
raised and QUrl::toString()
is called via gdb.parse_and_eval()
in a
fallback path. The fallback path turns out to be extremely slow:
hovering the mouse pointer over a default-constructed QUrl
variable
while debugging occupies GDB for about 15 seconds on my system.
By contrast, GDB computes the value of a valid QUrl
in about a second.
Returning early when the d
-pointer is null makes printing an invalid
QUrl
about as fast as a valid one.
Without the added early return, "" is displayed in KDevelop's debugging
UI as an invalid QUrl
variable's value, even though valid QUrl
values
are not quoted. When QUrlPrinter
early-returns ""
, an empty space
(not "") is displayed, which is indistinguishable from a not yet
computed value. Returning '""'
would preserve the current "" value in
the UI. But Qt Creator's debugging UI displays <invalid> in this case,
which seems a better fit, so let us follow suit.
CCBUG: 436339