Skip to content
  • Pablo Rauzy's avatar
    Warn user if kateproject file's JSON is malformed and failed to parse [proper] · 358cf5a3
    Pablo Rauzy authored and Christoph Cullmann's avatar Christoph Cullmann committed
    Hello :),
    
    Kate was silently failing when my `.kateproject` file contained malformed JSON and it took me a lot of time to figure out this was the problem.
    
    Here I propose a simple way to fix that: show a warning dialog telling the user when it is the case, but only once for each `.kateproject` file's version (I keep a map from project files to their last modification time for that).
    
    However, please note that this is my very first Kate (or KDE) contribution, and that I've never worked with the KDE Frameworks, Qt, or even C++ really (except for small university projects)…
    So please do not hesitate to tell me what I did wrong!
    
    In particular:
    
    - I'm not sure my static variable approach is the right one, but I feel like it would be really a lot more work to use a class member (the `readJSONFile` method is static too);
    - I'm not sure `QMap<QString, QDateTime>` is the best or the most KDE way to store the map;
    - I'm not entirely sure to have respected your naming conventions;
    - maybe the content of the error message could be improved.
    
    While I'm here: it was a bit of a mess to get Kate master branch to compile on my Debian stable system, but I must say that I'm quite impressed with KDE's tooling (kdesrc-build is quite impressive).
    
    <details><summary>Details about that</summary>
    Here are the Debian packages I needed to install to be able to compile Kate + all 75 KDE packages it depends on when following the instructions from the [Built It](https://kate-editor.org/build-it/) page from Kate's website:
     
    qtdeclarative5-dev qtbase5-private-dev qttools5-dev libpolkit-gobject-1-dev libpolkit-agent-1-dev libqt5x11extras5-dev libqt5waylandclient5-dev libwayland-dev libqt5svg5-dev libqca-qt5-2-dev libxcb-res0-dev libxcb-keysyms1-dev ibgcrypt20-dev libboost-dev libxss-dev libqt5scripttools5 wayland-protocols libattr1-dev qtquickcontrols2-5-dev qtscript5-dev
     
    I also had to install all these, but some of them may very well be useless, I just didn't want to try them one by one, and the error message in the log was only about XCB without any more details (and libxcb1-dev was already installed…):
     
    libxcb-event1-dev libxcb-dri2-0-dev libxcb-util-dev libxcb-shm0-dev libxcb-shape0-dev libxcb-render-util0-dev libxcb-xvmc0-dev libxcb-ewmh-dev libxcb-render0-dev libxcb-cursor-dev libxcb-randr0-dev libxcb-xinput-dev libxcb-dpms0-dev libxcb-record0-dev libxcb-xtest0-dev libxcb-icccm1-dev libxcb-reply1-dev libxcb-property1-dev libxcb-screensaver0-dev libxcb-icccm4-dev libxcb-aux0-dev libxcb-util0-dev libxcb-glx0-dev libxcb-xrm-dev libxcb-atom1-dev libxcb-sync-dev
    
    Once curated, maybe this package list should be added in some form or another to the Build It page?
    </details>
    
    Anyway, I *really* love KDE and Kate in particular, and it was itching me for a long time to contribute something. I'm not sure this merge request will be accepted, but at least I have everything set up now :).
    358cf5a3