This change resolves T5981.
The segfault is fixed by checking whether or not a Game object is valid, before letting the user play with it.
Details
Details
- Reviewers
ltoscano - Group Reviewers
KDE Games - Maniphest Tasks
- T5981: Sudoku: fix segfault when generating a puzzle from improperly loaded game variants
- Commits
- R417:817ad710b3e5: Fix segfault when attempting to generate or enter in an invalid game variant.
Manually added a borked game variant in KSudoku::updateShapesList() using a CustomGameVariant with null QUrl.
Compiled and verified the segfault no longer occurred.
/* * For the purpose of testing the change, a deliberately borked game variant. * TODO: remove in final version of diff. */ variant = new CustomGame(i18n("Invalid TODO Remove me"), QUrl(), m_gameVariants); variant->setDescription(i18n("Invalid TODO Remove me")); variant->setIcon("ksudoku-ksudoku_9x9");
Diff Detail
Diff Detail
- Repository
- R417 KSudoku
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Comment Actions
The real test could be probably a unit test :)
It is true that many others are missing too (there are 0 tests now). If you feel about trying writing one, you are welcome.
In the meantime, the change looks definitely correct.
Comment Actions
Provide feedback to the user when unable to start a puzzle of a particular (invalid) game variant.
Comment Actions
Unfortunately that may not be so easy: the code is part of private slots (which are in turn wired up to buttons that look like they come from a privately inherited base class).
Is it even possible to invoke private slots through the Qt meta object system directly?