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 --> <!-- 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"> <function name="connect,QObject::connect">
<noreturn>false</noreturn> <noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1" direction="in"> <arg nr="1" direction="in">
<not-null/> <not-null/>
<not-uninit/> <not-uninit/>
@ -414,6 +415,7 @@
<!-- bool QObject::disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) // static --> <!-- bool QObject::disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) // static -->
<function name="disconnect,QObject::disconnect"> <function name="disconnect,QObject::disconnect">
<noreturn>false</noreturn> <noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1" direction="in"> <arg nr="1" direction="in">
<not-null/> <not-null/>
<not-uninit/> <not-uninit/>
@ -445,6 +447,7 @@
<function name="QMenu::addAction"> <function name="QMenu::addAction">
<noreturn>false</noreturn> <noreturn>false</noreturn>
<returnValue type="QAction *"/> <returnValue type="QAction *"/>
<leak-ignore/>
<arg nr="1" direction="in"> <arg nr="1" direction="in">
<not-uninit/> <not-uninit/>
<not-bool/> <not-bool/>

View File

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

View File

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

View File

@ -1027,7 +1027,10 @@ void CheckMemoryLeakNoVar::checkForUnreleasedInputArgument(const Scope *scope)
break; break;
arg = arg->astOperand1(); 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; continue;
if (isReopenStandardStream(arg)) if (isReopenStandardStream(arg))
continue; continue;

View File

@ -470,3 +470,20 @@ void nullPointer(int * pIntPtr)
*pIntPtr = 3; *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() {};
};
}