Fix FP leakNoVarFunctionCall with Qt object (#4272)

* Add missing <leak-ignore/>, test

* Fix qt.cfg, format

* Fix FP leakNoVarFunctionCall

* Format

* Delete memory, rule of five

* Missing include

* Avoid dependency

* explicit

* Fix Qt test case

* Fix typo

* Fix

* Add Q_OBJECT
This commit is contained in:
chrchr-github 2022-07-13 21:09:53 +02:00 committed by GitHub
parent bc58f55c6e
commit 2c7d98626a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 1 deletions

View File

@ -383,6 +383,7 @@
<!-- QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type = Qt::AutoConnection) // static -->
<function name="connect,QObject::connect">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
@ -414,6 +415,7 @@
<!-- bool QObject::disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) // static -->
<function name="disconnect,QObject::disconnect">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
@ -445,6 +447,7 @@
<function name="QMenu::addAction">
<noreturn>false</noreturn>
<returnValue type="QAction *"/>
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<not-bool/>

View File

@ -112,4 +112,5 @@ HelpDialog::HelpDialog(QWidget *parent) :
HelpDialog::~HelpDialog()
{
delete mUi;
delete mHelpEngine;
}

View File

@ -33,6 +33,10 @@ namespace Ui {
class HelpBrowser : public QTextBrowser {
public:
explicit HelpBrowser(QWidget* parent = nullptr) : QTextBrowser(parent), mHelpEngine(nullptr) {}
HelpBrowser(const HelpBrowser&) = delete;
HelpBrowser(HelpBrowser&&) = delete;
HelpBrowser& operator=(const HelpBrowser&) = delete;
HelpBrowser& operator=(HelpBrowser&&) = delete;
void setHelpEngine(QHelpEngine *helpEngine);
QVariant loadResource(int type, const QUrl& name) override;
private:

View File

@ -1027,7 +1027,10 @@ void CheckMemoryLeakNoVar::checkForUnreleasedInputArgument(const Scope *scope)
break;
arg = arg->astOperand1();
}
if (getAllocationType(arg, 0) == No)
const AllocType alloc = getAllocationType(arg, 0);
if (alloc == No)
continue;
if ((alloc == New || alloc == NewArray) && arg->next() && !(arg->next()->isStandardType() || mSettings->library.detectContainerOrIterator(arg)))
continue;
if (isReopenStandardStream(arg))
continue;

View File

@ -470,3 +470,20 @@ void nullPointer(int * pIntPtr)
*pIntPtr = 3;
}
}
namespace {
class C : public QObject {
Q_OBJECT
public:
explicit C(QObject* parent = nullptr) : QObject(parent) {}
void signal() {}
};
class D : public QObject {
Q_OBJECT
public:
D() {
connect(new C(this), &C::signal, this, &D::slot);
}
void slot() {};
};
}