www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Little app using gtkD, how to make it well?

reply Romain <no no.com> writes:
Hello,

I started an application using gtkD and libusb-d. I would love to 
get some hints about how to make good use of D since I'm a java 
developper and maybe use too much of it in D code or doing wrong 
things.

The program will only work with msi laptop that have a 
steelseries keyboard, but it may work with other hardware and is 
untested.

I think the program leak (or don't release the usb handle) when 
exiting using ctrl+c for example, so I may move the Keyboard and 
all libusb object in the global scope and use them by using a 
kind of sigterm handler. Initially I used the "scope(exit){}" but 
it don't work :)


Thanks you
Sep 11 2017
next sibling parent Romain <no no.com> writes:
On Monday, 11 September 2017 at 20:19:28 UTC, Romain wrote:
 Hello,

 I started an application using gtkD and libusb-d. I would love 
 to get some hints about how to make good use of D since I'm a 
 java developper and maybe use too much of it in D code or doing 
 wrong things.

 The program will only work with msi laptop that have a 
 steelseries keyboard, but it may work with other hardware and 
 is untested.

 I think the program leak (or don't release the usb handle) when 
 exiting using ctrl+c for example, so I may move the Keyboard 
 and all libusb object in the global scope and use them by using 
 a kind of sigterm handler. Initially I used the "scope(exit){}" 
 but it don't work :)


 Thanks you
Of course, the url is https://github.com/notnotme/msi-steelseries
Sep 11 2017
prev sibling parent Jesse Phillips <Jesse.K.Phillips+D gmail.com> writes:
On Monday, 11 September 2017 at 20:19:28 UTC, Romain wrote:
 Hello,

 I started an application using gtkD and libusb-d. I would love 
 to get some hints about how to make good use of D since I'm a 
 java developper and maybe use too much of it in D code or doing 
 wrong things.

 The program will only work with msi laptop that have a 
 steelseries keyboard, but it may work with other hardware and 
 is untested.

 I think the program leak (or don't release the usb handle) when 
 exiting using ctrl+c for example, so I may move the Keyboard 
 and all libusb object in the global scope and use them by using 
 a kind of sigterm handler. Initially I used the "scope(exit){}" 
 but it don't work :)


 Thanks you
scope(exit) isn't going to handle a ctrl+c on the program. Your OS should handle resource acquisition once the program has been killed.
Sep 11 2017