Search code examples
qtautomated-refactoring

Is there a easy way to protect, or revert Qt source code?


I just accidentally refactored QList to QSet, and Qt faithfully did it, to all of its own sources too... (yup, that was dumb!)

Thankfully my code is source controlled, I just reverted everything, would it be feasible/sensible to make a git repo for the Qt sources too? (I have the free version so I didn't think I could modify them anyway...?)

Is there a hidden setting that will prevent its sources from being modifiable, to stop me from doing this again?

I'm currently using the maintenance tool to install a newer version of Qt, but other than update or add/remove, there wasn't a re-install option that I could see, am I missing something?


Solution

  • Thankfully my code is source controlled, I just reverted everything, would it be feasible/sensible to make a git repo for the Qt sources too? (I have the free version so I didn't think I could modify them anyway...?)

    Feasible? Definitely. Sensible? Perhaps, assuming that by "make a git repo" you mean "cloning the official Qt repos from Git". It depends on how many times you plan on making the same renaming mistake. :D But seriously, I think there are benefits to building Qt yourself:

    • You can easily debug and check the implementation of API that you're using.
    • You can configure Qt to skip building stuff that you're not interested in.
    • You can easily patch Qt if there's a bug that you know of a fix for but hasn't been merged into Qt itself yet.

    There are downsides too, though. You might run into build issues if you're using configure flags that the CI doesn't use (such as a -no-foo option). It can take a while to build depending on how many submodules you have and what kind of machine you're building on.

    In general, if you're not using API that's in dev and not yet released, it's probably not worth bothering.

    If you're still interested, this page has instructions for building Qt from Git:

    https://wiki.qt.io/Building_Qt_5_from_Git

    Is there a hidden setting that will prevent its sources from being modifiable, to stop me from doing this again?

    Couldn't you set some permissions on the source directory? I've never had to do this, but have been bitten by it on unrelated occasions before, so I know it works. :D

    I'm currently using the maintenance tool to install a newer version of Qt, but other than update or add/remove, there wasn't a re-install option that I could see, am I missing something?

    Remove and add is your only option, I think. Otherwise, you can always keep a backup of the source by just copying the whole directory.