Can't delete my extension's user modified preferences on uninstall Topic is solved

Add-ons for Pale Moon and other applications
General discussion, compatibility, contributed extensions, themes, plugins, and more.

Moderators: FranklinDM, Lootyhoof

User avatar
moonbat
Knows the dark side
Knows the dark side
Posts: 4942
Joined: 2015-12-09, 15:45
Contact:

Can't delete my extension's user modified preferences on uninstall

Unread post by moonbat » 2022-10-28, 09:59

I'm trying to implement a clean uninstall for my extensions using the uninstall observer, and whatever I do, any preference that is modified from the default remains as it is after a restart, and I manually have to reset it in about:config and again restart to totally get rid of it.

Code: Select all

	uninstallObserver :{
		observe : function(aSubject,aTopic,aData){
			if(aTopic == "quit-application" && Common.uninstall == true) {
				Common.rrPrefBranch.clearUserPref("firstrun");
				Services.prefs.setBoolPref("extensions.moonbat.status",true);
				Common.rrPrefBranch.deleteBranch("");
			}
		}
	}
}
The default value of firstrun here, set in my extension's preferences.js, is true.
Whether I do a nsIPrefBranch.clearUserPref (as here) or just setBoolPref to true (the default value), the firstrun variable remains in about:config after uninstalling
and restarting. The same goes for any other preference of the extension that I have. rrPrefBranch here is the nsiPrefBranch starting from my extension under "extensions.extensionname".
I've tried directly deleting the branch using Services.prefs.deleteBranch("extensions.recordrewind.") as well to no effect.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
Linux Mint 21 Xfce x64 on HP i5-5200 laptop, 12 GB RAM.
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

User avatar
Kris_88
Keeps coming back
Keeps coming back
Posts: 933
Joined: 2021-01-26, 11:18

Re: Can't delete my extension's user modified preferences on uninstall

Unread post by Kris_88 » 2022-10-28, 18:59

I think there are two problems:
1) At the time of the "quit-application" callback, all windows are probably already closed and your overlay is removed from memory.
Try to move the critical code to the module.
2) The event "quit-application" can fire when the preferences service is no longer working.
Try "quit-application-granted" instead.

User avatar
moonbat
Knows the dark side
Knows the dark side
Posts: 4942
Joined: 2015-12-09, 15:45
Contact:

Re: Can't delete my extension's user modified preferences on uninstall

Unread post by moonbat » 2022-10-29, 09:51

Already using a module for the observer and quit-application-granted didn't work. Most annoying thing is being unable to figure if the observer was getting called.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
Linux Mint 21 Xfce x64 on HP i5-5200 laptop, 12 GB RAM.
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

User avatar
Kris_88
Keeps coming back
Keeps coming back
Posts: 933
Joined: 2021-01-26, 11:18

Re: Can't delete my extension's user modified preferences on uninstall

Unread post by Kris_88 » 2022-10-29, 11:22

Works fine, even with Service.prompt.alert.
Look for a mistake in your code.
Attachments
example.zip
(2.72 KiB) Downloaded 8 times

User avatar
moonbat
Knows the dark side
Knows the dark side
Posts: 4942
Joined: 2015-12-09, 15:45
Contact:

Re: Can't delete my extension's user modified preferences on uninstall

Unread post by moonbat » 2022-10-29, 12:23

Found the problem..it was in the addonListener where there was a case mismatch when checking the addon ID. Thanks for helping sort this out :thumbup:
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
Linux Mint 21 Xfce x64 on HP i5-5200 laptop, 12 GB RAM.
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

User avatar
Kris_88
Keeps coming back
Keeps coming back
Posts: 933
Joined: 2021-01-26, 11:18

Re: Can't delete my extension's user modified preferences on uninstall

Unread post by Kris_88 » 2022-10-29, 12:47

OK!

Locked