Skip to content

Commit

Permalink
NVDA no longer causes Microsoft Word to crash immediately after it st…
Browse files Browse the repository at this point in the history
…arts in Windows XP.

Static variables defined within functions are broken on Windows XP (Visual Studio bug 1941836), so use a global variable instead.
Fixes #6033.
  • Loading branch information
jcsteh committed Jun 10, 2016
1 parent c6f7536 commit 72cdc1f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions nvdaHelper/remote/winword.cpp
Expand Up @@ -363,8 +363,10 @@ bool collectSpellingGrammarErrorOffsets(int spellingGrammarErrorsDispId, IDispat
return !errorVector.empty();
}

// #6033: This must not be a static variable inside the function
// because that causes crashes on Windows XP (Visual Studio bug 1941836).
vector<wstring> headingStyleNames;
int getHeadingLevelFromParagraph(IDispatch* pDispatchParagraph) {
static vector<wstring> headingNames;
IDispatchPtr pDispatchStyle=NULL;
// fetch the localized style name for the given paragraph
if(_com_dispatch_raw_propget(pDispatchParagraph,wdDISPID_PARAGRAPH_STYLE,VT_DISPATCH,&pDispatchStyle)!=S_OK||!pDispatchStyle) {
Expand All @@ -376,7 +378,7 @@ int getHeadingLevelFromParagraph(IDispatch* pDispatchParagraph) {
return 0;
}
// If not fetched already, fetch all builtin heading style localized names (1 through 9).
if(headingNames.empty()) {
if(headingStyleNames.empty()) {
IDispatchPtr pDispatchDocument=NULL;
IDispatchPtr pDispatchStyles=NULL;
if(_com_dispatch_raw_propget(pDispatchStyle,wdDISPID_STYLE_PARENT,VT_DISPATCH,&pDispatchDocument)==S_OK&&pDispatchDocument&&_com_dispatch_raw_propget(pDispatchDocument,wdDISPID_DOCUMENT_STYLES,VT_DISPATCH,&pDispatchStyles)==S_OK&&pDispatchStyles) {
Expand All @@ -387,7 +389,7 @@ int getHeadingLevelFromParagraph(IDispatch* pDispatchParagraph) {
BSTR builtinNameLocal=NULL;
_com_dispatch_raw_propget(pDispatchBuiltinStyle,wdDISPID_STYLE_NAMELOCAL,VT_BSTR,&builtinNameLocal);
if(!builtinNameLocal) continue;
headingNames.push_back(builtinNameLocal);
headingStyleNames.push_back(builtinNameLocal);
SysFreeString(builtinNameLocal);
}
}
Expand All @@ -396,7 +398,7 @@ int getHeadingLevelFromParagraph(IDispatch* pDispatchParagraph) {
int level=0;
int count=1;
// See if the style name matches one of the builtin heading styles
for(auto i=headingNames.cbegin();i!=headingNames.cend();++i) {
for(auto i=headingStyleNames.cbegin();i!=headingStyleNames.cend();++i) {
if(i->compare(nameLocal)==0) {
level=count;
break;
Expand Down
6 changes: 6 additions & 0 deletions user_docs/en/changes.t2t
Expand Up @@ -3,6 +3,12 @@

%!includeconf: ../changes.t2tconf

= 2016.2.1 =
This release fixes crashes in Microsoft Word:

- NVDA no longer causes Microsoft Word to crash immediately after it starts in Windows XP. (#6033)


= 2016.2 =
Highlights of this release include the ability to indicate spelling errors while typing; support for reporting grammar errors in Microsoft Word; and improvements and fixes to Microsoft Office support.

Expand Down

0 comments on commit 72cdc1f

Please sign in to comment.