fix: place the guided tour's card from its allocation, and count GTK warnings
The tour measured its card with a height-for-width request whose for_size came from the natural width minus the margins the tour sets for positioning. A measure reports margins *included*, so that for_size landed a margin short of the minimum the box answers with and GTK warned once per frame: Trying to measure GtkBox 0x... for width of N, but it needs at least M (about 9/s for as long as the tour was up). The card now takes its size from gtk_widget_compute_bounds() once a frame has run -- its allocation rectangle, not gtk_widget_get_width(), which is only the content box -- and falls back to a measure with no for_size at all only on a frame with nothing allocated. GTK is built with structured logging, so its messages reach the log writer and never the handler API; no existing probe can read one. The exit dump now counts them (`gtk warnings:`, must read 0) through a writer function chained to g_log_writer_default(), which leaves stderr unchanged.
This commit is contained in:
1 parent
d8a79b96ba
commit
bb62b8178c
5 files changed
+94
-12
No files matched your search
+30
@@ -5646,9 +5646,35 @@ void collect_spins(GtkWidget* w, std::vector<double>* out) {
|
||||
/// dialogs built and destroyed in one run.
|
||||
|
||||
|
||||
/// GTK writes its own log messages -- `Trying to measure GtkBox \u2026 for width of N, but it needs at
|
||||
/// least M` is one -- from inside a call of ours, so they reach stderr and never a widget: no probe
|
||||
/// can read one, and the class is otherwise invisible to the self-check. The exit dump therefore
|
||||
/// carries a count of them, which is the one reading that can assert the class away (`gtk warnings:
|
||||
/// 0`). GTK is built with structured logging, so its messages go through the log *writer* and not
|
||||
/// through the handler API (`g_log_set_handler()` never sees them); the writer is chained to rather
|
||||
/// than replaced, so every message still reaches stderr exactly as before and the documented
|
||||
/// baselines are read the same way they always were.
|
||||
int g_gtk_warning_count = 0;
|
||||
GLogWriterOutput count_gtk_log(GLogLevelFlags level, const GLogField* fields, gsize n_fields,
|
||||
gpointer user_data) {
|
||||
for (gsize i = 0; i < n_fields; ++i) {
|
||||
if (g_strcmp0(fields[i].key, "GLIB_DOMAIN") != 0) continue;
|
||||
if (g_strcmp0(static_cast<const char*>(fields[i].value), "Gtk") == 0 &&
|
||||
(level & (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR)) != 0) {
|
||||
++g_gtk_warning_count;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return g_log_writer_default(level, fields, n_fields, user_data);
|
||||
}
|
||||
|
||||
int run_ui(int argc, char** argv, const Config& cfg, ScopeModel& model, Acquisition& acq,
|
||||
RowSet& rows) {
|
||||
(void)argc;
|
||||
// Count GTK's own log messages for the run (see `count_gtk_log`). Installed before anything can
|
||||
// log -- and it must be: a log writer function may only be installed once, and GTK does not install
|
||||
// one, so this is the whole of the run's logging rather than a replacement.
|
||||
g_log_set_writer_func(count_gtk_log, nullptr, nullptr);
|
||||
// Installs libadwaita's stylesheet, which the shortcut overview's `AdwShortcutsDialog`
|
||||
// needs to be drawn at all. Idempotent, and `choose_source()` may already have run it.
|
||||
adw_init();
|
||||
@@ -6040,6 +6066,10 @@ int run_ui(int argc, char** argv, const Config& cfg, ScopeModel& model, Acquisit
|
||||
// guided tour stood when the last capture ran. Both are captured on the tick (`capture_help_state`),
|
||||
// so neither asks a destroyed widget anything.
|
||||
std::printf("[udpscope] help layer: %s\n", app.dbg_context_help.c_str());
|
||||
// GTK's own log at warning or above, counted for the whole run (see `count_gtk_log`). A probe
|
||||
// cannot read one of these -- they are written by the toolkit, not stored in a widget -- so this
|
||||
// count is the reading that catches the class, and the run must print `0`.
|
||||
std::printf("[udpscope] gtk warnings: %d\n", g_gtk_warning_count);
|
||||
// The bounds the help's annotated figures draw their crop boxes from: window coordinates, or
|
||||
// -1,-1,0,0 for a widget that is not on screen (`is_visible()`, not `get_visible()` -- a widget
|
||||
// under a hidden parent keeps its own flag true). Measured on the tick, after a frame.
|
||||
|
||||
Reference in new issue
Block a user