From: Francesco <f18...@ya...> - 2010-03-04 09:44:25
|
Hi Frans, 2010/3/4 Frans Schreuder <fra...@gm...>: > I saw that in your modifications, you called libusb_init() from main.cpp (as > well ass libusb_exit). > I think it is better to move this to the hardware constructor and > destructor. hmmm, why? > I already tested this in linux, but I don't know if it works out > well on all systems? on Windows it didn't work well with the earlier versions of the libusb windows port. I didn't test recently but in any case I think that the initialization is a bit slow because the windows port needs to internally enumerate the USB hubs AFAIR. > What was the reason for you to call these functions from main? in general the initialization of all libraries is done in the main() of a program and never repeated (as it shouldn't really be necessary!). The initialization routines usually allocate memory and perform many operations which maybe time-consuming. I don't think we should repeat them multiple times unless absolutely necessary. In fact, I think that also the current organization of the Hardware class, which gets allocated and deleted multiple times should also be avoided: upp_wx currently is very slow to start up and IIRC this is because Hardware is created and deleted 2-3 times at the startup. I'd really like much more to have a Hardware m_hw; member in UsbPicProg class definition and then have just a bool Connect(HardwareType hwToTryToConnect); member in the Hardware class which would be used by UppMainWindow (only when necessary). I think this would be: 1) a better design from a OOP point of view. 2) more efficient design => reduce startup time of upp_wx. If you agree I can do such modifications in the weekend... Francesco |