Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing prefixes for xxx.prj. and xxx.xxx.prj. object in two code files #77

Open
spacenka opened this issue Oct 1, 2021 · 0 comments
Open

Comments

@spacenka
Copy link

spacenka commented Oct 1, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant