Skip to content

Commit dabcb2e

Browse files
committed
Spreadsheet: Fixes for coverity defects Feb 2025
1 parent c4a4ce3 commit dabcb2e

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

src/Mod/Spreadsheet/App/Cell.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ void Cell::setDisplayUnit(const std::string& unit)
543543
if (newDisplayUnit != displayUnit) {
544544
PropertySheet::AtomicPropertyChange signaller(*owner);
545545

546-
displayUnit = newDisplayUnit;
546+
displayUnit = std::move(newDisplayUnit);
547547
setUsed(DISPLAY_UNIT_SET, !displayUnit.isEmpty());
548548
setDirty();
549549

src/Mod/Spreadsheet/App/DisplayUnit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class DisplayUnit
3939
explicit DisplayUnit(const std::string _stringRep = "",
4040
const Base::Unit _unit = Base::Unit(),
4141
double _scaler = 0.0)
42-
: stringRep(_stringRep)
42+
: stringRep(std::move(_stringRep))
4343
, unit(_unit)
4444
, scaler(_scaler)
4545
{}

src/Mod/Spreadsheet/App/PropertySheet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ void PropertySheet::setAlias(CellAddress address, const std::string& alias)
787787
App::ObjectIdentifier key(owner, oldAlias);
788788
App::ObjectIdentifier value(owner, alias.empty() ? address.toString() : alias);
789789

790-
m[key] = value;
790+
m[key] = std::move(value);
791791

792792
owner->getDocument()->renameObjectIdentifiers(m);
793793
}
@@ -1397,7 +1397,7 @@ void PropertySheet::addDependencies(CellAddress key)
13971397

13981398
// Insert into maps
13991399
propertyNameToCellMap[propName].insert(key);
1400-
cellToPropertyNameMap[key].insert(propName);
1400+
cellToPropertyNameMap[key].insert(std::move(propName));
14011401
}
14021402
}
14031403
}

src/Mod/Spreadsheet/App/Sheet.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,15 @@ Sheet::Sheet()
104104

105105
Sheet::~Sheet()
106106
{
107-
clearAll();
107+
try {
108+
clearAll();
109+
}
110+
catch (boost::wrapexcept<boost::regex_error>&) {
111+
// Don't let an exception propagate out of a destructor (calls terminate())
112+
Base::Console().Error(
113+
"clearAll() resulted in an exception when deleting the spreadsheet : %s\n",
114+
*pcNameInDocument);
115+
}
108116
}
109117

110118
/**

src/Mod/Spreadsheet/Gui/DlgBindSheet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void DlgBindSheet::accept()
191191
addr = std::string("<<") + copy + ">>";
192192
}
193193
else {
194-
addr = copy;
194+
addr = std::move(copy);
195195
}
196196
};
197197

src/Mod/Spreadsheet/Gui/ZoomableView.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public Q_SLOTS:
6868

6969
QPointer<SpreadsheetGui::SheetTableView> stv;
7070
QGraphicsScene m_scene;
71-
QGraphicsProxyWidget* qpw;
71+
QGraphicsProxyWidget* qpw {nullptr};
7272

73-
int m_zoomLevel;
73+
int m_zoomLevel {100};
7474

7575
protected:
7676
void focusOutEvent(QFocusEvent* event) override;

0 commit comments

Comments
 (0)