From 90b389035e807f1f4943adafdd186eda17278728 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Tue, 14 Apr 2020 23:46:42 +0200 Subject: [PATCH] Several small code improvements --- .travis.yml | 2 +- examples/7segment.cpp | 2 +- examples/background-color.cpp | 2 +- examples/calculator.cpp | 4 +- examples/checklist.cpp | 2 +- examples/keyboard.cpp | 2 +- examples/listbox.cpp | 2 +- examples/listview.cpp | 2 +- examples/mandelbrot.cpp | 2 +- examples/menu.cpp | 2 +- examples/mouse.cpp | 6 +- examples/rotozoomer.cpp | 2 +- examples/scrollview.cpp | 4 +- examples/string-operations.cpp | 6 +- examples/term-attributes.cpp | 29 +++++----- examples/termcap.cpp | 4 +- examples/timer.cpp | 2 +- examples/transparent.cpp | 9 +-- examples/treeview.cpp | 9 ++- examples/ui.cpp | 14 ++--- examples/watch.cpp | 2 +- examples/windows.cpp | 12 ++-- src/fapplication.cpp | 12 +++- src/fbutton.cpp | 5 +- src/fcombobox.cpp | 2 +- src/flistview.cpp | 38 +++++++++++++ src/foptimove.cpp | 7 ++- src/frect.cpp | 43 +++++++------- src/fwidget_functions.cpp | 6 +- src/include/final/flistview.h | 4 ++ src/include/final/fvterm.h | 77 +++++++++++++++++++------ src/include/final/fwidget.h | 95 ++++++++++++++++++++++++------- src/include/final/sgr_optimizer.h | 6 +- 33 files changed, 291 insertions(+), 125 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0ab7bd2e..f7b5d2a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -100,7 +100,7 @@ matrix: - bash <(curl -s https://codecov.io/bash) # - # sonarcloud + # SonarCloud # - os: linux env: diff --git a/examples/7segment.cpp b/examples/7segment.cpp index 4d69f59d..81f83237 100644 --- a/examples/7segment.cpp +++ b/examples/7segment.cpp @@ -36,7 +36,7 @@ using finalcut::FSize; // class SegmentView //---------------------------------------------------------------------- -class SegmentView : public finalcut::FDialog +class SegmentView final : public finalcut::FDialog { public: explicit SegmentView (finalcut::FWidget* = nullptr); diff --git a/examples/background-color.cpp b/examples/background-color.cpp index ab8e4809..37b4670b 100644 --- a/examples/background-color.cpp +++ b/examples/background-color.cpp @@ -34,7 +34,7 @@ using finalcut::FSize; // class Background //---------------------------------------------------------------------- -class Background : public finalcut::FDialog +class Background final : public finalcut::FDialog { public: // Typedef diff --git a/examples/calculator.cpp b/examples/calculator.cpp index 9ada2b07..87c62951 100644 --- a/examples/calculator.cpp +++ b/examples/calculator.cpp @@ -42,7 +42,7 @@ constexpr lDouble PI{3.141592653589793238L}; // class Button //---------------------------------------------------------------------- -class Button : public finalcut::FButton +class Button final : public finalcut::FButton { public: // Constructor @@ -106,7 +106,7 @@ void Button::onKeyPress (finalcut::FKeyEvent* ev) // class Calc //---------------------------------------------------------------------- -class Calc : public finalcut::FDialog +class Calc final : public finalcut::FDialog { public: // Constructor diff --git a/examples/checklist.cpp b/examples/checklist.cpp index 39ba3f52..65380a59 100644 --- a/examples/checklist.cpp +++ b/examples/checklist.cpp @@ -36,7 +36,7 @@ using finalcut::FSize; // class CheckList //---------------------------------------------------------------------- -class CheckList : public finalcut::FDialog +class CheckList final : public finalcut::FDialog { public: // Constructor diff --git a/examples/keyboard.cpp b/examples/keyboard.cpp index 077918cf..705d3efe 100644 --- a/examples/keyboard.cpp +++ b/examples/keyboard.cpp @@ -26,7 +26,7 @@ // class Keyboard //---------------------------------------------------------------------- -class Keyboard : public finalcut::FWidget +class Keyboard final : public finalcut::FWidget { public: // Constructor diff --git a/examples/listbox.cpp b/examples/listbox.cpp index 38eb83a5..332a0c12 100644 --- a/examples/listbox.cpp +++ b/examples/listbox.cpp @@ -76,7 +76,7 @@ FString& mapToString ( std::map(L"wchar_t*"); + wchar_t* wchar_str{const_cast(L"wchar_t*")}; + streamer3 << wchar_str; std::cout << " stream in: " << streamer3 << std::endl; // ...from c++ string @@ -132,7 +133,8 @@ void streamingIntoFStringExample() // ...from c-string finalcut::FString streamer5; - streamer5 << const_cast("char*"); + char* char_str{C_STR("char*")}; + streamer5 << char_str; std::cout << " stream in: " << streamer5 << std::endl; // ...from wide character diff --git a/examples/term-attributes.cpp b/examples/term-attributes.cpp index 03ba743e..0a51b62c 100644 --- a/examples/term-attributes.cpp +++ b/examples/term-attributes.cpp @@ -34,7 +34,7 @@ using finalcut::FColorPair; // class AttribDlg //---------------------------------------------------------------------- -class AttribDlg : public finalcut::FDialog +class AttribDlg final : public finalcut::FDialog { public: // Constructor @@ -200,7 +200,7 @@ void AttribDlg::adjustSize() // class AttribDemo //---------------------------------------------------------------------- -class AttribDemo : public finalcut::FWidget +class AttribDemo final : public finalcut::FWidget { public: // Constructor @@ -425,19 +425,18 @@ void AttribDemo::draw() const std::vector > effect { - [&] { printDim(); }, - [&] { printNormal(); }, - [&] { printBold(); }, - [&] { printBoldDim(); }, - [&] { printItalic(); }, - [&] { printUnderline(); }, - [&] { printDblUnderline(); }, - [&] { printCrossesOut(); }, - [&] { printBlink(); }, - [&] { printReverse(); }, - [&] { printStandout(); }, - [&] { printInvisible(); }, - [&] { printProtected(); }, + [this] { printNormal(); }, + [this] { printBold(); }, + [this] { printBoldDim(); }, + [this] { printItalic(); }, + [this] { printUnderline(); }, + [this] { printDblUnderline(); }, + [this] { printCrossesOut(); }, + [this] { printBlink(); }, + [this] { printReverse(); }, + [this] { printStandout(); }, + [this] { printInvisible(); }, + [this] { printProtected(); }, }; for (std::size_t y{0}; y < getParentWidget()->getHeight() - 7; y++) diff --git a/examples/termcap.cpp b/examples/termcap.cpp index 46c05e89..ecd9b647 100644 --- a/examples/termcap.cpp +++ b/examples/termcap.cpp @@ -237,7 +237,9 @@ void debug (finalcut::FApplication& TermApp) } #else void debug (finalcut::FApplication&) -{ } +{ + // FINAL CUT was compiled without debug option +} #endif //---------------------------------------------------------------------- diff --git a/examples/timer.cpp b/examples/timer.cpp index 834e5d71..a041d0c6 100644 --- a/examples/timer.cpp +++ b/examples/timer.cpp @@ -29,7 +29,7 @@ namespace fc = finalcut::fc; // class Timer //---------------------------------------------------------------------- -class Timer : public finalcut::FWidget +class Timer final : public finalcut::FWidget { public: // Constructor diff --git a/examples/transparent.cpp b/examples/transparent.cpp index ab4ca1dc..01bca28f 100644 --- a/examples/transparent.cpp +++ b/examples/transparent.cpp @@ -33,7 +33,7 @@ using finalcut::FStyle; // class Transparent //---------------------------------------------------------------------- -class Transparent : public finalcut::FDialog +class Transparent final : public finalcut::FDialog { public: // Typedef and Enumeration @@ -74,6 +74,7 @@ Transparent::Transparent ( finalcut::FWidget* parent : finalcut::FDialog(parent) , type(tt) { + // Set statusbar text for this window setStatusbarMessage("Press Q to quit"); } @@ -139,7 +140,7 @@ void Transparent::onKeyPress (finalcut::FKeyEvent* ev) // class MainWindow //---------------------------------------------------------------------- -class MainWindow : public finalcut::FDialog +class MainWindow final : public finalcut::FDialog { public: // Constructor @@ -212,8 +213,8 @@ MainWindow::MainWindow (finalcut::FWidget* parent) ibg->setGeometry (FPoint(42, 3), FSize(29, 7)); ibg->unsetTransparentShadow(); - // Statusbar at the bottom - status_bar.setMessage("Press Q to quit"); + // Set statusbar text for this window + setStatusbarMessage("Press Q to quit"); unsetTransparentShadow(); activateDialog(); diff --git a/examples/treeview.cpp b/examples/treeview.cpp index b7bb2799..d83e8672 100644 --- a/examples/treeview.cpp +++ b/examples/treeview.cpp @@ -66,6 +66,7 @@ bool sortAscending ( const finalcut::FObject* lhs const sInt64 r_number = StringToNumber(r_item->getText(column)); return bool( l_number < r_number ); // lhs < rhs } + case 3: { std::setlocale(LC_NUMERIC, "C"); @@ -73,6 +74,9 @@ bool sortAscending ( const finalcut::FObject* lhs const double r_number = r_item->getText(column).toDouble(); return bool( l_number < r_number ); // lhs < rhs } + + default: + break; // Don't do anything } return false; @@ -102,6 +106,9 @@ bool sortDescending ( const finalcut::FObject* lhs const double r_number = r_item->getText(column).toDouble(); return bool( l_number > r_number ); // lhs > rhs } + + default: + break; // Don't do anything } return false; @@ -112,7 +119,7 @@ bool sortDescending ( const finalcut::FObject* lhs // class Treeview //---------------------------------------------------------------------- -class Treeview : public finalcut::FDialog +class Treeview final : public finalcut::FDialog { public: // Constructor diff --git a/examples/ui.cpp b/examples/ui.cpp index 824413cb..ad7f0ad5 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -38,20 +38,20 @@ using finalcut::FSize; // class ProgressDialog //---------------------------------------------------------------------- -class ProgressDialog : public finalcut::FDialog +class ProgressDialog final : public finalcut::FDialog { public: // Constructor explicit ProgressDialog (finalcut::FWidget* = nullptr); - // Disable copy constructor - ProgressDialog (const ProgressDialog&) = delete; + // Copy constructor + ProgressDialog (const ProgressDialog&) = default; // Destructor ~ProgressDialog() override; - // Disable assignment operator (=) - ProgressDialog& operator = (const ProgressDialog&) = delete; + // Assignment operator (=) + ProgressDialog& operator = (const ProgressDialog&) = default; private: // Event handlers @@ -181,7 +181,7 @@ void ProgressDialog::cb_exit_bar (const finalcut::FWidget*, const FDataPtr) // class TextWindow //---------------------------------------------------------------------- -class TextWindow : public finalcut::FDialog +class TextWindow final : public finalcut::FDialog { public: // Constructor @@ -247,7 +247,7 @@ void TextWindow::adjustSize() // class MyDialog //---------------------------------------------------------------------- -class MyDialog : public finalcut::FDialog +class MyDialog final : public finalcut::FDialog { public: // Constructor diff --git a/examples/watch.cpp b/examples/watch.cpp index cf4b0339..77b98744 100644 --- a/examples/watch.cpp +++ b/examples/watch.cpp @@ -31,7 +31,7 @@ using finalcut::FSize; // class Watch //---------------------------------------------------------------------- -class Watch : public finalcut::FDialog +class Watch final : public finalcut::FDialog { public: // Constructor diff --git a/examples/windows.cpp b/examples/windows.cpp index c74b9947..92e69907 100644 --- a/examples/windows.cpp +++ b/examples/windows.cpp @@ -32,7 +32,7 @@ using finalcut::FSize; // class SmallWindow //---------------------------------------------------------------------- -class SmallWindow : public finalcut::FDialog +class SmallWindow final : public finalcut::FDialog { public: // Constructor @@ -160,20 +160,20 @@ void SmallWindow::onTimer (finalcut::FTimerEvent*) // class Window //---------------------------------------------------------------------- -class Window : public finalcut::FDialog +class Window final : public finalcut::FDialog { public: // Constructor explicit Window (finalcut::FWidget* = nullptr); - // Disable copy constructor - Window (const Window&) = delete; + // Copy constructor + Window (const Window&) = default; // Destructor ~Window() override; - // Disable assignment operator (=) - Window& operator = (const Window&) = delete; + // Assignment operator (=) + Window& operator = (const Window&) = default; private: // Typedefs diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 9f287098..706d3f3b 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -88,8 +88,9 @@ FApplication::FApplication ( const int& _argc if ( ! (_argc && _argv) ) { - static char* empty{C_STR("")}; app_argc = 0; + static char empty_str[1] = ""; + auto empty = const_cast(empty_str); app_argv = static_cast(&empty); } @@ -179,8 +180,7 @@ bool FApplication::sendEvent ( const FObject* receiver if ( receiver->isWidget() ) { - const auto r_widget = static_cast(receiver); - auto widget = const_cast(r_widget); + const auto widget = static_cast(receiver); if ( getModalDialogCounter() > 0 ) { @@ -363,7 +363,13 @@ void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev) if ( ret == FMessageBox::Yes ) ev->accept(); else + { ev->ignore(); + + // Status bar restore after closing the FMessageBox + if ( getStatusBar() ) + getStatusBar()->drawMessage(); + } } // private methods of FApplication diff --git a/src/fbutton.cpp b/src/fbutton.cpp index 77259ac8..ab68691b 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -521,7 +521,9 @@ inline void FButton::drawTopBottomBackground() //---------------------------------------------------------------------- inline void FButton::drawButtonTextLine (const FString& button_text) { + std::size_t z{0}; std::size_t pos{}; + std::size_t columns{0}; print() << FPoint(2 + int(indent), 1 + int(vcenter_offset)) << FColorPair (button_fg, button_bg); @@ -547,8 +549,7 @@ inline void FButton::drawButtonTextLine (const FString& button_text) if ( active_focus && (isMonochron() || getMaxColor() < 16) ) setBold(); - for ( std::size_t z{0}, columns{0} - ; pos < center_offset + column_width && columns + 2 < getWidth(); ) + while ( pos < center_offset + column_width && columns + 2 < getWidth() ) { if ( z == hotkeypos && getFlags().active ) { diff --git a/src/fcombobox.cpp b/src/fcombobox.cpp index a0d4d0c2..f1dbb234 100644 --- a/src/fcombobox.cpp +++ b/src/fcombobox.cpp @@ -538,7 +538,7 @@ void FComboBox::draw() { const auto& wc = getFWidgetColors(); - const FColorPair button_color = [&] () + const FColorPair button_color = [this, &wc] () { if ( list_window.isEmpty() ) return FColorPair ( wc.scrollbar_button_inactive_fg diff --git a/src/flistview.cpp b/src/flistview.cpp index 14c2ad93..0bf0b424 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -491,8 +491,46 @@ FListViewIterator::FListViewIterator (iterator iter) : node(iter) { } +//---------------------------------------------------------------------- +FListViewIterator::FListViewIterator (const FListViewIterator& i) + : iter_path(i.iter_path) // copy constructor + , node(i.node) + , position(i.position) +{ } + +//---------------------------------------------------------------------- +FListViewIterator::FListViewIterator (FListViewIterator&& i) noexcept + : iter_path(i.iter_path) // move constructor + , node(i.node) + , position(i.position) +{ + i.iter_path = iterator_stack{}; + i.node = iterator{}; + i.position = 0; +} // FListViewIterator operators +//---------------------------------------------------------------------- +FListViewIterator& FListViewIterator::operator = (const FListViewIterator& i) +{ + iter_path = i.iter_path; + node = i.node; + position = i.position; + return *this; +} + +//---------------------------------------------------------------------- +FListViewIterator& FListViewIterator::operator = (FListViewIterator&& i) noexcept +{ + iter_path = i.iter_path; + node = i.node; + position = i.position; + i.iter_path = iterator_stack{}; + i.node = iterator{}; + i.position = 0; + return *this; +} + //---------------------------------------------------------------------- FListViewIterator& FListViewIterator::operator ++ () // prefix { diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 5986f03a..2bb8ebd0 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -566,8 +566,9 @@ int FOptiMove::capDuration (const char cap[], int affcnt) if ( p[0] == '$' && p[1] == '<' && std::strchr(p, '>') ) { float num = 0; + p += 2; - for (p += 2; *p != '>'; p++) + while ( *p != '>' ) { if ( std::isdigit(uChar(*p)) ) num = num * 10 + float(*p - '0'); @@ -575,11 +576,13 @@ int FOptiMove::capDuration (const char cap[], int affcnt) num *= float(affcnt); else if ( *p == '.' ) { - ++p; + p++; if ( *p != '>' && std::isdigit(uChar(*p)) ) num += float((*p - '0') / 10.0); } + + p++; } ms += num * 10; diff --git a/src/frect.cpp b/src/frect.cpp index dc8d1ccd..c2fa83df 100644 --- a/src/frect.cpp +++ b/src/frect.cpp @@ -56,6 +56,28 @@ FRect::~FRect() // destructor // public methods of FRect +//---------------------------------------------------------------------- +FRect& FRect::operator = (const FRect& r) +{ + X1 = r.X1; + Y1 = r.Y1; + X2 = r.X2; + Y2 = r.Y2; + return *this; +} + +//---------------------------------------------------------------------- +FRect& FRect::operator = (FRect&& r) noexcept +{ + X1 = r.X1; + Y1 = r.Y1; + X2 = r.X2; + Y2 = r.Y2; + r.X1 = r.Y1 = 0; + r.X2 = r.Y2 = -1; + return *this; +} + //---------------------------------------------------------------------- bool FRect::isEmpty() const { @@ -310,27 +332,6 @@ FRect FRect::combined (const FRect& r) const return new_rect; } -//---------------------------------------------------------------------- -FRect& FRect::operator = (const FRect& r) -{ - X1 = r.X1; - Y1 = r.Y1; - X2 = r.X2; - Y2 = r.Y2; - return *this; -} - -//---------------------------------------------------------------------- -FRect& FRect::operator = (FRect&& r) noexcept -{ - X1 = r.X1; - Y1 = r.Y1; - X2 = r.X2; - Y2 = r.Y2; - r.X1 = r.Y1 = 0; - r.X2 = r.Y2 = -1; - return *this; -} // FRect non-member operators //---------------------------------------------------------------------- diff --git a/src/fwidget_functions.cpp b/src/fwidget_functions.cpp index 5d5a4840..69e807b3 100644 --- a/src/fwidget_functions.cpp +++ b/src/fwidget_functions.cpp @@ -60,9 +60,10 @@ FKey getHotkey (const FString& text) if ( text.isEmpty() ) return 0; + std::size_t i{0}; const std::size_t length = text.getLength(); - for (std::size_t i{0}; i < length; i++) + while ( i < length ) { try { @@ -76,7 +77,10 @@ FKey getHotkey (const FString& text) { return 0; } + + i++; } + return 0; } diff --git a/src/include/final/flistview.h b/src/include/final/flistview.h index 26ffbd34..585f1f61 100644 --- a/src/include/final/flistview.h +++ b/src/include/final/flistview.h @@ -190,8 +190,12 @@ class FListViewIterator // Constructor FListViewIterator (); FListViewIterator (iterator); + FListViewIterator (const FListViewIterator&); // copy constructor + FListViewIterator (FListViewIterator&&) noexcept; // move constructor // Overloaded operators + FListViewIterator& operator = (const FListViewIterator&); + FListViewIterator& operator = (FListViewIterator&&) noexcept; FListViewIterator& operator ++ (); // prefix FListViewIterator operator ++ (int); // postfix FListViewIterator& operator -- (); // prefix diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index 87e01119..8fa5b21c 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -99,22 +99,7 @@ class FVTerm typedef std::function FPreprocessingFunction; struct FTermArea; // forward declaration - - struct FVTermPreprocessing - { - FVTermPreprocessing() - : instance(nullptr) - , function(nullptr) - { } - - FVTermPreprocessing (const FVTerm* i, const FPreprocessingFunction& f) - : instance(i) - , function(f) - { } - - const FVTerm* instance; - FPreprocessingFunction function; - }; + struct FVTermPreprocessing; // forward declaration typedef std::vector FPreprocessing; @@ -527,14 +512,17 @@ struct FVTerm::FTermArea // define virtual terminal character properties public: // Constructor FTermArea() = default; + // Disable copy constructor FTermArea (const FTermArea&) = delete; + // Destructor ~FTermArea() = default; // Disable assignment operator (=) FTermArea& operator = (const FTermArea&) = delete; + // Data members int offset_left{0}; // Distance from left terminal side int offset_top{0}; // Distance from top of the terminal int width{-1}; // Window width @@ -555,6 +543,63 @@ struct FVTerm::FTermArea // define virtual terminal character properties }; +//---------------------------------------------------------------------- +// struct FVTerm::FVTermPreprocessing +//---------------------------------------------------------------------- + +struct FVTerm::FVTermPreprocessing +{ + // Constructor + FVTermPreprocessing() + : instance(nullptr) + , function(nullptr) + { } + + FVTermPreprocessing (const FVTerm* i, const FPreprocessingFunction& f) + : instance(i) + , function(f) + { } + + FVTermPreprocessing (const FVTermPreprocessing& p) // copy constructor + : instance(p.instance) + , function(p.function) + { } + + FVTermPreprocessing (FVTermPreprocessing&& p) noexcept // move constructor + : instance(p.instance) + , function(p.function) + { + p.instance = nullptr; + p.function = nullptr; + } + + // Overloaded operators + FVTermPreprocessing& operator = (const FVTermPreprocessing& p) + { + instance = p.instance; + function = p.function; + return *this; + } + + FVTermPreprocessing& operator = (FVTermPreprocessing&& p) noexcept + { + instance = p.instance; + function = p.function; + p.instance = nullptr; + p.function = nullptr; + return *this; + } + + // Destructor + ~FVTermPreprocessing() + { } + + // Data members + const FVTerm* instance{}; + FPreprocessingFunction function{}; +}; + + // FVTerm inline functions //---------------------------------------------------------------------- template diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index dcd6981e..f8ac6b8c 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -340,27 +340,7 @@ class FWidget : public FVTerm, public FObject static void quit(); protected: - struct FCallbackData - { - FCallbackData() - : cb_signal() - , cb_instance(nullptr) - , cb_function() - , data(nullptr) - { } - - FCallbackData (FString s, FWidget* i, FCallback c, FDataPtr d) - : cb_signal(s) - , cb_instance(i) - , cb_function(c) - , data(d) - { } - - FString cb_signal; - FWidget* cb_instance; - FCallback cb_function; - FDataPtr data; - }; + struct FCallbackData; // forward declaration // Typedefs typedef std::vector FCallbackObjects; @@ -537,6 +517,79 @@ class FWidget : public FVTerm, public FObject friend void clearFlatBorder (FWidget*); }; +//---------------------------------------------------------------------- +// struct FWidget::FCallbackData +//---------------------------------------------------------------------- +struct FWidget::FCallbackData +{ + // Constructor + FCallbackData() + : cb_signal() + , cb_instance(nullptr) + , cb_function() + , data(nullptr) + { } + + FCallbackData (FString s, FWidget* i, FCallback c, FDataPtr d) + : cb_signal(s) + , cb_instance(i) + , cb_function(c) + , data(d) + { } + + FCallbackData (const FCallbackData& c) // copy constructor + : cb_signal(c.cb_signal) + , cb_instance(c.cb_instance) + , cb_function(c.cb_function) + , data(c.data) + { } + + FCallbackData (FCallbackData&& c) noexcept // move constructor + : cb_signal(c.cb_signal) + , cb_instance(c.cb_instance) + , cb_function(c.cb_function) + , data(c.data) + { + c.cb_signal.clear(); + c.cb_instance = nullptr; + c.cb_function = nullptr; + c.data = nullptr; + } + + // Destructor + ~FCallbackData() + { } + + // Overloaded operators + FCallbackData& operator = (const FCallbackData& c) + { + cb_signal = c.cb_signal; + cb_instance = c.cb_instance; + cb_function = c.cb_function; + data = c.data; + return *this; + } + + FCallbackData& operator = (FCallbackData&& c) noexcept + { + cb_signal = c.cb_signal; + cb_instance = c.cb_instance; + cb_function = c.cb_function; + data = c.data; + c.cb_signal.clear(); + c.cb_instance = nullptr; + c.cb_function = nullptr; + c.data = nullptr; + return *this; + } + + // Data members + FString cb_signal{}; + FWidget* cb_instance{}; + FCallback cb_function{}; + FDataPtr data{}; +}; + // non-member function forward declarations // implemented in fwidget_functions.cpp diff --git a/src/include/final/sgr_optimizer.h b/src/include/final/sgr_optimizer.h index e6e48f54..e0d6814f 100644 --- a/src/include/final/sgr_optimizer.h +++ b/src/include/final/sgr_optimizer.h @@ -56,12 +56,12 @@ class SGRoptimizer final // Constructors explicit SGRoptimizer (attributebuffer&); - // Destructor - ~SGRoptimizer(); - // Disable copy constructor SGRoptimizer (const SGRoptimizer&) = delete; + // Destructor + ~SGRoptimizer(); + // Disable assignment operator (=) SGRoptimizer& operator = (const SGRoptimizer&) = delete;