"New Class" wizard: Check custom base class for QObject parent

That is, if the user specifies a custom base class, we check whether its
constructor takes a "QObject *parent" parameter, and if it does, we give
the derived class one as well.
This is technically a heuristic, but the pattern is pretty stable in the
Qt world.

Fixes: QTCREATORBUG-25156
Change-Id: Ie64440929df61cca7258d6d692c5de62970f9a65
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2021-01-15 16:55:26 +01:00
parent aae3bf4ef7
commit e735e95f06
7 changed files with 113 additions and 5 deletions

View File

@@ -42,6 +42,7 @@
#include "cpprefactoringchanges.h"
#include "cpprefactoringengine.h"
#include "cppsourceprocessor.h"
#include "cpptoolsjsextension.h"
#include "cpptoolsplugin.h"
#include "cpptoolsconstants.h"
#include "cpptoolsreuse.h"
@@ -54,6 +55,7 @@
#include <coreplugin/documentmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/jsexpander.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/vcsmanager.h>
#include <cplusplus/ASTPath.h>
@@ -575,6 +577,13 @@ CppModelManager *CppModelManager::instance()
return m_instance;
}
void CppModelManager::registerJsExtension()
{
Core::JsExpander::registerGlobalObject("Cpp", [this] {
return new CppToolsJsExtension(&d->m_locatorData);
});
}
void CppModelManager::initCppTools()
{
// Objects