dustinrue/ControlPlane — pull request #256 by VladimirTechMan (2013-04-30 19:22:11+00:00)
Title: Memleak fix and improvements in awakeFromNib of CPController

Making several changes to method **awakeFromNib** of **CPController**, as follows:

- Fixing the memory leak that happens when an evidence source started by calling **[evidenceSources startOrStopAll]** posts an "evidenceSourceDataDidChange" notification. That causes calling **doUpdate** and creating the update timer. Then the timer is re-created again as a part of **awakeFromNib**, thus leaking an earlier created timer. Currently the issue happens if the "Nearby WiFi Network" evidence source is enabled.
- Improving the sequence of high-level actions inside **awakeFromNib** so that (1) loading user defaults and persistent contexts are handled, (2) flags and queues for screen lock and screen saver are set, (3) update and sleep threads are started, (4) the icon / title are set in status bar and the app is unhidden, (5) evidence sources are started and updating timer is created (if not created yet).
- Unhiding the app without activation (expect when the debug setting requires to show prefs window). That is especially useful when the notifications from CP are enabled -- otherwise (if the CP remains active after the start) the pop up notifications will not be shown to the user (though they will be added to the notification center history, if configured so).

Any questions or comments on those code changes, let me know.