ImportPhotos
ImportPhotos copied to clipboard
Missing prefixes for xxx.prj. and xxx.xxx.prj. object in two code files
The popup viewer in 3.0.2 falls back to a relative path (relative to current project) when the full path of an image file cannot be found. This is helpful when sharing a QGIS map across systems with different user names, since the full paths may differ.
The 3.0.2 code attempts to retrieve the path of the current project incorrectly, causing a Python crash.
The simple corrections that seem to work are to provide a necessary object prefix. code for MouseClick.py (fifth line puts self. in front of prj.fileName() in the QFileInfo() call):
try:
if not os.path.exists(imPath):
self.prj = QgsProject.instance()
if self.prj.fileName() and 'RELPATH' in fields:
imPath = os.path.join(QFileInfo(self.prj.fileName()).absolutePath(), feature.attributes()[feature.fieldNameIndex('RelPath')])
else:
c = self.drawSelf.noImageFound()
if c: return
A similar fix is needed in PhotosViewer.py, inserting self.drawSelf. in front of prj.fileName() in the QFileInfo() call, fourth line.
if not os.path.exists(imPath):
try:
if self.drawSelf.prj.fileName() and 'RELPATH' in self.drawSelf.fields:
imPath = QFileInfo(self.drawSelf.prj.fileName()).absolutePath() + \
feature.attributes()[feature.fieldNameIndex('RelPath')]
except:
imPath = ''
Sorry that I cannot provide a GitHub pull request to send my working versions. Just signed up for Github today to be able to report this issue. Context: QGIS 3.16.x 32 bit in MS Windows.
Thanks for coding and providing this plugin. I am testing it to pop up geological strata drawings at points where wells have been drilled.
-- SP, Cornell University, Ithaca NY USA