Permalink
Browse files

bugfix: CVWidget:-oscConnect

make sure arguments to NetAddr have the correct type regardless from how oscConnect got called (GUI or from code)
warn if a OSCresponder for the Widget already exists

Signed-off-by: nuss <st9fan@gmail.com>
  • Loading branch information...
nuss committed Apr 14, 2013
1 parent 41011ba commit 30d4befca0bdd7e65dcb2f20dc7dc840522d623f
Showing with 20 additions and 11 deletions.
  1. +20 −11 CVCenter/CVWidget.sc
View
@@ -604,14 +604,18 @@ CVWidget {
oscConnect { |ip, port, name, oscMsgIndex=1, slot|
var thisIP, intPort;
- if(ip.size > 0 and:{
- "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$".matchRegexp(ip).not and:{
- ip != "nil"
+ ip !? { thisIP = ip.asString.replace(" ", "") };
+
+ if(thisIP.size > 0 and:{
+ "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$".matchRegexp(thisIP).not and:{
+ thisIP != "nil"
}
}, {
- Error("Please provide a valid IP-address or leave the IP-field empty").throw;
+ Error("Please provide a valid IP-address or leave the it empty").throw;
});
+ if(thisIP.size == 0 or:{ thisIP == "nil" }, { thisIP = nil });
+
intPort = port.asString;
if(intPort.size > 0, {
@@ -620,23 +624,26 @@ CVWidget {
}, {
intPort = intPort.asInt;
})
- });
+ }, { intPort = nil });
- if(ip == "nil", { thisIP = "" }, { thisIP = ip });
- if(port == "nil", { intPort = nil });
+ if(port == "nil" or:{ port == nil }, { intPort = nil });
if("^\/".matchRegexp(name.asString).not, {
Error("You have to supply a valid OSC-typetag (command-name), beginning with an \"/\" as third argument to oscConnect").throw;
});
switch(this.class,
CVWidgetKnob, {
- wdgtControllersAndModels.oscConnection.model.value_([thisIP, intPort, name.asSymbol, oscMsgIndex.asInteger]).changedKeys(synchKeys);
- CmdPeriod.add({ if(this.class.removeResponders, { this.oscDisconnect }) });
+ if(midiOscEnv.oscResponder.isNil, {
+ wdgtControllersAndModels.oscConnection.model.value_([thisIP, intPort, name.asSymbol, oscMsgIndex.asInteger]).changedKeys(synchKeys);
+ CmdPeriod.add({ if(this.class.removeResponders, { this.oscDisconnect }) });
+ }, { "Already connected!".warn })
},
{
- wdgtControllersAndModels[slot.asSymbol].oscConnection.model.value_([thisIP, intPort, name.asSymbol, oscMsgIndex.asInteger]).changedKeys(synchKeys);
- CmdPeriod.add({ if(this.class.removeResponders, { this.oscDisconnect(slot.asSymbol) }) });
+ if(midiOscEnv[slot].oscResponder.isNil, {
+ wdgtControllersAndModels[slot.asSymbol].oscConnection.model.value_([thisIP, intPort, name.asSymbol, oscMsgIndex.asInteger]).changedKeys(synchKeys);
+ CmdPeriod.add({ if(this.class.removeResponders, { this.oscDisconnect(slot.asSymbol) }) });
+ }, { "Already connected!".warn })
}
)
}
@@ -1362,6 +1369,8 @@ CVWidget {
)
};
+ // "IP, IP.class: %, %\nport, port.class: %, %\n".postf(theChanger.value[0], theChanger.value[0].class, theChanger.value[1], theChanger.value[1].class);
+
if(theChanger.value[0].size > 0, { netAddr = NetAddr(theChanger.value[0], theChanger.value[1]) });
if(midiOscEnv.oscResponder.isNil, {

0 comments on commit 30d4bef

Please sign in to comment.