diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2014-09-18 19:00:56 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2014-09-19 10:56:53 +0200 |
commit | b2ef4a806bd5f8f81917a7c93d210cee123191af (patch) | |
tree | 6de595aebfa0789af9ccf3d2fb6b73cff917c492 /utils/regtools | |
parent | 7d112053abefb9574e922b467ccf2f04a49591e3 (diff) |
qeditor: initialise libusb once in a static ctor
Change-Id: Ic93def2b3633c498c9863b0dada3281853be8c6c
Reviewed-on: http://gerrit.rockbox.org/973
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
Diffstat (limited to 'utils/regtools')
-rw-r--r-- | utils/regtools/qeditor/backend.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/utils/regtools/qeditor/backend.cpp b/utils/regtools/qeditor/backend.cpp index 86e4d60ef9..570ae4d01f 100644 --- a/utils/regtools/qeditor/backend.cpp +++ b/utils/regtools/qeditor/backend.cpp @@ -356,7 +356,6 @@ bool HWStubIoBackend::Reload() */ HWStubBackendHelper::HWStubBackendHelper() { - libusb_init(NULL); #ifdef LIBUSB_NO_HOTPLUG m_hotplug = false; #else @@ -371,7 +370,7 @@ HWStubBackendHelper::HWStubBackendHelper() &HWStubBackendHelper::HotPlugCallback, reinterpret_cast< void* >(this), &m_hotplug_handle); } -#endif +#endif /* LIBUSB_NO_HOTPLUG */ } HWStubBackendHelper::~HWStubBackendHelper() @@ -379,7 +378,7 @@ HWStubBackendHelper::~HWStubBackendHelper() #ifndef LIBUSB_NO_HOTPLUG if(m_hotplug) libusb_hotplug_deregister_callback(NULL, m_hotplug_handle); -#endif +#endif /* LIBUSB_NO_HOTPLUG */ } QList< HWStubDevice* > HWStubBackendHelper::GetDevList() @@ -420,14 +419,28 @@ int HWStubBackendHelper::HotPlugCallback(struct libusb_context *ctx, struct libu } return 0; } -#endif +#endif /* LIBUSB_NO_HOTPLUG */ bool HWStubBackendHelper::HasHotPlugSupport() { return m_hotplug; } -#endif +namespace +{ +class lib_usb_init +{ +public: + lib_usb_init() + { + libusb_init(NULL); + } +}; + +lib_usb_init __lib_usb_init; +} + +#endif /* HAVE_HWSTUB */ /** * BackendHelper |