Skip to content

No longer crash Windows Explorer on Windows 7 when focusing metadata edit fields#10153

Merged
michaelDCurran merged 3 commits into
nvaccess:masterfrom
lukaszgo1:5337
Sep 13, 2019
Merged

No longer crash Windows Explorer on Windows 7 when focusing metadata edit fields#10153
michaelDCurran merged 3 commits into
nvaccess:masterfrom
lukaszgo1:5337

Conversation

@lukaszgo1

Copy link
Copy Markdown
Contributor

Link to issue number:

Fixes #5337

Summary of the issue:

In 89dd4b7 we started using ITextDocumentTextInfo for RichEdit on Windows 7 and above to fix some braille bugs. This however causes crashes in metadata fields in Windows Explorer under Windows 7.

Description of how this pull request fixes the issue:

For these particular edit fields EditTextInfo is used instead.

Testing performed:

Focused some mp3 files with tags, and an xlsx file with author and title. Tabbed to the metadata fields, ensured that the crash is gone.

Known issues with pull request:

Content of these edit boxes isn't always accessible, Even if it would be these controls aren't keyboard navigable so it isn't a big loss.

Change log entry:

Section: Bug fixes
Windows Explorer on Windows 7 would no longer crash when accessing metadata edit fields.

@lukaszgo1

Copy link
Copy Markdown
Contributor Author

@feerrenrut @LeonarddeR Given the fact that this crash is quite serious would it be possible to have it reviewed, and included in 2019.3?

Comment thread source/appModules/explorer.py Outdated
return windowText


class metadataEditField(RichEdit50):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that class names start in upper case

Suggested change
class metadataEditField(RichEdit50):
class MetadataEditField(RichEdit50):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mistakes like this are perfect candidates for automatic detection by linter. Would it be possible to implement this somehow?

Comment thread source/appModules/explorer.py Outdated
By default these fields would use ITextDocumentTextInfo ,
but to avoid Windows Explorer crashes we need to use EditTextInfo here. """
def _get_TextInfo(self):
return EditTextInfo

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return EditTextInfo
if ((winVersion.winVersion.major, winVersion.winVersion.minor) == (6, 1)):
cls.TextInfo = EditTextInfo
else:
cls.TextInfo = super().TextInfo
return cls.TextInfo

Comment thread source/appModules/explorer.py Outdated
""" Used for metadata edit fields in Windows Explorer in Windows 7.
By default these fields would use ITextDocumentTextInfo ,
but to avoid Windows Explorer crashes we need to use EditTextInfo here. """
def _get_TextInfo(self):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a perfect case to benefit from magic class properties:

Suggested change
def _get_TextInfo(self):
@classmethod
def _get_TextInfo(cls):

See also the suggestion for the code below. This ensures that:

  1. The winVersion check is performed only once, rather than multiple times
  2. The appropriate TextInfo class is cached for the lifetime of the nVDA instance.

Comment thread source/appModules/explorer.py Outdated
return # Optimization: return early to avoid comparing class names and roles that will never match.

if(
(winVersion.winVersion.major, winVersion.winVersion.minor) == (6, 1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer the MetadataEditField overlay to be added to all these fields.
Having said that, have you come across cases wherhe RichEdit50W is used as the window class for edit boxes in Explorer that aren't metadata edit fields? How about edit fields in the properties window of files, for example?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting to use editTextInfo for all RichEdits in Win Explorer regardless of the Windows version? I am personally against it because Windows Explorer is also used in Control Panel, and it isn't realistic to check all edit fields there under every version of Windows. I personally think that the check implemented at present might not be enough, however I haven't found any other negatively affected fields under Win 7. The main priority when bug fixing for me is not to introduce regression so better to be safe than sorry.

@LeonarddeR LeonarddeR left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, should have been a request for changes from the start.

@Brian1Gaff

Brian1Gaff commented Aug 28, 2019 via email

Copy link
Copy Markdown

@lukaszgo1

Copy link
Copy Markdown
Contributor Author

Okay, all these fields have common windowControlID, so we can match on this.

@lukaszgo1

Copy link
Copy Markdown
Contributor Author

@LeonarddeR all your requests are now addressed. I am now matching on windowControlID when choosing classes, and performing more expensive check for WIndows Version at the class level.

@LeonarddeR LeonarddeR left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for applying the changes @lukaszgo1

@LeonarddeR LeonarddeR requested a review from feerrenrut August 29, 2019 05:08
@lukaszgo1

Copy link
Copy Markdown
Contributor Author

@LeonarddeR Thanks for approving. I've looked at the dev info for these controls one more time, and it turns out that the full displayed text of these is available as its value. I've tried to overwrite _get_windowText and return content of value there to have best of both words i.e. no longer crash Win Explorer, and have content of these fields readable but it didn't work. Any ideas how to make it working? It shouldn't block this from being merged but would be nice to have.

@LeonarddeR

LeonarddeR commented Aug 29, 2019 via email

Copy link
Copy Markdown
Collaborator

@lukaszgo1

Copy link
Copy Markdown
Contributor Author

As I said in the pr description when EditTextInfo is used for these fields only part of the actual content of these is readable. However entire content is available as a value, so it would be nice to have it accessible as well. Note that windowText and value differs in these cases.

@LeonarddeR

LeonarddeR commented Aug 29, 2019 via email

Copy link
Copy Markdown
Collaborator

@michaelDCurran

Copy link
Copy Markdown
Member

Is this pr ready to be merged, or is using value important? If it is just about avoiding the crash, I think taking this as it is is the best way to go.

@LeonarddeR

Copy link
Copy Markdown
Collaborator

Pretty sure that using value as window text will break things. I vote for merging as is and if we really need to address this again, we could revisit this by creating a new textInfo that uses value as its source.

@michaelDCurran michaelDCurran merged commit 7e42799 into nvaccess:master Sep 13, 2019
@nvaccessAuto nvaccessAuto added this to the 2019.3 milestone Sep 13, 2019
michaelDCurran added a commit that referenced this pull request Sep 13, 2019
@lukaszgo1 lukaszgo1 deleted the 5337 branch September 13, 2019 10:32
@lukaszgo1

Copy link
Copy Markdown
Contributor Author

Thanks for merging.
@LeonarddeR wrote:

[...] if we really need to address this again, we could revisit this by creating a new textInfo that uses value as its source.

How hard it would be in your opinion?

@LeonarddeR

Copy link
Copy Markdown
Collaborator

A 2019.2.1 version of NVDA is on the way. I believe it has been requested that this pr would be included in that as well, see #10153 (comment). However, this issue has been there for ages and I don't think it is that severe to go into a point release. Thoughts @michaelDCurran?

@michaelDCurran

michaelDCurran commented Sep 17, 2019 via email

Copy link
Copy Markdown
Member

@XLTechie

XLTechie commented Sep 17, 2019 via email

Copy link
Copy Markdown
Collaborator

@LeonarddeR

LeonarddeR commented Sep 17, 2019 via email

Copy link
Copy Markdown
Collaborator

@lukaszgo1

Copy link
Copy Markdown
Contributor Author

A few thoughts:
First of all this crash is very severe, we cannot tell our users what they shouldn't be doing as we have done in #9435 because when they would realize that they tabbed into metadata field it is too late. The outcome of this crash is completely unusable machine, not just crashed Firefox as in case of another pull request which was included in 2019.2.1.
It is true that historically only bug fixes for issues introduced in the main release were included in the point one, however it is not the case here as both #10104 and #10188 are fixing bugs introduced not in 2019.2

@michaelDCurran

Copy link
Copy Markdown
Member

@lukaszgo1 Alright. If you can create a new pr against nvaccess/beta, and test that it still fixes the issue, then I will review it. I have a feeling that this change might be a bit too complex to simply be rebased onto beta, though I'm not sure. It does however mean that we will release a 2019.2.1beta1 and ask for feedback over a longer period of time to ensure this does not cause any other regressions. But other than this and possibly reverting liblouis to 3.9, no more changes will be considered for 2019.2.1.

@lukaszgo1

Copy link
Copy Markdown
Contributor Author

@michaelDCurran I've created #10234

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

Successfully merging this pull request may close these issues.

Windows Explorer crashes by going to the save-button of metadata

6 participants