App: modernize C++11
* use nullptr
This commit is contained in:
@@ -207,7 +207,7 @@ init_freecad_base_module(void)
|
||||
static struct PyModuleDef BaseModuleDef = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"__FreeCADBase__", Base_doc, -1,
|
||||
NULL, NULL, NULL, NULL, NULL
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr
|
||||
};
|
||||
return PyModule_Create(&BaseModuleDef);
|
||||
}
|
||||
@@ -222,13 +222,13 @@ init_freecad_module(void)
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"FreeCAD", FreeCAD_doc, -1,
|
||||
__AppMethods,
|
||||
NULL, NULL, NULL, NULL
|
||||
nullptr, nullptr, nullptr, nullptr
|
||||
};
|
||||
return PyModule_Create(&FreeCADModuleDef);
|
||||
}
|
||||
|
||||
Application::Application(std::map<std::string,std::string> &mConfig)
|
||||
: _mConfig(mConfig), _pActiveDoc(0), _isRestoring(false),_allowPartial(false)
|
||||
: _mConfig(mConfig), _pActiveDoc(nullptr), _isRestoring(false),_allowPartial(false)
|
||||
, _isClosingAll(false), _objCount(-1), _activeTransactionID(0)
|
||||
, _activeTransactionGuard(0), _activeTransactionTmpName(false)
|
||||
{
|
||||
@@ -531,7 +531,7 @@ bool Application::closeDocument(const char* name)
|
||||
|
||||
// For exception-safety use a smart pointer
|
||||
if (_pActiveDoc == pos->second)
|
||||
setActiveDocument((Document*)0);
|
||||
setActiveDocument(static_cast<Document*>(nullptr));
|
||||
std::unique_ptr<Document> delDoc (pos->second);
|
||||
DocMap.erase( pos );
|
||||
DocFileMap.erase(FileInfo(delDoc->FileName.getValue()).filePath());
|
||||
@@ -559,7 +559,7 @@ App::Document* Application::getDocument(const char *Name) const
|
||||
pos = DocMap.find(Name);
|
||||
|
||||
if (pos == DocMap.end())
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
return pos->second;
|
||||
}
|
||||
@@ -570,7 +570,7 @@ const char * Application::getDocumentName(const App::Document* doc) const
|
||||
if (it->second == doc)
|
||||
return it->first.c_str();
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<App::Document*> Application::getDocuments() const
|
||||
@@ -667,10 +667,10 @@ public:
|
||||
|
||||
Document* Application::openDocument(const char * FileName, bool createView) {
|
||||
std::vector<std::string> filenames(1,FileName);
|
||||
auto docs = openDocuments(filenames,0,0,0,createView);
|
||||
auto docs = openDocuments(filenames, nullptr, nullptr, nullptr, createView);
|
||||
if(docs.size())
|
||||
return docs.front();
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Document *Application::getDocumentByPath(const char *path, PathMatchMode checkCanonical) const {
|
||||
@@ -767,7 +767,7 @@ std::vector<Document*> Application::openDocuments(const std::vector<std::string>
|
||||
DocTiming timing;
|
||||
|
||||
const char *path = name.c_str();
|
||||
const char *label = 0;
|
||||
const char *label = nullptr;
|
||||
if (isMainDoc) {
|
||||
if (paths && paths->size()>count)
|
||||
path = (*paths)[count].c_str();
|
||||
@@ -959,17 +959,17 @@ Document* Application::openDocumentPrivate(const char * FileName,
|
||||
}
|
||||
}
|
||||
if(!reopen)
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(doc) {
|
||||
_pendingDocsReopen.emplace_back(FileName);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isMainDoc)
|
||||
return 0;
|
||||
return nullptr;
|
||||
else if(doc)
|
||||
return doc;
|
||||
}
|
||||
@@ -1042,7 +1042,7 @@ void Application::setActiveDocument(const char *Name)
|
||||
{
|
||||
// If no active document is set, resort to a default.
|
||||
if (*Name == '\0') {
|
||||
_pActiveDoc = 0;
|
||||
_pActiveDoc = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1215,7 +1215,7 @@ ParameterManager * Application::GetParameterSet(const char* sName) const
|
||||
if ( it != mpcPramManager.end() )
|
||||
return it->second;
|
||||
else
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::map<std::string,ParameterManager *> & Application::GetParameterSetList(void) const
|
||||
@@ -1612,7 +1612,7 @@ void Application::slotChangePropertyEditor(const App::Document &doc, const App::
|
||||
//**************************************************************************
|
||||
// Init, Destruct and singleton
|
||||
|
||||
Application * Application::_pcSingleton = 0;
|
||||
Application * Application::_pcSingleton = nullptr;
|
||||
|
||||
int Application::_argc;
|
||||
char ** Application::_argv;
|
||||
@@ -1662,8 +1662,8 @@ void Application::destruct(void)
|
||||
}
|
||||
|
||||
paramMgr.clear();
|
||||
_pcSysParamMngr = 0;
|
||||
_pcUserParamMngr = 0;
|
||||
_pcSysParamMngr = nullptr;
|
||||
_pcUserParamMngr = nullptr;
|
||||
|
||||
#ifdef FC_DEBUG
|
||||
// Do this only in debug mode for memory leak checkers
|
||||
@@ -1690,12 +1690,12 @@ void Application::destructObserver(void)
|
||||
if ( _pConsoleObserverFile ) {
|
||||
Console().DetachObserver(_pConsoleObserverFile);
|
||||
delete _pConsoleObserverFile;
|
||||
_pConsoleObserverFile = 0;
|
||||
_pConsoleObserverFile = nullptr;
|
||||
}
|
||||
if ( _pConsoleObserverStd ) {
|
||||
Console().DetachObserver(_pConsoleObserverStd);
|
||||
delete _pConsoleObserverStd;
|
||||
_pConsoleObserverStd = 0;
|
||||
_pConsoleObserverStd = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1741,12 +1741,12 @@ void printBacktrace(size_t skip=0)
|
||||
char **symbols = backtrace_symbols(callstack, nFrames);
|
||||
|
||||
for (size_t i = skip; i < nFrames; i++) {
|
||||
char *demangled = NULL;
|
||||
char *demangled = nullptr;
|
||||
int status = -1;
|
||||
Dl_info info;
|
||||
if (dladdr(callstack[i], &info) && info.dli_sname && info.dli_fname) {
|
||||
if (info.dli_sname[0] == '_') {
|
||||
demangled = abi::__cxa_demangle(info.dli_sname, NULL, 0, &status);
|
||||
demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2483,7 +2483,7 @@ void Application::initConfig(int argc, char ** argv)
|
||||
Console().AttachObserver(_pConsoleObserverFile);
|
||||
}
|
||||
else
|
||||
_pConsoleObserverFile = 0;
|
||||
_pConsoleObserverFile = nullptr;
|
||||
|
||||
// Banner ===========================================================
|
||||
if (!(mConfig["RunMode"] == "Cmd")) {
|
||||
@@ -2629,7 +2629,7 @@ void Application::initApplication(void)
|
||||
}
|
||||
|
||||
// seed randomizer
|
||||
srand(time(0));
|
||||
srand(time(nullptr));
|
||||
}
|
||||
|
||||
std::list<std::string> Application::getCmdLineFiles()
|
||||
|
||||
Reference in New Issue
Block a user