UpdateCheck

class controllers.UpdateCheck

Bases: handle

UPDATECHECK - Controller for the Check for Update dialog.

Constructor Summary
UpdateCheck(mibModel, varargin)

UPDATECHECK - Constructor for the Check for Update dialog controller.

Syntax:

controller = controllers.UpdateCheck(mibModel)
controller = controllers.UpdateCheck(mibModel, mibController)
Input Arguments:
  • mibModel - handle to the MibModel instance

  • mibController - (optional) handle to MibController; without it the Update button installs the new version but cannot restart MIB

Output Arguments:
  • controller - handle to the constructed UpdateCheck controller

Property Summary
mibController

handle to the view

mibModel
mibVersion

handle to MibController; optional, required only to restart MIB after an in-place update

view

handle to the model

Method Summary
addCallbacks()

ADDCALLBACKS - Wire all widget callbacks and tooltips for the Update Check dialog.

closeWindow()

CLOSEWINDOW - Close the Update Check dialog and fire CloseEvent.

downloadBtn_Callback()

DOWNLOADBTN_CALLBACK - Open the platform-specific MIB download link in a browser.

HTTPS only, without a fallback to HTTP: browsers (Chrome: “Insecure download blocked”) refuse downloads over plain HTTP, and web does not report such a refusal, so a fallback could never be triggered.

recheckPeriodSpinner_Callback(hObject)

RECHECKPERIODSPINNER_CALLBACK - Save the recheck period preference.

updateBtn_Callback()

UPDATEBTN_CALLBACK - Download and install a MIB update in-place (MATLAB mode only).

Prompts for the installation directory, downloads MIB3_Matlab.zip to a temporary file and unzips it into the destination. The download goes over HTTPS; when that fails it is retried once over plain HTTP, and only the error of the HTTP attempt is shown.

The zip contains the whole distribution with mib\ at its top level, so the suggested destination is the parent of mibModel.mibPath; unzipping into mibPath itself would create mib\mib\ and leave the running installation untouched.

Cancel is honoured after the download, before the unzip, which is the only irreversible step; the download and the unzip themselves cannot be interrupted, so the dialog stops being cancelable once the unzip starts.

Files held open by MATLAB cannot be replaced; unzip skips them with the MATLAB:io:archive:extractArchive:OverwriteOpenFile warning and leaves them out of its returned list. This always hits the window icons (mib_icon_16px.png of the dialogs, mib_icon_32px.png of the main window): a uifigure keeps its Icon file locked for the rest of the MATLAB session, even after it is deleted, so an update run at startup is affected as well. The warning ID is language independent; when it is the last warning of the unzip, the zip is extracted once more to a temporary folder to get its full file list, and the skipped files are named in the final message. Skipped icons are reported as harmless; anything else as a possible malfunction, with the advice to restart MATLAB and update again. A lock scan of the installation instead would take about 70 s.

MIB is restarted only when the destination is the running installation and mibController was supplied; otherwise the running MIB stays open and the user is told where the new copy is. The restart closes the main window with AppContainer.close(), which runs MibController.exitProgram through CanCloseFcn exactly as the window close button does: preferences and user stats are saved and all child windows, this one included, are closed. exitProgram must not be called directly - it is only the close request handler and leaves the main window open. close() is synchronous, so the new MIB is started afterwards from a single-shot timer: it is constructed once this callback has returned and released its handles to the old instance, not inside the callback of a window that no longer exists.

updateWidgets()

UPDATEWIDGETS - Fetch the version file from the MIB server and populate the dialog.

Selects the appropriate URL by platform, fetches the text file, parses the version number and HTML sections, then updates informationText and the informationEdit HTML pane. The version file is read over HTTPS; when that fails (e.g. a proxy or an old Java without the server’s certificate chain) it is read again over plain HTTP, so an unreachable server costs up to two 4 s timeouts.

informationText is emphasized: bold, 4 points larger than the MIB font, word-wrapped and centered next to the image. Its background tells the outcome apart, using the tints of utils.themeColors:

  • panelGreen - a newer version is available; the release notes are shown

  • panelBlue - the running version is the latest; the general information section is shown

  • panelYellow - the version could not be determined (server not reachable, or no number before the first <html> of the version file); the release notes section, which for an unreachable server is the local “not detected” message, is shown. Without this case the NaN version would fall through to “latest version”

utils.applyThemeColors (the ThemeChangedFcn of the dialog) remaps these tints on a light/dark theme switch. Must run after utils.fontSizeUpdate, which would reset the font size.