Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Fix #392, 'setMenu of null' with multiple instances #394

Merged
merged 2 commits into from
Apr 21, 2017
Merged

Fix #392, 'setMenu of null' with multiple instances #394

merged 2 commits into from
Apr 21, 2017

Conversation

keforbes
Copy link
Collaborator

This is more of a workaround than a true fix but it works fine. Basically, we're setting the rebuild-menu event listener on ipcMain but there is only a single instance of ipcMain across all Oni windows. When one of the instances receives a rebuild-menu event from one of the other instances it would try calling mainWindow.setMenu() and get this error.

My fix is to just ignore the event if mainWindow is null. So it avoids the error but I feel like in the future we should find a way to isolate the Oni instances a little better.

@bryphe
Copy link
Member

bryphe commented Apr 21, 2017

My fix is to just ignore the event if mainWindow is null. So it avoids the error but I feel like in the future we should find a way to isolate the Oni instances a little better.

Sounds good for now. At least this will suppress the error. I think that the event object returned from ipcMain has a WebContents instance through the sender event property of the object it returns. It looks like we need the BrowserWindow instance though - but maybe we can derive that from the WebContents. That way, we could pass in the BrowserWindow that is relevant for the event to rebuildMenu.

I'm also wondering if later there is a way to handle more of the menu logic in browser/src instead of building it from main.js - I think we might be able to call those methods directly from the browser process without needing to ipc out, and that might help us out here.

In the meantime this will definitely help alleviate that pain point - thanks for the fix, @keforbes !

@bryphe bryphe merged commit 1aa7f41 into onivim:master Apr 21, 2017
@keforbes keforbes deleted the fix-392 branch April 21, 2017 20:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants