Try Clazy fix-its

clazy is a compiler plugin which allows clang to understand Qt
semantics. You get more than 50 Qt related compiler warnings, ranging
from unneeded memory allocations to misusage of API, including fix-its
for automatic refactoring.

https://invent.kde.org/sdk/clazy
This commit is contained in:
Laurent Trinques
2025-02-14 15:52:23 +01:00
parent adcf77e34a
commit dba7caed30
88 changed files with 512 additions and 409 deletions

View File

@@ -55,7 +55,8 @@ DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand(
//When removing a deti we must know its parent item, for re-adding deti as child of the parent
//when undoing this command
for(DynamicElementTextItem *deti : m_removed_contents.m_element_texts)
for (DynamicElementTextItem* deti :
std::as_const(m_removed_contents.m_element_texts))
{
if(deti->parentGroup())
m_grp_texts_hash.insert(deti, deti->parentGroup());
@@ -73,7 +74,9 @@ DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand(
}
//The deletion of the groups is not managed by this undo, but by a RemoveTextsGroupCommand
for(ElementTextItemGroup *group : m_removed_contents.m_texts_groups) {
for (ElementTextItemGroup* group :
std::as_const(m_removed_contents.m_texts_groups))
{
new RemoveTextsGroupCommand(group->parentElement(), group, this);
}
@@ -81,7 +84,7 @@ DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand(
setPotentialsOfRemovedElements();
//Get all linkeds table of removed table.
for (auto table : m_removed_contents.m_tables)
for (auto table : std::as_const(m_removed_contents.m_tables))
{
//Table is already managed, jump to next loop
if (m_table_scene_hash.keys().contains(table))
@@ -122,7 +125,7 @@ DeleteQGraphicsItemCommand::~DeleteQGraphicsItemCommand()
*/
void DeleteQGraphicsItemCommand::setPotentialsOfRemovedElements()
{
for (Element *elmt : m_removed_contents.m_elements)
for (Element* elmt : std::as_const(m_removed_contents.m_elements))
{
//a list of terminals who have at least two conductors docked in.
QList<Terminal *> terminals_list;
@@ -179,7 +182,8 @@ void DeleteQGraphicsItemCommand::setPotentialsOfRemovedElements()
//If a conductor was already created between these two terminals
//in this undo command, from another removed element, we do nothing
bool exist_ = false;
for (QPair<Terminal *, Terminal *> pair : m_connected_terminals)
for (QPair<Terminal*, Terminal*> pair :
std::as_const(m_connected_terminals))
{
if (pair.first == hub_terminal && pair.second == t) {
exist_ = true;
@@ -226,7 +230,7 @@ Terminal *DeleteQGraphicsItemCommand::terminalInSamePotential(
{
QList<Conductor *> conductor_list = terminal->conductors();
conductor_list.removeAll(conductor_to_exclude);
for(Conductor *c : conductor_list)
for (Conductor* c : std::as_const(conductor_list))
{
Terminal *other_terminal = c->terminal1 == terminal ? c->terminal2 : c->terminal1;
if(!m_removed_contents.items(DiagramContent::Elements).contains(other_terminal->parentElement())) {
@@ -234,7 +238,7 @@ Terminal *DeleteQGraphicsItemCommand::terminalInSamePotential(
}
}
//No one of direct conductor of terminal are docked to an element which is not removed
for(Conductor *c : conductor_list)
for (Conductor* c : std::as_const(conductor_list))
{
Terminal *other_terminal = c->terminal1 == terminal ? c->terminal2 : c->terminal1;
Terminal *terminal_to_return = terminalInSamePotential(other_terminal, c);
@@ -258,11 +262,12 @@ void DeleteQGraphicsItemCommand::undo()
m_diagram->addItem(item);
//We relink element after every element was added to diagram
for(Element *e : m_removed_contents.m_elements)
for (Element* e : std::as_const(m_removed_contents.m_elements))
for(Element *elmt : m_link_hash[e])
e->linkToElement(elmt);
for(DynamicElementTextItem *deti : m_removed_contents.m_element_texts)
for (DynamicElementTextItem* deti :
std::as_const(m_removed_contents.m_element_texts))
{
if(m_elmt_text_hash.keys().contains(deti))
m_elmt_text_hash.value(deti)->addDynamicTextItem(deti);
@@ -307,14 +312,15 @@ void DeleteQGraphicsItemCommand::redo()
}
}
for(Element *e : m_removed_contents.m_elements)
for (Element* e : std::as_const(m_removed_contents.m_elements))
{
//Get linked element, for relink it at undo
if (!e->linkedElements().isEmpty())
m_link_hash.insert(e, e->linkedElements());
}
for(DynamicElementTextItem *deti : m_removed_contents.m_element_texts)
for (DynamicElementTextItem* deti :
std::as_const(m_removed_contents.m_element_texts))
{
if(deti->parentGroup() && deti->parentGroup()->parentElement())
deti->parentGroup()->parentElement()->removeTextFromGroup(deti, deti->parentGroup());