10-18-2007 11:50 PM
10-19-2007 12:20 AM - edited 10-19-2007 12:20 AM
Well, sure as heck, I look at wordreport.c in CVI 8.1 and they've changed the error handling in this exact spot !!!!!
linHandleL is a local and not initialized, so trying to close it breaks if it happens to be non-zero but not a valid handle.
CVI 8.1 :
HRESULT CVIFUNC WordRpt_GoToDocumentTop (CAObjHandle docHandle)
{
HRESULT error = S_OK;
CAObjHandle lineHandleL = 0;
VARIANT vtGoToLine, vtGoToFirst;
vtGoToLine = CA_VariantInt (WordConst_wdGoToLine);
vtGoToFirst = CA_VariantInt (WordConst_wdGoToFirst);
errChk (Word_DocumentGoTo (docHandle, NULL, vtGoToLine,
vtGoToFirst, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, &lineHandleL));
errChk (Word_RangeSelect (lineHandleL, NULL));
Error:
CA_DiscardObjHandle(lineHandleL);
return error;
}
Previous version (CVI 8.0 or 7.1 I don't know which):
HRESULT CVIFUNC WordRpt_GoToDocumentTop (CAObjHandle docHandle)
{
HRESULT error = S_OK;
CAObjHandle lineHandleL;
VARIANT vtGoToLine, vtGoToFirst;
vtGoToLine = CA_VariantInt (WordConst_wdGoToLine);
vtGoToFirst = CA_VariantInt (WordConst_wdGoToFirst);
errChk (Word_DocumentGoTo (docHandle, NULL, vtGoToLine,
vtGoToFirst, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, &lineHandleL));
errChk (Word_SelectionSelect (lineHandleL, NULL));
Error:
if (lineHandleL)
CA_DiscardObjHandle(lineHandleL);
return error;
}
So my questions are:
Is this a "real" error, or is the actual error somewhere upstream of this (i.e bad document handle), or is this just a case of a non-initialized local variable getting referenced when it happens to be non-zero?
If it's a bad document handle (some upstream error), and I'm running in debug mode, why wouldn't I get an error popup prior to this function?
Can I rebuild the application using just this newer, CVI 8.1 version of wordreport.c in CVI 8.0 ? I don't want to build the app in 8.1 because of an issue with the serial library.
Should I change just this function in my (previously working fine) version of wordreport.c?
Menchar
Message Edited by menchar on 10-18-2007 10:24 PM
10-19-2007 12:31 AM - edited 10-19-2007 12:31 AM
Here's the top level code. We ran the debug build by itself (not using the IDE) just to get a popup at any library errors. The first error to show up is in the WordRpt_GoToDocumentTop() call. I'd have thought if the doc handle was bad we'd see the error prior to that.
newDocument is true (nonzero) and fillInCoverSheet is true also.
// Open the document.
if(newDocument) {
WordRpt_DocumentNew(appHandle, &docHandle);
WordRpt_PageOrientation(docHandle, 1); // landscape
// Set the default formatting attributes.
// Set the margins.
// WordRpt_SetMargins(CAObjHandle docHandle, float top, float bottom, float left, float right)
WordRpt_SetMargins(docHandle, 0.3, 0.5, 1.2, 1.2);
// Add page numbering.
// WordRpt_AddPageNumbers(CAObjHandle docHandle, int headerfooter, int alignment, int firstPage)
WordRpt_AddPageNumbers(docHandle, WRConst_Footer, WRConst_AlignPageNumberCenter, WRConst_TRUE);
if(!fillInCoverSheet) {
// Reserve the first page for the cover sheet.
WordRpt_NewPage(docHandle);
}
} else {
WordRpt_DocumentOpen(appHandle, dataPackFileName, &docHandle);
}
// Position the cursor at the correct location inside the document.
if(fillInCoverSheet) {
WordRpt_GoToDocumentTop(docHandle); <========= error popup here.
} else {
WordRpt_GoToDocumentEnd(docHandle);
if(!newDocument)
WordRpt_NewPage(docHandle);
}
Thanks for any help / insight, yup I'm over the top a bit with this but it's getting my goat.
Menchar
Message Edited by menchar on 10-18-2007 10:34 PM
Message Edited by menchar on 10-18-2007 10:36 PM
10-19-2007 01:11 PM
10-19-2007 01:48 PM
Luis -
Yup, my thoughts exactly, if uptream call failed why no popup.
We're going to debug through it to see what's happening.
Thanks.
Menchar
10-19-2007 05:29 PM
10-19-2007 05:57 PM
10-19-2007 08:18 PM
10-20-2007 12:28 AM
10-22-2007 11:47 AM - edited 10-22-2007 11:47 AM
Message Edited by menchar on 10-22-2007 09:48 AM