View Single Post
Old 12-03-2014, 08:18 AM   #9
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,417
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
An alternate, probably, more performant implementation would be to use a global object named connected_device declared in devices.interface:

_connected_device = None
def connected_device():
return _connected_device

def set_connected_device(dev=None):
global _connected_device
_connected_device = dev



The GUI can simply call set_connected_device on ever device connection/disconnection. Drivers that are interested in connected status can call connected_device()

That avoids the overhead of calling a function on every device driver.
kovidgoyal is online now   Reply With Quote