Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"url": "git+https://github.com/opencor/webapp.git"
},
"type": "module",
"version": "1.20261105.1",
"version": "1.20261106.0",
"engines": {
"bun": ">=1.2.0"
},
Expand Down Expand Up @@ -93,8 +93,8 @@
"typescript-6": "npm:typescript@^6.0.3",
"unplugin-vue-components": "^32.1.0",
"uplot": "1.6.32",
"vite": "^8.3.5",
"vue": "^3.5.44",
"vite": "^8.3.6",
"vue": "^3.5.45",
"vue-tsc": "^3.3.14"
}
}
33 changes: 28 additions & 5 deletions src/main/MainWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,33 @@ export const clearRecentFiles = (): void => {
recentFilePaths = [];

updateReopenMenu(recentFilePaths);

// Let our renderer know that our recent files have been cleared, so that it can release the contents that it kept for
// the files that were opened using a data URL and then closed (see OpenCOR.addRecentFile()).

MainWindow.instance?.send('clear-recent-files');
};

export const fileClosed = (filePath: string): void => {
// Make sure that the file was not opened using a data URL (see isDataUrlFileName()).
// Note: a file opened using a data URL only exists in memory, in our renderer (see isDataUrlFileName()), so it can only
// be reopened during the current session and only as long as our renderer is not gone. Hence, we never save such
// a file as a recent file (see the constructor of MainWindow) and we forget about it when our renderer is gone
// (see onRenderProcessGone()).

if (isDataUrlFileName(filePath)) {
return;
const persistentRecentFilePaths = (): string[] => {
return recentFilePaths.filter((filePath) => !isDataUrlFileName(filePath));
};

const forgetDataUrlRecentFilePaths = (): void => {
const filePaths = persistentRecentFilePaths();

if (filePaths.length !== recentFilePaths.length) {
recentFilePaths = filePaths;

updateReopenMenu(recentFilePaths);
}
};

export const fileClosed = (filePath: string): void => {
removeRecentFilePath(filePath);

recentFilePaths.unshift(filePath);
Expand Down Expand Up @@ -825,7 +843,7 @@ export class MainWindow extends ApplicationWindow {

// Recent files.

electronConf.set('app.files.recent', recentFilePaths);
electronConf.set('app.files.recent', persistentRecentFilePaths());

// Opened files and selected file.
// Note: if our renderer is not ready, then either it crashed and we are being closed before it could be
Expand Down Expand Up @@ -1082,6 +1100,11 @@ export class MainWindow extends ApplicationWindow {

disallowSavingAnyFile();

// Our renderer is gone, so are the contents of the files that were opened using a data URL and then closed, i.e.
// those files cannot be reopened anymore.

forgetDataUrlRecentFilePaths();

// Ignore our renderer being gone if we are being closed (e.g., because OpenCOR is being quit), whatever the reason.
// Indeed, our renderer will normally exit cleanly in that case, but it may also be killed (e.g., when logging off or
// shutting down the system) or crash while being torn down. Either way, there is nothing to recover since we are
Expand Down
1 change: 1 addition & 0 deletions src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ electron.contextBridge.exposeInMainWorld('electronApi', {
onIpc('canonicalise-recent-file-paths', callback),
onChangelog: (callback: () => void) => onIpc('changelog', callback),
onCheckForUpdates: (callback: () => void) => onIpc('check-for-updates', callback),
onClearRecentFiles: (callback: () => void) => onIpc('clear-recent-files', callback),
onEnableDisableUi: (callback: (enable: boolean) => void) => onIpc('enable-disable-ui', callback),
onOpen: (callback: (filePath: string) => void) => onIpc('open', callback),
onOpenRemote: (callback: () => void) => onIpc('open-remote', callback),
Expand Down
Loading
Loading