Skip to content

Commit ac5dee2

Browse files
Fixed an issue with settings.
Signed-off-by: David Rebbe <drebbe@intrepidcs.com>
1 parent 6ac22e2 commit ac5dee2

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎src/methods.cpp‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "methods.h"
1+
#include "methods.h"
22
#include "exceptions.h"
33
#include "dll.h"
44
#include "defines.h"
@@ -1307,11 +1307,12 @@ PyObject* meth_get_device_settings(PyObject* self, PyObject* args)
13071307
}
13081308
// Grab the buffer out of the newly created object - make sure to call PyBuffer_Release(&settings_buffer) when done.
13091309
Py_buffer settings_buffer = {};
1310-
PyObject_GetBuffer(settings, &settings_buffer, PyBUF_SIMPLE);
1310+
PyObject_GetBuffer(settings, &settings_buffer, PyBUF_C_CONTIGUOUS | PyBUF_WRITABLE);
13111311

13121312
// Verify we have a valid NeoDevice Object - This comes after s_device_settings allocation for testing purposes
13131313
if (!PyNeoDevice_CheckExact(obj)) {
13141314
PyBuffer_Release(&settings_buffer);
1315+
Py_DECREF(settings);
13151316
return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME "." NEO_DEVICE_OBJECT_NAME);
13161317
}
13171318
ICS_HANDLE handle = PyNeoDevice_GetHandle(obj);
@@ -1320,6 +1321,7 @@ PyObject* meth_get_device_settings(PyObject* self, PyObject* args)
13201321
ice::Library* lib = dll_get_library();
13211322
if (!lib) {
13221323
PyBuffer_Release(&settings_buffer);
1324+
Py_DECREF(settings);
13231325
char buffer[512];
13241326
return set_ics_exception(exception_runtime_error(), dll_get_error(buffer));
13251327
}
@@ -1334,6 +1336,7 @@ PyObject* meth_get_device_settings(PyObject* self, PyObject* args)
13341336
{
13351337
Py_BLOCK_THREADS
13361338
PyBuffer_Release(&settings_buffer);
1339+
Py_DECREF(settings);
13371340
return set_ics_exception(exception_runtime_error(), "icsneoGetDeviceSettingsType() Failed");
13381341
}
13391342
}
@@ -1343,10 +1346,12 @@ PyObject* meth_get_device_settings(PyObject* self, PyObject* args)
13431346
{
13441347
Py_BLOCK_THREADS
13451348
PyBuffer_Release(&settings_buffer);
1349+
Py_DECREF(settings);
13461350
return set_ics_exception(exception_runtime_error(), "icsneoGetDeviceSettings() Failed");
13471351
}
13481352
Py_END_ALLOW_THREADS
13491353
//PyBuffer_Release(&settings_buffer);
1354+
//Py_INCREF(settings);
13501355
return settings;
13511356
}
13521357
catch (ice::Exception& ex)
@@ -1382,7 +1387,7 @@ PyObject* meth_set_device_settings(PyObject* self, PyObject* args)
13821387
// int _stdcall icsneoSetDeviceSettings(void* hObject, SDeviceSettings* pSettings, int iNumBytes, int bSaveToEEPROM, EPlasmaIonVnetChannel_t vnetSlot)
13831388
ice::Function<int __stdcall (ICS_HANDLE, SDeviceSettings*, int, int, EPlasmaIonVnetChannel_t)> icsneoSetDeviceSettings(lib, "icsneoSetDeviceSettings");
13841389
Py_buffer settings_buffer = {};
1385-
PyObject_GetBuffer(settings, &settings_buffer, PyBUF_SIMPLE);
1390+
PyObject_GetBuffer(settings, &settings_buffer, PyBUF_C_CONTIGUOUS | PyBUF_WRITABLE);
13861391
Py_BEGIN_ALLOW_THREADS
13871392
if (!icsneoSetDeviceSettings(handle, (SDeviceSettings*)settings_buffer.buf, settings_buffer.len, save_to_eeprom, vnet_slot)) {
13881393
Py_BLOCK_THREADS

0 commit comments

Comments
 (0)