View Single Post
Old 02-28-2013, 05:16 AM   #1
Apprentice Alf
Member
Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.Apprentice Alf ought to be getting tired of karma fortunes by now.
 
Apprentice Alf's Avatar
 
Posts: 14
Karma: 1236266
Join Date: Dec 2010
Device: None
FileTypePlugin, config_widget, JSONConfig and Cancel

I am working on a FileTypePlugin with a preferences dialog implemented using config_widget, and preferences stored using JSONConfig.

When my config_widget object initialises, I copy my preferences from my JSONConfig object to local copies in the config_widget object. All changes made by the config_widget are to these local copies.

When the user exists the config_widget using the OK button, my save_settings function is called, which copies the preferences back into the JSONConfig object, which writes the preferences out to the .json disk file.

This all works fine.

When the user exits the config_widget using the Cancel button, my save_settings function is not called, and my JSONConfig preferences and disk file remain unchanged.

This all works fine.

The problem is that when the configuration dialog is next opened, my config_widget is already initialised, and retains the local copy of the preferences that may not match the preferences in my JSONConfig object.

What function do I need to add to my config_widget object so that I can copy the actual JSONConfig preferences to the config_widget local copy of the preferences every time the configuration dialog is opened, not just the first time?

I tried adding an initialize() function, but it never got called.

I hope that this is just something that I've missed in the documentation....
Apprentice Alf is offline   Reply With Quote