I am working on registry input/export for Qt Creator Portable, and I need a way to clear empty section from an INI file.
Qt Creator does something that seems odd to me with the registry. Instead of having a registry key that contains the path to a directory of file, it recreates the file structure in the registry. So one of the registry entries would be:
HKEY_CURRENT_USER Software Trolltech OrganizationDefaults Qt Factory Cache 4.5 com.trolltech.Qt.QIconEngineFactoryInterface: C: Qt 2009.03 bin iconengines]
The only section that has anything in it is the last one, iconengines. So, when I export the registry, there are eight empty sections (from Trolltech to bin). To point to the portable installation, I replace C: with $APPDIR\App (D:\PortableApps\QtCreatorPortable\Apps in my case). I can manually delete the empty sections and do a search and replace for the import and everything gets created fine, but when I do the export, I have the empty sections again. If I do a simple search and replace on export, I am left with orphaned sections. Those orphaned sections quickly add up depending on how deep in the directory structure QtCreatorPortable is installed.
I've done some Googleing, and I've found some code to get the section names and get all entries in a section, but I don't know NSIS well enough to be able to put the two together (I can't figure out how to pass the reg file to the second function call).
If you know how to combine the two codes, or know a better way to do it, let me know. Any help would be greatly appreciated.
Thanks,
Andy
I think that's just the usual Qt-apps registry mess. I think there is no need to export/import that stuff, just clean it up.
Most Qt-apps launchers deal with that. Look for examples at Lightscreen, ConvertAll, FreeMat, MuseScore...
I hope that isn't just a useless mess. I haven't been able to get Qt Creator to work portably because it can't find the installation of Qt. I was hoping that taking care of this registry would fix it. I was hoping to clear this bit on before I started testing, but I guess I need to test to make sure this does the trick.
Thanks for the other Qt apps to look at. I'll see what they do.
Thank you,
Andy
I checked up on all this with Qt Creator, calibre, KDE, KVIrc and a few other things; in all cases that I've tested it on, you can safely delete it all, it'll just create it again when you start it next. All it is is version numbers for the DLLs. Don't know why it creates them at all.
I think that I'll add in some sort of code to the PortableApps.com Launcher (test of John's increment due out presently) to clear up these sorts of Qt entries. They do follow a set standard which is convenient.
Here's the NSIS code that should get you through (needs LogicLib.nsh, Registry.nsh and FileFunc.nsh included). I'll implement the same idea for the PortableApps.com Launcher so that you can have a [Qt] section for such values -
QtRegistryDLLsClean1=Qt Factory Cache 4.5\com.trolltech.Qt...
. Actually thinking over it I think I'll try rewrite it to spider the whole thing and clean up any values. Ah, when you learn to understand some of these things (e.g. Java, Qt) you can actually make it pretty easy to make all such apps easy to do, rather than needing to solve it individually each time.P.S. if you were really needing a way to clear empty sections in an INI file I could whip up such a function fairly easily.
I am a Christian and a developer and moderator here.
“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1
but each Qt version uses a different branch. For example "Qt Factory Cache 4.3", "Qt Factory Cache 4.4" or "Qt Factory Cache 4.5". It's really Qt mess
I've found one Qt key which stores settings. The custom Colors are stored here:
It's the reason for the known issues of ConvertAll, FreeMat, MuseScore, ....
I mentioned that at the end - I think I can overcome it without too much more code - it's just hunting through the tree for the right value until they're all gone.
As for the real settings, that's where something else will need to be done. I'm still not decided on what's best to do about it. I think current solutions are about as good as we can get.
I am a Christian and a developer and moderator here.
“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1
Thanks for the great Qt clean up code. With this, I don't think that I will need the seperate code to clean up INI files. It interesting that this is standard code, but I'm pretty sure these missing registry entries are why Qt Creator Portable isn't working. I'm going to test it soon to see what happens. If this is what is breaking things, I can always restore the stripped INI, then use your code to clean them up when I'm done. Just need to makes sure that I update for new versions of Qt.
Thanks
Chris, you need an additional loop to remove the following branches too:
"HKCU\Software\Trolltech\OrganizationDefaults\$1\"
Otherwise "HKCU\Software\Trolltech\..." will be left behind
You're wrong
Note that it continues until $2 is empty. The last time through,
HKCU\Software\Trolltech\OrganizationDefaults\$1\
will be deleted.The only thing which could really be improved is deleting the Trolltech key if it's empty at the very end...
I am a Christian and a developer and moderator here.
“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1
"HKCU\Software\Trolltech\OrganizationDefaults\$1\" will be deleted.
But if $1="Qt Factory Cache 4.5\com.trolltech.Qt.QAccessibleFactoryInterface:",
"HKCU\Software\Trolltech\OrganizationDefaults\Qt Factory Cache 4.5\" will be left behind. Same for other $1 cases
You win this round
You really should have made it clearer what you meant... what you said, it already had, it's just you meant more than you said.
What I intend to do for the official generic launcher will cope with all those sorts of things.
I am a Christian and a developer and moderator here.
“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1
8)