Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UpdateSource is null on PrepareUpdates #36

Open
zam6ak opened this issue Mar 18, 2013 · 0 comments
Open

UpdateSource is null on PrepareUpdates #36

zam6ak opened this issue Mar 18, 2013 · 0 comments
Labels

Comments

@zam6ak
Copy link

zam6ak commented Mar 18, 2013

Hi

I was following an example from NAppUpdate blog (which I now know is not only outdated but erroneous, see: http://pastebin.com/198EtE6B).

In it CheckForUpdates is passed IUpdateSource but unless set globally ahead of the time, it will cause the PrepareUpdates to fail.

So this does not work:

// prep
var updateManager = UpdateManager.Instance;
// more checks
updateManager.CheckForUpdates(updateSource); // passed in via method arg
// other stuff...
 updateManager.PrepareUpdates(); // <-- NPE

But this does

// prep
var updateManager = UpdateManager.Instance;
updateManager.UpdateSource = updateSource; // must set it here !!!
// more checks
updateManager.CheckForUpdates(updateSource);
// other stuff...
 updateManager.PrepareUpdates();  // <-- now it works....

Suggested fix:
in UpdateManager.cs inside of public void CheckForUpdates(IUpdateSource source) method after checking the args re-set UpdateSource to (maybe line 247)

UpdateSource = source;

so that subseqent call to Prepare does not fail...

Perhaps even better, do not allow methods to accept update source at all, and have checks in all methods to insure it is set before invoking them (unless there is a need to have varying update sources during update process ?)....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants