From eaa0ef06512ffe44eb3f24404454fd85240bb6ff Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 24 Feb 2017 01:27:38 +0100 Subject: [PATCH] midi: make sure the process terminates when closing the app main window --- app/main/main.js | 2 ++ app/main/midi.js | 15 +++++---------- app/main/osc.js | 3 ++- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/main/main.js b/app/main/main.js index 664f0fd4..c06fc923 100644 --- a/app/main/main.js +++ b/app/main/main.js @@ -29,6 +29,7 @@ var start = function(readyApp) { var win = require('./electron-window')({address:address, shortcuts:true}) app.on('before-quit',()=>{ win.destroy() + if (osc.midi) osc.midi.stop() }) return win } else { @@ -36,6 +37,7 @@ var start = function(readyApp) { var win = require('./electron-window')({address:address, shortcuts:true}) app.on('before-quit',()=>{ win.destroy() + if (osc.midi) osc.midi.stop() }) }) } diff --git a/app/main/midi.js b/app/main/midi.js index 37cde77b..bb79573f 100644 --- a/app/main/midi.js +++ b/app/main/midi.js @@ -6,15 +6,6 @@ var PythonShell = require('python-shell'), var py = new PythonShell(path.resolve('/main/midi.py'),{mode:'text', args: settings.read('midi')}) - -// py.send('zefezf') -// -// -// py.on('error', function (message) { -// // received a message sent from the Python script (a simple "print" statement) -// console.log('error:' +message); -// }); - oscToMidi = (data)=>{ var args = [] for (i in data.args) { @@ -41,8 +32,12 @@ init = (receiveOsc)=>{ }) } +stop = ()=>{ + py.childProcess.kill() +} module.exports = { send: oscToMidi, - init: init + init: init, + stop: stop } diff --git a/app/main/osc.js b/app/main/osc.js index 0ef2525e..4806f518 100644 --- a/app/main/osc.js +++ b/app/main/osc.js @@ -179,5 +179,6 @@ module.exports = { sendOsc(data) - } + }, + midi:midi }