Skip to content

Commit f49fce0

Browse files
committed
halui -fix memory leaks
1 parent 6a57188 commit f49fce0

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

lib/python/bridgeui/bridge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def init_read(self):
9797
self.readSocket.connect(self.readAddress)
9898

9999
# callback from ZMQ read socket
100-
def readMsg(self, msg):
100+
def readMsg(self):
101101
if self.readSocket.getsockopt(zmq.EVENTS) & zmq.POLLIN:
102102
while self.readSocket.getsockopt(zmq.EVENTS) & zmq.POLLIN:
103103
# get raw message

src/emc/usr_intf/halui.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,9 +1875,8 @@ static void py_call_axis_jogspeed(double speed)
18751875
if (pValue == NULL){
18761876
fprintf(stderr, "halui bridge: writeMsg function failed: returned NULL\n");
18771877
if (PyErr_Occurred()) PyErr_Print();
1878-
}else{
1879-
Py_DECREF(pValue);
18801878
}
1879+
Py_DECREF(pValue);
18811880

18821881
}else{
18831882
if (PyErr_Occurred()) PyErr_Print();
@@ -1924,9 +1923,8 @@ static void py_call_axis_changed( int axis)
19241923
if (pValue == NULL){
19251924
fprintf(stderr, "halui bridge: writeMsg function failed: returned NULL\n");
19261925
if (PyErr_Occurred()) PyErr_Print();
1927-
}else{
1928-
Py_DECREF(pValue);
19291926
}
1927+
Py_DECREF(pValue);
19301928

19311929
}else{
19321930
if (PyErr_Occurred()) PyErr_Print();
@@ -1944,9 +1942,8 @@ static void py_call_request_MDI( int index)
19441942
if (pValue == NULL){
19451943
fprintf(stderr, "halui bridge: runIndexedMacro function failed: returned NULL\n");
19461944
if (PyErr_Occurred()) PyErr_Print();
1947-
}else{
1948-
Py_DECREF(pValue);
19491945
}
1946+
Py_DECREF(pValue);
19501947

19511948
}else{
19521949
if (PyErr_Occurred()) PyErr_Print();
@@ -1972,8 +1969,9 @@ static void check_hal_changes()
19721969

19731970
// get python to process socket messages
19741971
pFuncRead = PyObject_GetAttrString(pInstance, "readMsg");
1972+
19751973
if (pFuncRead && PyCallable_Check(pFuncRead)) {
1976-
pValue = PyObject_CallFunction(pFuncRead, "O", pClass);
1974+
pValue = PyObject_CallNoArgs(pFuncRead);
19771975
if (pValue == NULL){
19781976
fprintf(stderr, "Halui Bridge: readMsg function failed: returned NULL\n");
19791977
}
@@ -1985,6 +1983,8 @@ static void check_hal_changes()
19851983
fprintf(stderr, "Bridge: Failed python function");
19861984
exit(1);
19871985
}
1986+
Py_DECREF(pFuncRead);
1987+
Py_DECREF(pValue);
19881988

19891989
// check socket messages for current axis selection
19901990
int value = py_call_get_axis_selected();
@@ -2766,6 +2766,7 @@ int main(int argc, char *argv[])
27662766
fprintf(stderr, "bridge: Failed to load \"%s\"\n", "pyui");
27672767
exit(1);
27682768
}
2769+
Py_DECREF(pClass);
27692770

27702771
// get configuration information
27712772
if (0 != iniLoad(emc_inifile)) {

0 commit comments

Comments
 (0)