mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-19 20:44:16 +02:00
Fix a crash opening a project whose symbol has a terminal with no orientation
A terminal in a symbol's definition saved without its orientation attribute crashed QElectroTech whenever the project was opened, in the GUI and with --resave alike: Qet::orientationFromString() read the first character of an empty string. Hand-edited or generated symbols, or a damaged file, can hold such a terminal. An empty string is now an inconsistency like any other, and the terminal faces north, as the function's comment already said. Every non-empty string gives the same orientation as before. tst_terminalnoorientation runs the real binary's --resave on fixtures/terminal_no_orientation.qet (unlinked_contact_label.qet with one terminal's orientation removed): it crashes without the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XCdg2Er2vYhB8Vwa5G7fSR
This commit is contained in:
+5
-4
@@ -49,10 +49,11 @@
|
||||
@return l'orientation designee par la chaine de caractere
|
||||
*/
|
||||
Qet::Orientation Qet::orientationFromString(const QString &s) {
|
||||
QChar c = s[0];
|
||||
if (c == 'e') return(Qet::East);
|
||||
else if (c == 's') return(Qet::South);
|
||||
else if (c == 'w') return (Qet::West);
|
||||
//An empty string (a terminal saved without its orientation) is
|
||||
//an inconsistency too: s[0] would read past its end and crash
|
||||
if (s.startsWith(QLatin1Char('e'))) return(Qet::East);
|
||||
else if (s.startsWith(QLatin1Char('s'))) return(Qet::South);
|
||||
else if (s.startsWith(QLatin1Char('w'))) return (Qet::West);
|
||||
else return(Qet::North);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user