Skip to content

Commit aa1c5a9

Browse files
committed
[LINT] errors 1732 & 1733
1732: new in constructor for class 'Name' which has no assignment operator. 1733: new in constructor for class 'Name' which has no copy constructor. Copy constructors and assignment operators were disabled for classes where memory was "newed", with the few exceptions where the copy constructor was actually needed or in case of a false positive. Signed-off-by: Jocelyn Legault <jocelynlegault@gmail.com>
1 parent 7ffb284 commit aa1c5a9

File tree

9 files changed

+64
-17
lines changed

9 files changed

+64
-17
lines changed

PythonScript/src/ConsoleDialog.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include "PluginInterface.h"
99
#include "Docking.h"
1010

11-
ConsoleDialog::ConsoleDialog()
12-
: DockingDlgInterface(IDD_CONSOLE),
11+
ConsoleDialog::ConsoleDialog() :
12+
DockingDlgInterface(IDD_CONSOLE),
1313
m_data(new tTbData),
1414
m_prompt(">>> "),
1515
m_scintilla(NULL),
@@ -24,6 +24,24 @@ ConsoleDialog::ConsoleDialog()
2424
m_historyIter = m_history.end();
2525
}
2626

27+
ConsoleDialog::ConsoleDialog(const ConsoleDialog& other) :
28+
DockingDlgInterface(IDD_CONSOLE),
29+
m_data(other.m_data ? new tTbData(*other.m_data) : NULL),
30+
m_prompt(other.m_prompt),
31+
m_scintilla(other.m_scintilla),
32+
m_hInput(other.m_hInput),
33+
m_console(other.m_console),
34+
m_originalInputWndProc(other.m_originalInputWndProc),
35+
m_hTabIcon(other.m_hTabIcon),
36+
m_history(other.m_history),
37+
m_historyIter(other.m_historyIter),
38+
m_changes(other.m_changes),
39+
m_currentHistory(other.m_currentHistory),
40+
m_runButtonIsRun(other.m_runButtonIsRun),
41+
m_hContext(other.m_hContext)
42+
{
43+
}
44+
2745
ConsoleDialog::~ConsoleDialog()
2846
{
2947
if (m_scintilla)

PythonScript/src/ConsoleDialog.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class ConsoleDialog : public DockingDlgInterface
1414
{
1515
public:
1616
ConsoleDialog();
17+
ConsoleDialog(const ConsoleDialog& other);
1718
~ConsoleDialog();
1819

1920

@@ -34,6 +35,8 @@ class ConsoleDialog : public DockingDlgInterface
3435
BOOL CALLBACK run_dlgProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
3536

3637
private:
38+
ConsoleDialog& operator = (const ConsoleDialog&); // Disable assignment operator disabled
39+
3740
void createOutputWindow(HWND hParentWindow);
3841
void runStatement();
3942
void stopStatement();

PythonScript/src/CreateWrapper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ def writeCppFile(f,out):
314314
out.write('\tinline size_t size() const { return m_bufferLen; }\n')
315315
out.write('private:\n')
316316
out.write('\tPythonCompatibleStrBuffer(); // default constructor disabled\n')
317+
out.write('\tPythonCompatibleStrBuffer(const PythonCompatibleStrBuffer&); // copy constructor disabled\n')
318+
out.write('\tPythonCompatibleStrBuffer& operator = (const PythonCompatibleStrBuffer&); // Disable assignment operator disabled\n')
317319
out.write('\tsize_t m_bufferLen;\n')
318320
out.write('\tchar* m_bufferPtr;\n')
319321
out.write('};\n')

PythonScript/src/PythonConsole.cpp

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,30 @@
1414
#include "NotepadPlusWrapper.h"
1515

1616
PythonConsole::PythonConsole(HWND hNotepad) :
17-
PyProducerConsumer<std::string>(),
18-
mp_scintillaWrapper(new ScintillaWrapper(NULL)),
19-
mp_mainThreadState(NULL),
20-
m_hThread(NULL),
21-
m_hNotepad(hNotepad),
22-
m_consumerStarted(false),
23-
m_nppData(new NppData)
24-
{
25-
mp_consoleDlg = new ConsoleDialog();
26-
27-
m_statementRunning = CreateEvent(NULL, FALSE, TRUE, NULL);
17+
mp_scintillaWrapper(new ScintillaWrapper(NULL)),
18+
mp_consoleDlg(new ConsoleDialog()),
19+
mp_mainThreadState(NULL),
20+
m_statementRunning(CreateEvent(NULL, FALSE, TRUE, NULL)),
21+
m_hThread(NULL),
22+
m_hNotepad(hNotepad),
23+
m_consumerStarted(false),
24+
m_nppData(new NppData)
25+
{
26+
}
27+
28+
PythonConsole::PythonConsole(const PythonConsole& other) :
29+
mp_scintillaWrapper(other.mp_scintillaWrapper ? new ScintillaWrapper(*other.mp_scintillaWrapper) : NULL),
30+
mp_consoleDlg(other.mp_consoleDlg ? new ConsoleDialog(*other.mp_consoleDlg) : NULL),
31+
m_console(other.m_console),
32+
m_pushFunc(other.m_pushFunc),
33+
m_sys(other.m_sys),
34+
mp_mainThreadState(other.mp_mainThreadState),
35+
m_statementRunning(other.m_statementRunning),
36+
m_hThread(other.m_hThread),
37+
m_hNotepad(other.m_hNotepad),
38+
m_consumerStarted(other.m_consumerStarted),
39+
m_nppData(other.m_nppData ? new NppData(*other.m_nppData) : NULL)
40+
{
2841
}
2942

3043
PythonConsole::~PythonConsole()

PythonScript/src/PythonConsole.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class PythonConsole : public NppPythonScript::PyProducerConsumer<std::string>, p
1919
{
2020
public:
2121
PythonConsole(HWND hNotepad);
22+
PythonConsole(const PythonConsole& other);
2223
~PythonConsole();
2324

2425
void init(HINSTANCE hInst, NppData& nppData);
@@ -70,6 +71,7 @@ class PythonConsole : public NppPythonScript::PyProducerConsumer<std::string>, p
7071

7172
private:
7273
PythonConsole(); // default constructor disabled
74+
PythonConsole& operator = (const PythonConsole&); // assignment operator disabled
7375

7476
ConsoleDialog *mp_consoleDlg;
7577

PythonScript/src/PythonHandler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ class PythonHandler : public NppPythonScript::PyProducerConsumer<RunScriptArgs>
7777

7878
private:
7979
PythonHandler(); // default constructor disabled
80+
PythonHandler(const PythonHandler&); // copy constructor disabled
81+
PythonHandler& operator = (const PythonHandler&); // Disable assignment operator disabled
8082

8183
// Private methods
8284
void initModules();

PythonScript/src/ScintillaCells.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
#include "ScintillaCells.h"
44

5-
ScintillaCells::ScintillaCells(boost::python::str characters, boost::python::list styles)
5+
//lint -e1732 (Info -- new in constructor for class 'ScintillaCells' which has no assignment operator -- Effective C++ #11)
6+
//lint -e1733 (Info -- new in constructor for class 'ScintillaCells' which has no copy constructor -- Effective C++ #11)
7+
// The allocated memory is placed inside a shared_ptr. The default copy constructor and assignment operator will do just fine.
8+
ScintillaCells::ScintillaCells(boost::python::str characters, boost::python::list styles) :
9+
m_length(_len(characters)),
10+
m_cells(new unsigned char[m_length*2])
611
{
7-
m_length = _len(characters);
8-
m_cells.reset(new unsigned char[(m_length)*2]);
912
const char *chrs = boost::python::extract<const char*>(characters);
1013
size_t styleLength = _len(styles);
1114
int style = 0;
@@ -21,6 +24,8 @@ ScintillaCells::ScintillaCells(boost::python::str characters, boost::python::lis
2124
m_cells.get()[(pos*2) + 1] = static_cast<unsigned char>(style);
2225
}
2326
}
27+
//lint +e1732
28+
//lint +e1733
2429

2530
ScintillaCells::~ScintillaCells()
2631
{

PythonScript/src/ScintillaCells.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class ScintillaCells
1313
private:
1414
ScintillaCells(); // default constructor disabled
1515

16-
std::shared_ptr<unsigned char> m_cells;
1716
size_t m_length;
17+
std::shared_ptr<unsigned char> m_cells;
1818
};
1919

2020
#endif

PythonScript/src/ScintillaWrapperGenerated.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class PythonCompatibleStrBuffer
2424
inline size_t size() const { return m_bufferLen; }
2525
private:
2626
PythonCompatibleStrBuffer(); // default constructor disabled
27+
PythonCompatibleStrBuffer(const PythonCompatibleStrBuffer&); // copy constructor disabled
28+
PythonCompatibleStrBuffer& operator = (const PythonCompatibleStrBuffer&); // Disable assignment operator disabled
2729
size_t m_bufferLen;
2830
char* m_bufferPtr;
2931
};

0 commit comments

Comments
 (0)