QtAutogen: Improved error handling

This commit is contained in:
Sebastian Holtermann
2016-11-30 21:17:38 +01:00
committed by Brad King
parent 00750ece6a
commit 7731121d66
2 changed files with 32 additions and 18 deletions

View File

@@ -515,10 +515,15 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
this->LogInfo(err.str());
}
if (this->MocRelaxedMode) {
this->ParseCppFile(absFilename, headerExtensions, includedMocs, uiFiles);
if (!this->ParseCppFile(absFilename, headerExtensions, includedMocs,
uiFiles)) {
return false;
}
} else {
this->StrictParseCppFile(absFilename, headerExtensions, includedMocs,
uiFiles);
if (!this->StrictParseCppFile(absFilename, headerExtensions,
includedMocs, uiFiles)) {
return false;
}
}
this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles);
}
@@ -568,7 +573,10 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
return true;
}
void cmQtAutoGenerators::ParseCppFile(
/**
* @return True on success
*/
bool cmQtAutoGenerators::ParseCppFile(
const std::string& absFilename,
const std::vector<std::string>& headerExtensions,
std::map<std::string, std::string>& includedMocs,
@@ -584,11 +592,11 @@ void cmQtAutoGenerators::ParseCppFile(
err << "AUTOGEN: warning: " << absFilename << ": file is empty\n"
<< std::endl;
this->LogWarning(err.str());
return;
return true;
}
this->ParseForUic(absFilename, contentsString, includedUis);
if (this->MocExecutable.empty()) {
return;
return true;
}
const std::string absPath = cmsys::SystemTools::GetFilenamePath(
@@ -652,7 +660,7 @@ void cmQtAutoGenerators::ParseCppFile(
<< std::endl;
}
this->LogError(err.str());
::exit(EXIT_FAILURE);
return false;
}
} else {
std::string fileToMoc = absFilename;
@@ -700,7 +708,7 @@ void cmQtAutoGenerators::ParseCppFile(
"header.\n"
<< std::endl;
this->LogError(err.str());
::exit(EXIT_FAILURE);
return false;
}
} else {
dotMocIncluded = true;
@@ -744,13 +752,17 @@ void cmQtAutoGenerators::ParseCppFile(
<< "\"" << scannedFileBasename << ".moc\" !\n"
<< std::endl;
this->LogError(err.str());
::exit(EXIT_FAILURE);
return false;
}
}
return true;
}
void cmQtAutoGenerators::StrictParseCppFile(
/**
* @return True on success
*/
bool cmQtAutoGenerators::StrictParseCppFile(
const std::string& absFilename,
const std::vector<std::string>& headerExtensions,
std::map<std::string, std::string>& includedMocs,
@@ -766,11 +778,11 @@ void cmQtAutoGenerators::StrictParseCppFile(
err << "AUTOGEN: warning: " << absFilename << ": file is empty\n"
<< std::endl;
this->LogWarning(err.str());
return;
return true;
}
this->ParseForUic(absFilename, contentsString, includedUis);
if (this->MocExecutable.empty()) {
return;
return true;
}
const std::string absPath = cmsys::SystemTools::GetFilenamePath(
@@ -823,7 +835,7 @@ void cmQtAutoGenerators::StrictParseCppFile(
<< std::endl;
}
this->LogError(err.str());
::exit(EXIT_FAILURE);
return false;
}
} else {
if (basename != scannedFileBasename) {
@@ -839,7 +851,7 @@ void cmQtAutoGenerators::StrictParseCppFile(
"moc on this source file.\n"
<< std::endl;
this->LogError(err.str());
::exit(EXIT_FAILURE);
return false;
}
dotMocIncluded = true;
includedMocs[absFilename] = currentMoc;
@@ -861,8 +873,10 @@ void cmQtAutoGenerators::StrictParseCppFile(
<< "\"" << scannedFileBasename << ".moc\" !\n"
<< std::endl;
this->LogError(err.str());
::exit(EXIT_FAILURE);
return false;
}
return true;
}
void cmQtAutoGenerators::ParseForUic(

View File

@@ -43,12 +43,12 @@ private:
bool GenerateQrc(const std::string& qrcInputFile,
const std::string& qrcOutputFile, bool unique_n);
void ParseCppFile(
bool ParseCppFile(
const std::string& absFilename,
const std::vector<std::string>& headerExtensions,
std::map<std::string, std::string>& includedMocs,
std::map<std::string, std::vector<std::string> >& includedUis);
void StrictParseCppFile(
bool StrictParseCppFile(
const std::string& absFilename,
const std::vector<std::string>& headerExtensions,
std::map<std::string, std::string>& includedMocs,