Another attempt to fix closing/opening of output project
This commit is contained in:
@@ -1572,6 +1572,7 @@ int DLLEXPORT EN_setqualtype(EN_Project p, int qualType, char *chemName,
|
||||
double ccf = 1.0;
|
||||
|
||||
if (!p->Openflag) return 102;
|
||||
if (qual->OpenQflag) return 262;
|
||||
if (qualType < EN_NONE || qualType > EN_TRACE) return 251;
|
||||
qual->Qualflag = (char)qualType;
|
||||
qual->Ctol *= Ucf[QUALITY];
|
||||
|
||||
@@ -43,6 +43,7 @@ int openfiles(Project *pr, const char *f1, const char *f2, const char *f3)
|
||||
pr->report.RptFile = NULL;
|
||||
pr->outfile.OutFile = NULL;
|
||||
pr->outfile.HydFile = NULL;
|
||||
pr->outfile.TmpOutFile = NULL;
|
||||
|
||||
// Save file names
|
||||
strncpy(pr->parser.InpFname, f1, MAXFNAME);
|
||||
@@ -172,16 +173,17 @@ int openoutfile(Project *pr)
|
||||
int errcode = 0;
|
||||
|
||||
// Close output file if already opened
|
||||
if (pr->outfile.TmpOutFile != pr->outfile.OutFile &&
|
||||
pr->outfile.TmpOutFile != NULL)
|
||||
{
|
||||
fclose(pr->outfile.TmpOutFile);
|
||||
pr->outfile.TmpOutFile = NULL;
|
||||
}
|
||||
if (pr->outfile.OutFile != NULL)
|
||||
{
|
||||
fclose(pr->outfile.OutFile);
|
||||
pr->outfile.OutFile = NULL;
|
||||
}
|
||||
if (pr->outfile.TmpOutFile != NULL)
|
||||
{
|
||||
fclose(pr->outfile.TmpOutFile);
|
||||
pr->outfile.TmpOutFile = NULL;
|
||||
}
|
||||
|
||||
// If output file name was supplied, then attempt to
|
||||
// open it. Otherwise open a temporary output file.
|
||||
@@ -266,12 +268,6 @@ void initpointers(Project *pr)
|
||||
pr->hydraul.smatrix.NZSUB = NULL;
|
||||
pr->hydraul.smatrix.LNZ = NULL;
|
||||
|
||||
pr->outfile.OutFile = NULL;
|
||||
pr->outfile.HydFile = NULL;
|
||||
pr->outfile.TmpOutFile = NULL;
|
||||
pr->parser.InFile = NULL;
|
||||
pr->report.RptFile = NULL;
|
||||
|
||||
initrules(pr);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,9 @@ int openqual(Project *pr)
|
||||
|
||||
int errcode = 0;
|
||||
int n;
|
||||
|
||||
// Return if no quality analysis requested
|
||||
if (qual->Qualflag == NONE) return errcode;
|
||||
|
||||
// Build nodal adjacency lists if they don't already exist
|
||||
if (net->Adjlist == NULL)
|
||||
@@ -401,12 +404,15 @@ int closequal(Project *pr)
|
||||
Quality *qual = &pr->quality;
|
||||
int errcode = 0;
|
||||
|
||||
if (qual->SegPool) mempool_delete(qual->SegPool);
|
||||
FREE(qual->FirstSeg);
|
||||
FREE(qual->LastSeg);
|
||||
FREE(qual->PipeRateCoeff);
|
||||
FREE(qual->FlowDir);
|
||||
FREE(qual->SortedNodes);
|
||||
if (qual->Qualflag != NONE)
|
||||
{
|
||||
if (qual->SegPool) mempool_delete(qual->SegPool);
|
||||
FREE(qual->FirstSeg);
|
||||
FREE(qual->LastSeg);
|
||||
FREE(qual->PipeRateCoeff);
|
||||
FREE(qual->FlowDir);
|
||||
FREE(qual->SortedNodes);
|
||||
}
|
||||
return errcode;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user