KUrl is part of the deprecated kdelibs4support API.
Porting away from it removes one obstacle towards legacy free sudoku for KDE.
Details
- Reviewers
ltoscano stikonas - Group Reviewers
KDE Games - Commits
- R417:45e1f086125d: Port usage of KUrl and friends to equivalent constructs with QUrl.
Using XDG_DATA_DIRS to point to locally built copy of ksudoku game assets, I tested the following:
- Generate a Killer type (i.e. a custom Sudoku variant) puzzle using defaults for difficulty/symmetry
- Reconfigured toolbars to add the Home Page action & invoke the Home Page action
- Save the puzzle/game file & Quit the application
- Reload the application and load the previously saved puzzle.
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.
Shorter command line. Please follow the guidelines for git commits. First line no more than 55/60 characters, followed by a blank line and the rest of the commit message (with more or less 78/80 character limit).
Updating D5544: Summary:
Port usage of KUrl and friends to equivalent constructs with QUrl.
KUrl is part of the deprecated kdelibs4support API.
Porting away from it removes one obstacle towards legacy free sudoku for KDE.
There are few errors; following the chat on IRC, I think you need a development environment:
/mnt/kde/git/kde/kdegames/ksudoku/src/gui/ksudoku.cpp: In member function ‘void KSudoku::updateShapesList()’: /mnt/kde/git/kde/kdegames/ksudoku/src/gui/ksudoku.cpp:220:72: error: no matching function for call to ‘ksudoku::CustomGame::CustomGame(QString&, QString&, ksudoku::GameVariantCollection*&)’ variant = new CustomGame(variantName, variantDataPath, m_gameVariants); ^ In file included from /mnt/kde/git/kde/kdegames/ksudoku/src/gui/ksudoku.cpp:73:0: /mnt/kde/git/kde/kdegames/ksudoku/src/gui/gamevariants.h:170:2: note: candidate: ksudoku::CustomGame::CustomGame(const QString&, const QUrl&, ksudoku::GameVariantCollection*) CustomGame(const QString& name, const QUrl& url, GameVariantCollection* collection=0); ^~~~~~~~~~ /mnt/kde/git/kde/kdegames/ksudoku/src/gui/gamevariants.h:170:2: note: no known conversion for argument 2 from ‘QString’ to ‘const QUrl&’ /mnt/kde/git/kde/kdegames/ksudoku/src/gui/gamevariants.h:168:7: note: candidate: ksudoku::CustomGame::CustomGame(const ksudoku::CustomGame&) class CustomGame : public GameVariant { ^~~~~~~~~~ /mnt/kde/git/kde/kdegames/ksudoku/src/gui/gamevariants.h:168:7: note: candidate expects 1 argument, 3 provided /mnt/kde/git/kde/kdegames/ksudoku/src/gui/gamevariants.h:168:7: note: candidate: ksudoku::CustomGame::CustomGame(ksudoku::CustomGame&&) /mnt/kde/git/kde/kdegames/ksudoku/src/gui/gamevariants.h:168:7: note: candidate expects 1 argument, 3 provided /mnt/kde/git/kde/kdegames/ksudoku/src/gui/ksudoku.cpp: In member function ‘virtual void KSudoku::dragEnterEvent(QDragEnterEvent*)’: /mnt/kde/git/kde/kdegames/ksudoku/src/gui/ksudoku.cpp:631:37: error: request for member ‘hasUrls’ in ‘event->QDragEnterEvent::<anonymous>.QDragMoveEvent::<anonymous>.QDropEvent::mimeData()’, which is of pointer type ‘const QMimeData*’ (maybe you meant to use ‘->’ ?) event->accept(event->mimeData().hasUrls()); ^~~~~~~ /mnt/kde/git/kde/kdegames/ksudoku/src/gui/ksudoku.cpp: In member function ‘virtual void KSudoku::dropEvent(QDropEvent*)’: /mnt/kde/git/kde/kdegames/ksudoku/src/gui/ksudoku.cpp:636:43: error: conversion from ‘const QMimeData*’ to non-scalar type ‘const QMimeData’ requested const QMimeData data = event->mimeData(); ~~~~~~~~~~~~~~~^~
The program crashes when you select a non-standard game (which I guess comes from wrong reading of some URL). Porting to QUrl requires a bit of investigation as the behavior is a bit different.
Please note that they may be other crashes or other unexpected behaviors; a deeper testing which touches all the code which is changed here is needed.
Example of crash:
#6 0x000055e83b8bfcbc in QVector<int>::size() const () #7 0x000055e83b8ce5d0 in ksudoku::Puzzle::hasSolution() const () #8 0x000055e83b8de721 in ksudoku::WelcomeScreen::generatePuzzle() () #9 0x000055e83b8dfae3 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (ksudoku::WelcomeScreen::*)()>::call(void (ksudoku::WelcomeScreen::*)(), ksudoku::WelcomeScreen*, void**) () #10 0x000055e83b8dfa75 in void QtPrivate::FunctionPointer<void (ksudoku::WelcomeScreen::*)()>::call<QtPrivate::List<>, void>(void (ksudoku::WelcomeScreen::*)(), ksudoku::WelcomeScreen*, void**) () #11 0x000055e83b8df981 in QtPrivate::QSlotObject<void (ksudoku::WelcomeScreen::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) () #12 0x00007f89c5ef295e in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 #13 0x00007f89c7559135 in QAbstractItemView::doubleClicked(QModelIndex const&) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 #14 0x00007f89c756686a in QAbstractItemView::mouseDoubleClickEvent(QMouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 [...]
Thanks for the pointer. I'm still now sure why ksudoku would crash because at worst the puzzle should be in some 'invalid' state with bogus contents ... but then the QVector should still return a proper size() without crashing.
Alternatively, possibly more likely, the memory management of the containing Puzzle object itself was already messed up and the change in code merely tickles the bug.
Fix: crash on opening a custom game variant.
KUrl accepts raw file paths, but QUrl doesn't.
Use QUrl::fromLocalFile() to fix the crash.
Also make sure to not do hacky things with raw file paths when Qt supplies perfectly good APIs for that purpose already.
(Note: the entire function should probably be updated to use Qt APIs instead of manual fiddling with file & directory paths.)
src/gui/ksudoku.cpp | ||
---|---|---|
392 | Maybe KRun::RunFlags()) ? |