mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-13 10:04:13 +02:00
TitleBlockTemplate::minimumWidth() divided by (100.0 - sum(RelativeToTotalLength)) without guarding against a zero or negative denominator. When a template's relative-to-total-length
columns summed to exactly 100% (e.g. the shipped A4_1.titleblock), this produced qRound(NaN), which fatally aborted under Qt6's stricter qCheckedFPConversionToInteger assertion -- reached via double-clicking a title block template to edit it. Introduce TitleBlockTemplate::classifyWidthConstraint(), shared by minimumWidth() and maximumWidth(), returning std::optional WidthConstraintCase> to distinguish three non-finite outcomes: Unconstrained (RTT columns == 100%, no absolute columns -- an ordinary, valid template), RelativeWidthExceeds100Percent (RTT alone exceeds 100%), and AbsoluteColumnsExceedRemainingWidth (RTT == 100% with at least one absolute column also present) -- the latter two meaning the template's columns cannot be laid out at any width. maximumWidth() previously only checked "are all columns absolute", which incorrectly reported "no upper bound" for the two unsatisfiable cases above; it now shares the same classification, so both functions agree. Update TitleBlockTemplateView::updateDisplayedMinMaxWidth() to show distinct, accurate tooltip text for all four cases instead of printing the old std::numeric_limits<int>::max() sentinel or a misleading "no constraint" message for an unsatisfiable template. Manually verified all four cases: a normal template (finite width), A4_1.titleblock (Unconstrained), an over-100% RTT template (RelativeWidthExceeds100Percent), and RTT==100% with an absolute column present (AbsoluteColumnsExceedRemainingWidth). Translations still partially missing.
This commit is contained in:
@@ -999,34 +999,47 @@ void TitleBlockTemplateView::updateDisplayedMinMaxWidth()
|
||||
int max_width = tbtemplate_ -> maximumWidth();
|
||||
|
||||
QString min_max_width_sentence;
|
||||
if (min_width != -1 && max_width != -1) {
|
||||
min_max_width_sentence = QString(
|
||||
tr(
|
||||
"Longueur minimale : %1px\nLongueur maximale : %2px\n",
|
||||
"tooltip showing the minimum and/or maximum width of the edited template"
|
||||
)
|
||||
).arg(min_width).arg(max_width);
|
||||
} else if (min_width != -1) {
|
||||
min_max_width_sentence = QString(
|
||||
tr(
|
||||
"Longueur minimale : %1px\n",
|
||||
"tooltip showing the minimum width of the edited template"
|
||||
)
|
||||
).arg(min_width);
|
||||
} else if (max_width != -1) {
|
||||
min_max_width_sentence = QString(
|
||||
tr(
|
||||
"Longueur maximale : %1px\n",
|
||||
"tooltip showing the maximum width of the edited template"
|
||||
)
|
||||
).arg(max_width);
|
||||
} else {
|
||||
min_max_width_sentence = QString(
|
||||
tr(
|
||||
"Longueur non contrainte.\n",
|
||||
"tooltip shown when the edited template has neither a minimum nor a maximum width constraint"
|
||||
)
|
||||
);
|
||||
|
||||
switch (static_cast<TitleBlockTemplate::WidthConstraintCase>(min_width)) {
|
||||
case TitleBlockTemplate::WidthConstraintCase::RelativeWidthExceeds100Percent:
|
||||
// minimumWidth() and maximumWidth() both check infeasibility
|
||||
// first, identically, so max_width reports the same case
|
||||
// here -- no need to check it separately.
|
||||
min_max_width_sentence = tr(
|
||||
"Attention : la somme des largeurs relatives dépasse 100%% de la largeur totale, ce modèle de cartouche ne peut être satisfait par aucune largeur.\n",
|
||||
"tooltip warning shown when a template's relative-to-total-length columns alone already exceed 100%% of the total width"
|
||||
);
|
||||
break;
|
||||
case TitleBlockTemplate::WidthConstraintCase::AbsoluteColumnsExceedRemainingWidth:
|
||||
min_max_width_sentence = tr(
|
||||
"Attention : les colonnes de largeur fixe ne peuvent pas tenir dans la largeur restante, ce modèle de cartouche ne peut être satisfait par aucune largeur.\n",
|
||||
"tooltip warning shown when a template's relative-to-total-length columns already consume all available width, leaving no room for its fixed-width columns"
|
||||
);
|
||||
break;
|
||||
default:
|
||||
if (min_width != static_cast<int>(TitleBlockTemplate::WidthConstraintCase::Unconstrained)) {
|
||||
min_max_width_sentence += QString(
|
||||
tr(
|
||||
"Longueur minimale : %1px\n",
|
||||
"tooltip showing the minimum width of the edited template"
|
||||
)
|
||||
).arg(min_width);
|
||||
}
|
||||
if (max_width != static_cast<int>(TitleBlockTemplate::WidthConstraintCase::Unconstrained)) {
|
||||
min_max_width_sentence += QString(
|
||||
tr(
|
||||
"Longueur maximale : %1px\n",
|
||||
"tooltip showing the maximum width of the edited template"
|
||||
)
|
||||
).arg(max_width);
|
||||
}
|
||||
if (min_max_width_sentence.isEmpty()) {
|
||||
min_max_width_sentence = tr(
|
||||
"Longueur non contrainte.\n",
|
||||
"tooltip shown when the edited template has neither a minimum nor a maximum width constraint"
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// the tooltip may also display the split label for readability purpose
|
||||
|
||||
Reference in New Issue
Block a user