@@ -1751,21 +1751,31 @@ def validateDragDropEvent(self, event):
17511751 def dropEvent (self , paths ):
17521752 ext = Path (paths [0 ]).suffix .lower ()
17531753 if len (paths ) == 1 :
1754- try :
1755- # if hdf5 try as state, then materials, then images
1756- if ext in ('.h5' , '.hdf5' ):
1754+ # For single file try to guess loader based on extension
1755+ if ext in ('.h5' , '.hdf5' ):
1756+ try :
1757+ # Try loading it as a state file first
1758+ self .load_state_file (paths [0 ])
1759+ return
1760+ except :
17571761 try :
1758- # Try loading it as a state file first
1759- self .load_state_file (paths [0 ])
1760- except :
17611762 # If that fails, try loading it as a materials file
17621763 HexrdConfig ().load_materials (paths [0 ])
1763- elif ext in ('.hexrd' , '.yml' , '.yaml' ):
1764+ return
1765+ except :
1766+ # If that fails, continue on to try to load as image
1767+ pass
1768+ elif ext in ('.hexrd' , '.yml' , '.yaml' ):
1769+ try :
17641770 # Try loading it as an instrument config
17651771 HexrdConfig ().load_instrument_config (paths [0 ])
1766- except :
1767- # If everything else fails, try loading as images
1768- self .open_image_files (selected_files = paths )
1769- else :
1770- # If there are multiple files, try loading as images
1772+ return
1773+ except :
1774+ # If that fails, continue on to try to load as image
1775+ pass
1776+ try :
1777+ # Fall back to trying to load as image if no loader succeeds or
1778+ # extension is not in known list
17711779 self .open_image_files (selected_files = paths )
1780+ except Exception as e :
1781+ print (f'Error loading images: { e } ' )
0 commit comments