Commit d6a459c3 authored by hjk's avatar hjk
Browse files

cppmodelmanagerinterface: use singleton instead of object pool

parent 9d72c553
......@@ -96,7 +96,7 @@ CMakeProject::~CMakeProject()
{
// Remove CodeModel support
CPlusPlus::CppModelManagerInterface *modelManager
= ExtensionSystem::PluginManager::instance()->getObject<CPlusPlus::CppModelManagerInterface>();
= CPlusPlus::CppModelManagerInterface::instance();
QMap<QString, CMakeUiCodeModelSupport *>::const_iterator it, end;
it = m_uiCodeModelSupport.constBegin();
end = m_uiCodeModelSupport.constEnd();
......@@ -283,7 +283,7 @@ bool CMakeProject::parseCMakeLists()
allIncludePaths.append(cbpparser.includeFiles());
CPlusPlus::CppModelManagerInterface *modelmanager =
ExtensionSystem::PluginManager::instance()->getObject<CPlusPlus::CppModelManagerInterface>();
CPlusPlus::CppModelManagerInterface::instance();
if (modelmanager) {
CPlusPlus::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
if (pinfo.includePaths != allIncludePaths
......@@ -609,7 +609,7 @@ void CMakeProject::createUiCodeModelSupport()
{
// qDebug()<<"creatUiCodeModelSupport()";
CPlusPlus::CppModelManagerInterface *modelManager
= ExtensionSystem::PluginManager::instance()->getObject<CPlusPlus::CppModelManagerInterface>();
= CPlusPlus::CppModelManagerInterface::instance();
// First move all to
QMap<QString, CMakeUiCodeModelSupport *> oldCodeModelSupport;
......
......@@ -710,16 +710,6 @@ bool currentTextEditorPosition(QString *fileNameIn /* = 0 */,
return !fileName.isEmpty();
}
static CPlusPlus::CppModelManagerInterface *cppModelManager()
{
using namespace CPlusPlus;
static QPointer<CppModelManagerInterface> modelManager;
if (!modelManager.data())
modelManager = ExtensionSystem::PluginManager::instance()->
getObject<CPlusPlus::CppModelManagerInterface>();
return modelManager.data();
}
// Return the Cpp expression, and, if desired, the function
QString cppExpressionAt(TextEditor::ITextEditor *editor, int pos,
int *line, int *column, QString *function /* = 0 */)
......@@ -735,7 +725,7 @@ QString cppExpressionAt(TextEditor::ITextEditor *editor, int pos,
return QByteArray();
QString expr = plaintext->textCursor().selectedText();
CppModelManagerInterface *modelManager = cppModelManager();
CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
if (expr.isEmpty() && modelManager) {
QTextCursor tc(plaintext->document());
tc.setPosition(pos);
......
......@@ -89,12 +89,6 @@ static QString msgClassNotFound(const QString &uiClassName, const QList<Document
return QtCreatorIntegration::tr("The class definition of '%1' could not be found in %2.").arg(uiClassName, files);
}
static inline CppModelManagerInterface *cppModelManagerInstance()
{
return ExtensionSystem::PluginManager::instance()
->getObject<CppModelManagerInterface>();
}
QtCreatorIntegration::QtCreatorIntegration(QDesignerFormEditorInterface *core, FormEditorW *parent) :
qdesigner_internal::QDesignerIntegration(core, ::qobject_cast<QObject*>(parent)),
m_few(parent)
......@@ -259,7 +253,7 @@ static Function *findDeclaration(const Class *cl, const QString &functionName)
// TODO: remove me, this is taken from cppeditor.cpp. Find some common place for this method
static Document::Ptr findDefinition(Function *functionDeclaration, int *line)
{
if (CppModelManagerInterface *cppModelManager = cppModelManagerInstance()) {
if (CppModelManagerInterface *cppModelManager = CppModelManagerInterface::instance()) {
const Snapshot snapshot = cppModelManager->snapshot();
if (Symbol *def = snapshot.findMatchingDefinition(functionDeclaration)) {
......@@ -537,7 +531,7 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
*errorMessage = tr("Internal error: No project could be found for %1.").arg(currentUiFile);
return false;
}
CPlusPlus::Snapshot docTable = cppModelManagerInstance()->snapshot();
CPlusPlus::Snapshot docTable = CppModelManagerInterface::instance()->snapshot();
CPlusPlus::Snapshot newDocTable;
for (CPlusPlus::Snapshot::iterator it = docTable.begin(); it != docTable.end(); ++it) {
......@@ -606,7 +600,8 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
}
} else {
// add function declaration to cl
CppModelManagerInterface::WorkingCopy workingCopy = cppModelManagerInstance()->workingCopy();
CppModelManagerInterface::WorkingCopy workingCopy =
CppModelManagerInterface::instance()->workingCopy();
const QString fileName = doc->fileName();
getParsedDocument(fileName, workingCopy, docTable);
addDeclaration(docTable, fileName, cl, functionNameWithParameterNames);
......
......@@ -204,7 +204,7 @@ void GenericProject::refresh(RefreshOptions options)
m_rootNode->refresh();
CPlusPlus::CppModelManagerInterface *modelManager =
ExtensionSystem::PluginManager::instance()->getObject<CPlusPlus::CppModelManagerInterface>();
CPlusPlus::CppModelManagerInterface::instance();
if (m_toolChain && modelManager) {
const QByteArray predefinedMacros = m_toolChain->predefinedMacros();
......
......@@ -1329,7 +1329,7 @@ Qt4ProFileNode::Qt4ProFileNode(Qt4Project *project,
Qt4ProFileNode::~Qt4ProFileNode()
{
CPlusPlus::CppModelManagerInterface *modelManager
= ExtensionSystem::PluginManager::instance()->getObject<CPlusPlus::CppModelManagerInterface>();
= CPlusPlus::CppModelManagerInterface::instance();
QMap<QString, Qt4UiCodeModelSupport *>::const_iterator it, end;
end = m_uiCodeModelSupport.constEnd();
for (it = m_uiCodeModelSupport.constBegin(); it != end; ++it) {
......@@ -1891,7 +1891,7 @@ QStringList Qt4ProFileNode::updateUiFiles()
}
CPlusPlus::CppModelManagerInterface *modelManager =
ExtensionSystem::PluginManager::instance()->getObject<CPlusPlus::CppModelManagerInterface>();
CPlusPlus::CppModelManagerInterface::instance();
if (!toAdd.isEmpty()) {
foreach (FileNode *file, toAdd) {
......@@ -2193,7 +2193,7 @@ void Qt4ProFileNode::createUiCodeModelSupport()
{
// qDebug()<<"creatUiCodeModelSupport()";
CPlusPlus::CppModelManagerInterface *modelManager
= ExtensionSystem::PluginManager::instance()->getObject<CPlusPlus::CppModelManagerInterface>();
= CPlusPlus::CppModelManagerInterface::instance();
// First move all to
QMap<QString, Qt4UiCodeModelSupport *> oldCodeModelSupport;
......
......@@ -422,8 +422,7 @@ void Qt4Project::updateCppCodeModel()
Qt4BuildConfiguration *activeBC = activeTarget()->activeBuildConfiguration();
CPlusPlus::CppModelManagerInterface *modelmanager =
ExtensionSystem::PluginManager::instance()
->getObject<CPlusPlus::CppModelManagerInterface>();
CPlusPlus::CppModelManagerInterface::instance();
if (!modelmanager)
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment