diff --git a/ChangeLog b/ChangeLog index 2521e9d5..2d38e2a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2020-05-24 Markus Gans * New class FStringStream implements input and output operations on FString based streams + * Fixed memory leak in FString move assignment operator 2020-05-21 Markus Gans * Fixed the event queue in FApplication diff --git a/doc/first-steps.md b/doc/first-steps.md index f419157e..ff1de5b5 100644 --- a/doc/first-steps.md +++ b/doc/first-steps.md @@ -69,8 +69,8 @@ int main (int argc, char* argv[]) finalcut::FApplication app(argc, argv); finalcut::FDialog dialog(&app); dialog.setText ("A dialog"); - const finalcut::FPoint position(25, 5); - const finalcut::FSize size(30, 10); + const finalcut::FPoint position{25, 5}; + const finalcut::FSize size{30, 10}; dialog.setGeometry (position, size); finalcut::FWidget::setMainWidget(&dialog); dialog.show(); @@ -126,8 +126,8 @@ dialog.setText ("A dialog"); The title bar of the dialog box gets the text "A dialog". ```cpp -finalcut::FPoint position(25, 5); -finalcut::FSize size(30, 10); +finalcut::FPoint position{25, 5}; +finalcut::FSize size{30, 10}; dialog.setGeometry (position, size); ``` The dialog window gets a width of 30 and a height of 10 characters. @@ -206,11 +206,11 @@ int main (int argc, char* argv[]) // The object dialog is managed by app FDialog* dialog = new FDialog(&app); dialog->setText ("Window Title"); - dialog->setGeometry (FPoint(25, 5), FSize(40, 8)); + dialog->setGeometry (FPoint{25, 5}, FSize{40, 8}); // The object input is managed by dialog FLineEdit* input = new FLineEdit("predefined text", dialog); - input->setGeometry(FPoint(8, 2), FSize(29, 1)); + input->setGeometry(FPoint{8, 2}, FSize{29, 1}); input->setLabelText (L"&Input"); // The object label is managed by dialog @@ -218,7 +218,7 @@ int main (int argc, char* argv[]) "adipiscing elit, sed do eiusmod tempor " "incididunt ut labore et dolore magna aliqua." , dialog ); - label->setGeometry (FPoint(2, 4), FSize(36, 1)); + label->setGeometry (FPoint{2, 4}, FSize{36, 1}); FWidget::setMainWidget(dialog); dialog->show(); return app.exec(); @@ -322,13 +322,13 @@ class dialogWidget : public FDialog { public: explicit dialogWidget (FWidget* parent = nullptr) - : FDialog(parent) + : FDialog{parent} { setText ("Dialog"); - setGeometry (FPoint(25, 5), FSize(23, 4)); - label.setGeometry (FPoint(1, 1), FSize(10, 1)); + setGeometry (FPoint{25, 5}, FSize{23, 4}); + label.setGeometry (FPoint{1, 1}, FSize{10, 1}); label.setAlignment (fc::alignRight); - value.setGeometry (FPoint(11, 1), FSize(10, 1)); + value.setGeometry (FPoint{11, 1}, FSize{10, 1}); id = addTimer(100); } @@ -500,14 +500,14 @@ int main (int argc, char* argv[]) FApplication app(argc, argv); FDialog dialog(&app); dialog.setText ("A dialog with callback function"); - dialog.setGeometry (FRect(25, 5, 45, 9)); + dialog.setGeometry (FRect{25, 5, 45, 9}); FLabel label (&dialog); label = "The button has never been pressed before"; - label.setGeometry (FPoint(2, 2), FSize(41, 1)); + label.setGeometry (FPoint{2, 2}, FSize{41, 1}); FButton button (&dialog); // Character follows '&' will be used as the accelerator key button = "&Click me"; - button.setGeometry (FPoint(15, 5), FSize(14, 1)); + button.setGeometry (FPoint{15, 5}, FSize{14, 1}); // Connect the button signal "clicked" with the callback function button.addCallback @@ -553,9 +553,9 @@ int main (int argc, char* argv[]) FApplication app(argc, argv); FDialog dialog(&app); dialog.setText ("Lambda expression as callback"); - dialog.setGeometry (FRect(25, 5, 45, 9)); + dialog.setGeometry (FRect{25, 5, 45, 9}); FButton button ("&bottom", &dialog); - button.setGeometry (FPoint(15, 5), FSize(14, 1)); + button.setGeometry (FPoint{15, 5}, FSize{14, 1}); // Connect the button signal "clicked" with the lambda expression button.addCallback @@ -567,12 +567,12 @@ int main (int argc, char* argv[]) if ( button.getY() != 2 ) { - button.setPos (FPoint(15, 2)); + button.setPos (FPoint{15, 2}); button.setText("&top"); } else { - button.setPos (FPoint(15, 5)); + button.setPos (FPoint{15, 5}); button.setText("&bottom"); } @@ -619,8 +619,8 @@ class dialogWidget : public FDialog : FDialog(parent) { setText ("Callback method"); - setGeometry (FPoint(25, 5), FSize(25, 7)); - button.setGeometry (FPoint(7, 3), FSize(10, 1)); + setGeometry (FPoint{25, 5}, FSize{25, 7}); + button.setGeometry (FPoint{7, 3}, FSize{10, 1}); // Connect the button signal "clicked" with the callback method button.addCallback @@ -678,16 +678,16 @@ class dialogWidget : public FDialog { public: explicit dialogWidget (FWidget* parent = nullptr) - : FDialog(parent) + : FDialog{parent} { - setGeometry (FPoint(25, 5), FSize(22, 7)); + setGeometry (FPoint{25, 5}, FSize{22, 7}); setText ("Emit signal"); - const FSize size(5, 1); - label.setGeometry (FPoint(8, 1), size); + const FSize size{5, 1}; + label.setGeometry (FPoint{8, 1}, size); label.setAlignment (fc::alignRight); label.setForegroundColor (fc::Black); - plus.setGeometry (FPoint(3, 3), size); - minus.setGeometry (FPoint(13, 3), size); + plus.setGeometry (FPoint{3, 3}, size); + minus.setGeometry (FPoint{13, 3}, size); plus.setNoUnderline(); minus.setNoUnderline(); @@ -987,15 +987,15 @@ class dialogWidget : public FDialog { public: explicit dialogWidget (FWidget* parent = nullptr) - : FDialog(parent) + : FDialog{parent} { setText ("Dialog"); setResizeable(); - button.setGeometry (FPoint(1, 1), FSize(12, 1), false); - input.setGeometry (FPoint(2, 3), FSize(12, 1), false); + button.setGeometry (FPoint{1, 1}, FSize{12, 1}, false); + input.setGeometry (FPoint{2, 3}, FSize{12, 1}, false); // Set dialog geometry and calling adjustSize() - setGeometry (FPoint(25, 5), FSize(40, 12)); - setMinimumSize (FSize(25, 9)); + setGeometry (FPoint{25, 5}), FSize{40, 12}); + setMinimumSize (FSize{25, 9}); } private: @@ -1011,14 +1011,14 @@ class dialogWidget : public FDialog auto y = int((getDesktopHeight() - getHeight()) / 2); checkMinValue(x); checkMinValue(y); - setPos (FPoint(x, y), false); + setPos (FPoint{x, y}, false); } void adjustWidgets() { const auto bx = int(getWidth() - button.getWidth() - 3); const auto by = int(getHeight() - 4); - button.setPos (FPoint(bx, by), false); + button.setPos (FPoint{bx, by}, false); input.setWidth (getWidth() - 4); const auto ly = int(getHeight() / 2) - 1; input.setY (ly, false); @@ -1046,10 +1046,10 @@ class dialogWidget : public FDialog // Calling super class method draw() FDialog::draw(); - print() << FPoint (3, 3) - << FColorPair (fc::Black, fc::White) + print() << FPoint{3, 3} + << FColorPair{fc::Black, fc::White} << "Text on " - << FColorPair (fc::Blue, fc::Yellow) + << FColorPair{fc::Blue, fc::Yellow} << "top"; } @@ -1129,12 +1129,12 @@ class dialogWidget : public FDialog { public: explicit dialogWidget (FWidget* parent = nullptr) - : FDialog(parent) + : FDialog{parent} { setText ("Dialog"); - setGeometry (FPoint(28, 2), FSize(24, 21)); - scrollview.setGeometry(FPoint(1, 1), FSize(22, 11)); - scrollview.setScrollSize(FSize(60, 27)); + setGeometry (FPoint{28, 2}, FSize{24, 21}); + scrollview.setGeometry(FPoint{1, 1}, FSize{22, 11}); + scrollview.setScrollSize(FSize{60, 27}); const auto& wc = getFWidgetColors(); setColor (wc.label_inactive_fg, wc.dialog_bg); scrollview.clearArea(); @@ -1144,25 +1144,25 @@ class dialogWidget : public FDialog static std::vector d { - {"NW", FPoint(3, 13), FPoint(1, 1), black}, - {"N", FPoint(10, 13), FPoint(21, 1), red}, - {"NE", FPoint(17, 13), FPoint(41, 1), black}, - {"W", FPoint(3, 15), FPoint(1, 10), black}, - {"*", FPoint(10, 15), FPoint(21, 10), black}, - {"E", FPoint(17, 15), FPoint(41, 10), black}, - {"SW", FPoint(3, 17), FPoint(1, 19), black}, - {"S", FPoint(10, 17), FPoint(21, 19), cyan}, - {"SE", FPoint(17, 17), FPoint(41, 19), black} + {"NW", FPoint{3, 13}, FPoint{1, 1}, black}, + {"N", FPoint{10, 13}, FPoint{21, 1}, red}, + {"NE", FPoint{17, 13}, FPoint{41, 1}, black}, + {"W", FPoint{3, 15}, FPoint{1, 10}, black}, + {"*", FPoint{10, 15}, FPoint{21, 10}, black}, + {"E", FPoint{17, 15}, FPoint{41, 10}, black}, + {"SW", FPoint{3, 17}, FPoint{1, 19}, black}, + {"S", FPoint{10, 17}, FPoint{21, 19}, cyan}, + {"SE", FPoint{17, 17}, FPoint{41, 19}, black} }; for (auto&& b : d) { - scrollview.print() << std::get<2>(b) + FPoint(10, 5) + scrollview.print() << std::get<2>(b) + FPoint{10, 5} << std::get<3>(b) << std::get<0>(b); auto edit = new FLineEdit("direction " + std::get<0>(b), &scrollview); - edit->setGeometry(std::get<2>(b) + FPoint(1, 1), FSize(17, 1)); + edit->setGeometry(std::get<2>(b) + FPoint{1, 1}, FSize{17, 1}); auto btn = new FButton(std::get<0>(b), this); - btn->setGeometry(std::get<1>(b), FSize(4, 1)); + btn->setGeometry(std::get<1>(b), FSize{4, 1}); btn->unsetShadow(); btn->addCallback ( diff --git a/examples/7segment.cpp b/examples/7segment.cpp index 9ae83058..8cf9cdbb 100644 --- a/examples/7segment.cpp +++ b/examples/7segment.cpp @@ -74,7 +74,7 @@ class SegmentView final : public finalcut::FDialog //---------------------------------------------------------------------- SegmentView::SegmentView (finalcut::FWidget* parent) - : FDialog(parent) + : FDialog{parent} { // Dialog settings // Avoids calling a virtual function from the constructor diff --git a/examples/background-color.cpp b/examples/background-color.cpp index 4834e273..60938a7e 100644 --- a/examples/background-color.cpp +++ b/examples/background-color.cpp @@ -92,7 +92,7 @@ class Background final : public finalcut::FDialog //---------------------------------------------------------------------- Background::Background (finalcut::FWidget* parent) - : FDialog(parent) + : FDialog{parent} { // Dialog settings // Avoids calling a virtual function from the constructor diff --git a/examples/calculator.cpp b/examples/calculator.cpp index 857c3c8e..6beba5e8 100644 --- a/examples/calculator.cpp +++ b/examples/calculator.cpp @@ -62,7 +62,7 @@ class Button final : public finalcut::FButton //---------------------------------------------------------------------- Button::Button (finalcut::FWidget* parent) - : finalcut::FButton(parent) + : finalcut::FButton{parent} { } //---------------------------------------------------------------------- @@ -245,7 +245,7 @@ class Calc final : public finalcut::FDialog //---------------------------------------------------------------------- Calc::Calc (FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { // Dialog settings // Avoids calling a virtual function from the constructor diff --git a/examples/checklist.cpp b/examples/checklist.cpp index ab1c8221..33ce1e60 100644 --- a/examples/checklist.cpp +++ b/examples/checklist.cpp @@ -73,7 +73,7 @@ class CheckList final : public finalcut::FDialog //---------------------------------------------------------------------- CheckList::CheckList (finalcut::FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { // Dialog settings // Avoids calling a virtual function from the constructor diff --git a/examples/event-log.cpp b/examples/event-log.cpp index fe827de9..6d0991a7 100644 --- a/examples/event-log.cpp +++ b/examples/event-log.cpp @@ -83,7 +83,7 @@ class EventDialog final : public finalcut::FDialog //---------------------------------------------------------------------- EventDialog::EventDialog (finalcut::FWidget* parent) - : FDialog(parent) + : FDialog{parent} { // Dialog settings // Avoids calling a virtual function from the constructor @@ -263,7 +263,7 @@ class EventLog final : public finalcut::FDialog, public std::ostringstream //---------------------------------------------------------------------- EventLog::EventLog (finalcut::FWidget* parent) - : FDialog(parent) + : FDialog{parent} { // Dialog settings // Avoids calling a virtual function from the constructor diff --git a/examples/keyboard.cpp b/examples/keyboard.cpp index 78cfb5ef..cd7e0c8a 100644 --- a/examples/keyboard.cpp +++ b/examples/keyboard.cpp @@ -44,7 +44,7 @@ class Keyboard final : public finalcut::FWidget //---------------------------------------------------------------------- Keyboard::Keyboard (finalcut::FWidget* parent) - : finalcut::FWidget(parent) + : finalcut::FWidget{parent} { setFWidgetColors().term_fg = finalcut::fc::Default; setFWidgetColors().term_bg = finalcut::fc::Default; diff --git a/examples/listbox.cpp b/examples/listbox.cpp index 72480b6a..0a6c60cc 100644 --- a/examples/listbox.cpp +++ b/examples/listbox.cpp @@ -105,7 +105,7 @@ class Listbox final : public FDialog //---------------------------------------------------------------------- Listbox::Listbox (FWidget* parent) - : FDialog(parent) + : FDialog{parent} { auto temp = std::make_shared(); temp_str = temp; diff --git a/examples/listview.cpp b/examples/listview.cpp index 39cf8c71..0ec35148 100644 --- a/examples/listview.cpp +++ b/examples/listview.cpp @@ -68,7 +68,7 @@ class Listview final : public finalcut::FDialog //---------------------------------------------------------------------- Listview::Listview (finalcut::FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { // Set FListView geometry listView.setGeometry(FPoint{2, 1}, FSize{33, 14}); diff --git a/examples/mandelbrot.cpp b/examples/mandelbrot.cpp index 4c1a91ea..1ec4935e 100644 --- a/examples/mandelbrot.cpp +++ b/examples/mandelbrot.cpp @@ -53,7 +53,7 @@ class Mandelbrot final : public finalcut::FDialog //---------------------------------------------------------------------- Mandelbrot::Mandelbrot (finalcut::FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { FDialog::setText ("Mandelbrot set"); } diff --git a/examples/menu.cpp b/examples/menu.cpp index f8a21add..978114f0 100644 --- a/examples/menu.cpp +++ b/examples/menu.cpp @@ -117,7 +117,7 @@ class Menu final : public finalcut::FDialog //---------------------------------------------------------------------- Menu::Menu (finalcut::FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { // Menu bar itms File.setStatusbarMessage ("File management commands"); diff --git a/examples/mouse.cpp b/examples/mouse.cpp index b0de1afc..f9dc68f2 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -72,7 +72,7 @@ class ColorChooser final : public finalcut::FWidget //---------------------------------------------------------------------- ColorChooser::ColorChooser (finalcut::FWidget* parent) - : FWidget(parent) + : FWidget{parent} { FWidget::setSize (FSize{8, 12}); setFixedSize (FSize{8, 12}); @@ -226,7 +226,7 @@ class Brushes final : public finalcut::FWidget //---------------------------------------------------------------------- Brushes::Brushes (finalcut::FWidget* parent) - : FWidget(parent) + : FWidget{parent} { FWidget::setSize (FSize{8, 4}); setFixedSize (FSize{8, 4}); @@ -379,7 +379,7 @@ class MouseDraw final : public finalcut::FDialog //---------------------------------------------------------------------- MouseDraw::MouseDraw (finalcut::FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { FDialog::setText ("Drawing with the mouse"); c_chooser.setPos (FPoint{1, 1}); diff --git a/examples/rotozoomer.cpp b/examples/rotozoomer.cpp index adfa2fd4..a1bf1399 100644 --- a/examples/rotozoomer.cpp +++ b/examples/rotozoomer.cpp @@ -80,9 +80,9 @@ class RotoZoomer final : public finalcut::FDialog //---------------------------------------------------------------------- RotoZoomer::RotoZoomer (finalcut::FWidget* parent, bool b, int l) - : finalcut::FDialog(parent) - , benchmark(b) - , loops(l) + : finalcut::FDialog{parent} + , benchmark{b} + , loops{l} { FDialog::setText ("Rotozoomer effect"); diff --git a/examples/scrollview.cpp b/examples/scrollview.cpp index 7676c32b..0d5bdb60 100644 --- a/examples/scrollview.cpp +++ b/examples/scrollview.cpp @@ -72,7 +72,7 @@ class Scrollview final : public finalcut::FScrollView //---------------------------------------------------------------------- Scrollview::Scrollview (finalcut::FWidget* parent) - : finalcut::FScrollView(parent) + : finalcut::FScrollView{parent} { // Sets the navigation button geometry go_east.setGeometry (FPoint{1, 1}, FSize{5, 1}); @@ -214,7 +214,7 @@ class Scrollviewdemo final : public finalcut::FDialog //---------------------------------------------------------------------- Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { FDialog::setGeometry (FPoint{16, 3}, FSize{50, 19}); FDialog::setText ("Scrolling viewport example"); diff --git a/examples/term-attributes.cpp b/examples/term-attributes.cpp index 1e676382..c549cf4e 100644 --- a/examples/term-attributes.cpp +++ b/examples/term-attributes.cpp @@ -73,7 +73,7 @@ class AttribDlg final : public finalcut::FDialog //---------------------------------------------------------------------- AttribDlg::AttribDlg (finalcut::FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { FDialog::setText ( "A terminal attributes test (" + finalcut::FString{finalcut::FTerm::getTermType()} @@ -243,7 +243,7 @@ class AttribDemo final : public finalcut::FWidget //---------------------------------------------------------------------- AttribDemo::AttribDemo (finalcut::FWidget* parent) - : finalcut::FWidget(parent) + : finalcut::FWidget{parent} { if ( finalcut::FTerm::isMonochron() ) last_color = 1; diff --git a/examples/timer.cpp b/examples/timer.cpp index 5c162394..10086e7b 100644 --- a/examples/timer.cpp +++ b/examples/timer.cpp @@ -46,7 +46,7 @@ class Timer final : public finalcut::FWidget //---------------------------------------------------------------------- Timer::Timer (finalcut::FWidget* parent) - : finalcut::FWidget(parent) + : finalcut::FWidget{parent} { addTimer (60000); // 1-minute timer const int id = addTimer (50); // 50-millisecond timer diff --git a/examples/transparent.cpp b/examples/transparent.cpp index 62444d73..e9f23fc2 100644 --- a/examples/transparent.cpp +++ b/examples/transparent.cpp @@ -71,8 +71,8 @@ class Transparent final : public finalcut::FDialog //---------------------------------------------------------------------- Transparent::Transparent ( finalcut::FWidget* parent , Transparent::trans_type tt ) - : finalcut::FDialog(parent) - , type(tt) + : finalcut::FDialog{parent} + , type{tt} { // Set statusbar text for this window // Avoids calling a virtual function from the constructor @@ -191,7 +191,7 @@ class MainWindow final : public finalcut::FDialog //---------------------------------------------------------------------- MainWindow::MainWindow (finalcut::FWidget* parent) - : FDialog(parent) + : FDialog{parent} { // The memory allocation for the following three sub windows occurs // with the operator new. The lifetime of the generated widget diff --git a/examples/treeview.cpp b/examples/treeview.cpp index c0ec19bc..8d36e5af 100644 --- a/examples/treeview.cpp +++ b/examples/treeview.cpp @@ -326,7 +326,7 @@ Treeview::TreeItem Treeview::oceania[] = // constructors and destructor //---------------------------------------------------------------------- Treeview::Treeview (finalcut::FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { // Set FListView geometry listView.setGeometry(FPoint{2, 1}, FSize{53, 14}); diff --git a/examples/ui.cpp b/examples/ui.cpp index 9343c68f..f20ae301 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -76,7 +76,7 @@ class ProgressDialog final : public finalcut::FDialog //---------------------------------------------------------------------- ProgressDialog::ProgressDialog (finalcut::FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { // Dialog settings // Avoids calling a virtual function from the constructor @@ -218,7 +218,7 @@ class TextWindow final : public finalcut::FDialog //---------------------------------------------------------------------- TextWindow::TextWindow (finalcut::FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { scrollText.ignorePadding(); scrollText.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1}); @@ -369,7 +369,7 @@ class MyDialog final : public finalcut::FDialog //---------------------------------------------------------------------- MyDialog::MyDialog (finalcut::FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { init(); } diff --git a/examples/watch.cpp b/examples/watch.cpp index fdce0bc5..9b03b31f 100644 --- a/examples/watch.cpp +++ b/examples/watch.cpp @@ -73,7 +73,7 @@ class Watch final : public finalcut::FDialog //---------------------------------------------------------------------- Watch::Watch (FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { // Dialog settings // Avoids calling a virtual function from the constructor diff --git a/examples/windows.cpp b/examples/windows.cpp index f761f065..6aaab8be 100644 --- a/examples/windows.cpp +++ b/examples/windows.cpp @@ -66,7 +66,7 @@ class SmallWindow final : public finalcut::FDialog //---------------------------------------------------------------------- SmallWindow::SmallWindow (finalcut::FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { const auto& wc = getFWidgetColors(); const wchar_t arrow_up = fc::BlackUpPointingTriangle; @@ -240,7 +240,7 @@ class Window final : public finalcut::FDialog //---------------------------------------------------------------------- Window::Window (finalcut::FWidget* parent) - : finalcut::FDialog(parent) + : finalcut::FDialog{parent} { // Menu bar item File.setStatusbarMessage ("File management commands"); diff --git a/src/fapplication.cpp b/src/fapplication.cpp index f75baa35..c8380954 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -71,7 +71,7 @@ bool FApplication::quit_now {false}; FApplication::FApplication ( const int& _argc , char* _argv[] , bool disable_alt_screen ) - : FWidget(processParameters(_argc, _argv), disable_alt_screen) + : FWidget{processParameters(_argc, _argv), disable_alt_screen} , app_argc{_argc} , app_argv{_argv} { @@ -103,6 +103,8 @@ FApplication::~FApplication() // destructor if ( eventInQueue() ) event_queue.clear(); + + destroyLog(); } @@ -117,8 +119,8 @@ FApplication* FApplication::getApplicationObject() FApplication::FLogPtr& FApplication::getLog() { // Global logger object - static FLogPtr logger(std::make_shared()); - return logger; + static FLogPtr* logger = new FLogPtr(); + return *logger; } //---------------------------------------------------------------------- @@ -373,6 +375,7 @@ void FApplication::init (uInt64 key_time, uInt64 dblclick_time) mouse->setDblclickInterval (dblclick_time); // Initialize logging + setLog (std::make_shared()); getLog()->setLineEnding(FLog::CRLF); } @@ -478,6 +481,13 @@ inline FStartOptions& FApplication::getStartOptions() return FStartOptions::getFStartOptions(); } +//---------------------------------------------------------------------- +inline void FApplication::destroyLog() +{ + FLogPtr* logger = &(getLog()); + delete logger; +} + //---------------------------------------------------------------------- inline void FApplication::findKeyboardWidget() { diff --git a/src/fbutton.cpp b/src/fbutton.cpp index fca79f54..4b2f792c 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -36,14 +36,14 @@ namespace finalcut // constructors and destructor //---------------------------------------------------------------------- FButton::FButton(FWidget* parent) - : FWidget(parent) + : FWidget{parent} { init(); } //---------------------------------------------------------------------- FButton::FButton (const FString& txt, FWidget* parent) - : FWidget(parent) + : FWidget{parent} , text{txt} { init(); diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index 9830c095..b20a01a1 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -39,14 +39,14 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FButtonGroup::FButtonGroup(FWidget* parent) - : FScrollView(parent) + : FScrollView{parent} { init(); } //---------------------------------------------------------------------- FButtonGroup::FButtonGroup (const FString& txt, FWidget* parent) - : FScrollView(parent) + : FScrollView{parent} , text{txt} { init(); diff --git a/src/fcheckbox.cpp b/src/fcheckbox.cpp index 891ffcf6..44ba8b57 100644 --- a/src/fcheckbox.cpp +++ b/src/fcheckbox.cpp @@ -33,14 +33,14 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FCheckBox::FCheckBox(FWidget* parent) - : FToggleButton(parent) + : FToggleButton{parent} { init(); } //---------------------------------------------------------------------- FCheckBox::FCheckBox (const FString& txt, FWidget* parent) - : FToggleButton(txt, parent) + : FToggleButton{txt, parent} { init(); } diff --git a/src/fcheckmenuitem.cpp b/src/fcheckmenuitem.cpp index fcfdbf1f..201d4e05 100644 --- a/src/fcheckmenuitem.cpp +++ b/src/fcheckmenuitem.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2019 Markus Gans * +* Copyright 2015-2020 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -34,14 +34,14 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FCheckMenuItem::FCheckMenuItem (FWidget* parent) - : FMenuItem(parent) + : FMenuItem{parent} { init (parent); } //---------------------------------------------------------------------- FCheckMenuItem::FCheckMenuItem (const FString& txt, FWidget* parent) - : FMenuItem(txt, parent) + : FMenuItem{txt, parent} { init (parent); } diff --git a/src/fcombobox.cpp b/src/fcombobox.cpp index 623fbba4..28aec7b2 100644 --- a/src/fcombobox.cpp +++ b/src/fcombobox.cpp @@ -44,7 +44,7 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FDropDownListBox::FDropDownListBox (FWidget* parent) - : FWindow(parent) + : FWindow{parent} { init(); } @@ -169,7 +169,7 @@ bool FDropDownListBox::containsWidget (const FPoint& p) // constructors and destructor //---------------------------------------------------------------------- FComboBox::FComboBox (FWidget* parent) - : FWidget(parent) + : FWidget{parent} { init(); } diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 64b40d70..26d41583 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -42,14 +42,14 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FDialog::FDialog (FWidget* parent) - : FWindow(parent) + : FWindow{parent} { init(); } //---------------------------------------------------------------------- FDialog::FDialog (const FString& txt, FWidget* parent) - : FWindow(parent) + : FWindow{parent} , tb_text{txt} { init(); diff --git a/src/fdialoglistmenu.cpp b/src/fdialoglistmenu.cpp index 4c6cd4e0..3567b8ad 100644 --- a/src/fdialoglistmenu.cpp +++ b/src/fdialoglistmenu.cpp @@ -33,14 +33,14 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FDialogListMenu::FDialogListMenu(FWidget* parent) - : FMenu(parent) + : FMenu{parent} { init(); } //---------------------------------------------------------------------- FDialogListMenu::FDialogListMenu (const FString& txt, FWidget* parent) - : FMenu(txt, parent) + : FMenu{txt, parent} { init(); } diff --git a/src/fevent.cpp b/src/fevent.cpp index b79c068a..964cf440 100644 --- a/src/fevent.cpp +++ b/src/fevent.cpp @@ -53,7 +53,7 @@ bool FEvent::wasSent() const //---------------------------------------------------------------------- FKeyEvent::FKeyEvent (fc::events ev_type, FKey key_num) // constructor - : FEvent(ev_type) + : FEvent{ev_type} , k{key_num} { } @@ -86,7 +86,7 @@ FMouseEvent::FMouseEvent ( fc::events ev_type // constructor , const FPoint& pos , const FPoint& termPos , int button ) - : FEvent(ev_type) + : FEvent{ev_type} , p{pos} , tp{termPos} , b{button} @@ -96,7 +96,7 @@ FMouseEvent::FMouseEvent ( fc::events ev_type // constructor FMouseEvent::FMouseEvent ( fc::events ev_type // constructor , const FPoint& pos , int button ) - : FMouseEvent(ev_type, pos, FPoint{}, button) + : FMouseEvent{ev_type, pos, FPoint{}, button} { } //---------------------------------------------------------------------- @@ -140,7 +140,7 @@ FWheelEvent::FWheelEvent ( fc::events ev_type // constructor , const FPoint& pos , const FPoint& termPos , int wheel ) - : FEvent(ev_type) + : FEvent{ev_type} , p{pos} , tp{termPos} , w{wheel} @@ -150,7 +150,7 @@ FWheelEvent::FWheelEvent ( fc::events ev_type // constructor FWheelEvent::FWheelEvent ( fc::events ev_type // constructor , const FPoint& pos , int wheel ) - : FWheelEvent(ev_type, pos, FPoint{}, wheel) + : FWheelEvent{ev_type, pos, FPoint{}, wheel} { } //---------------------------------------------------------------------- @@ -191,7 +191,7 @@ int FWheelEvent::getWheel() const //---------------------------------------------------------------------- FFocusEvent::FFocusEvent (fc::events ev_type) // constructor - : FEvent(ev_type) + : FEvent{ev_type} { } //---------------------------------------------------------------------- @@ -236,7 +236,7 @@ void FFocusEvent::ignore() //---------------------------------------------------------------------- FAccelEvent::FAccelEvent (fc::events ev_type, void* focused) // constructor - : FEvent(ev_type) + : FEvent{ev_type} , focus_widget{focused} { } @@ -266,7 +266,7 @@ void FAccelEvent::ignore() //---------------------------------------------------------------------- FResizeEvent::FResizeEvent (fc::events ev_type) // constructor - : FEvent(ev_type) + : FEvent{ev_type} { } //---------------------------------------------------------------------- @@ -291,7 +291,7 @@ void FResizeEvent::ignore() //---------------------------------------------------------------------- FShowEvent::FShowEvent (fc::events ev_type) // constructor - : FEvent(ev_type) + : FEvent{ev_type} { } //---------------------------------------------------------------------- @@ -304,7 +304,7 @@ FShowEvent::~FShowEvent() // destructor //---------------------------------------------------------------------- FHideEvent::FHideEvent (fc::events ev_type) // constructor - : FEvent(ev_type) + : FEvent{ev_type} { } //---------------------------------------------------------------------- @@ -317,7 +317,7 @@ FHideEvent::~FHideEvent() // destructor //---------------------------------------------------------------------- FCloseEvent::FCloseEvent (fc::events ev_type) // constructor - : FEvent(ev_type) + : FEvent{ev_type} { } //---------------------------------------------------------------------- @@ -342,7 +342,7 @@ void FCloseEvent::ignore() //---------------------------------------------------------------------- FTimerEvent::FTimerEvent (fc::events ev_type, int timer_id) // constructor - : FEvent(ev_type) + : FEvent{ev_type} , id{timer_id} { } @@ -360,7 +360,7 @@ int FTimerEvent::getTimerId() const //---------------------------------------------------------------------- FUserEvent::FUserEvent (fc::events ev_type, int user_event_id) // constructor - : FEvent(ev_type) + : FEvent{ev_type} , uid{user_event_id} { } diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp index 2363d853..7087e6ed 100644 --- a/src/ffiledialog.cpp +++ b/src/ffiledialog.cpp @@ -99,14 +99,14 @@ FSystem* FFileDialog::fsystem{nullptr}; // constructors and destructor //---------------------------------------------------------------------- FFileDialog::FFileDialog (FWidget* parent) - : FDialog(parent) + : FDialog{parent} { init(); } //---------------------------------------------------------------------- FFileDialog::FFileDialog (const FFileDialog& fdlg) - : FDialog(fdlg.getParentWidget()) + : FDialog{fdlg.getParentWidget()} { if ( fdlg.directory ) setPath(fdlg.directory); @@ -119,9 +119,9 @@ FFileDialog::FFileDialog ( const FString& dirname , const FString& filter , DialogType type , FWidget* parent ) - : FDialog(parent) - , filter_pattern(filter) - , dlg_type(type) + : FDialog{parent} + , filter_pattern{filter} + , dlg_type{type} { if ( ! dirname.isNull() ) setPath(dirname); diff --git a/src/flabel.cpp b/src/flabel.cpp index 355ba392..dbeb5d48 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -40,15 +40,15 @@ namespace finalcut // constructors and destructor //---------------------------------------------------------------------- FLabel::FLabel(FWidget* parent) - : FWidget(parent) + : FWidget{parent} { init(); } //---------------------------------------------------------------------- FLabel::FLabel (const FString& txt, FWidget* parent) - : FWidget(parent) - , text(txt) + : FWidget{parent} + , text{txt} { init(); setText(txt); diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 8d63751d..5c37740a 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -42,7 +42,7 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FLineEdit::FLineEdit (FWidget* parent) - : FWidget(parent) + : FWidget{parent} , label{new FLabel("", parent)} { init(); @@ -50,8 +50,8 @@ FLineEdit::FLineEdit (FWidget* parent) //---------------------------------------------------------------------- FLineEdit::FLineEdit (const FString& txt, FWidget* parent) - : FWidget(parent) - , text(txt) + : FWidget{parent} + , text{txt} , label{new FLabel("", parent)} { init(); diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 3b35d9f8..808ec4d7 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -45,16 +45,16 @@ FListBoxItem::FListBoxItem() //---------------------------------------------------------------------- FListBoxItem::FListBoxItem (const FListBoxItem& item) - : text(item.text) - , data_pointer(item.data_pointer) - , brackets(item.brackets) - , selected(item.selected) + : text{item.text} + , data_pointer{item.data_pointer} + , brackets{item.brackets} + , selected{item.selected} { } //---------------------------------------------------------------------- FListBoxItem::FListBoxItem (const FString& txt, FDataPtr data) - : text(txt) - , data_pointer(data) + : text{txt} + , data_pointer{data} { } //---------------------------------------------------------------------- @@ -87,7 +87,7 @@ FListBoxItem& FListBoxItem::operator = (const FListBoxItem& item) // constructor and destructor //---------------------------------------------------------------------- FListBox::FListBox (FWidget* parent) - : FWidget(parent) + : FWidget{parent} { init(); } diff --git a/src/flistview.cpp b/src/flistview.cpp index 3b123ccd..133e3b99 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -170,9 +170,9 @@ bool sortDescendingByNumber (const FObject* lhs, const FObject* rhs) // constructor and destructor //---------------------------------------------------------------------- FListViewItem::FListViewItem (const FListViewItem& item) - : FObject(item.getParent()) - , column_list(item.column_list) - , data_pointer(item.data_pointer) + : FObject{item.getParent()} + , column_list{item.column_list} + , data_pointer{item.data_pointer} { auto parent = getParent(); @@ -191,7 +191,7 @@ FListViewItem::FListViewItem (const FListViewItem& item) //---------------------------------------------------------------------- FListViewItem::FListViewItem (iterator parent_iter) - : FObject((*parent_iter)->getParent()) + : FObject{(*parent_iter)->getParent()} { insert (this, parent_iter); } @@ -200,9 +200,9 @@ FListViewItem::FListViewItem (iterator parent_iter) FListViewItem::FListViewItem ( const FStringList& cols , FDataPtr data , iterator parent_iter ) - : FObject(nullptr) - , column_list(cols) - , data_pointer(data) + : FObject{nullptr} + , column_list{cols} + , data_pointer{data} { if ( cols.empty() ) return; @@ -496,7 +496,7 @@ FListViewIterator::FListViewIterator() //---------------------------------------------------------------------- FListViewIterator::FListViewIterator (iterator iter) - : node(iter) + : node{iter} { } //---------------------------------------------------------------------- @@ -505,16 +505,16 @@ FListViewIterator::~FListViewIterator() // destructor //---------------------------------------------------------------------- FListViewIterator::FListViewIterator (const FListViewIterator& i) - : iter_path(i.iter_path) // copy constructor - , node(i.node) - , position(i.position) + : iter_path{i.iter_path} // copy constructor + , node{i.node} + , position{i.position} { } //---------------------------------------------------------------------- FListViewIterator::FListViewIterator (FListViewIterator&& i) noexcept - : iter_path(std::move(i.iter_path)) // move constructor - , node(std::move(i.node)) - , position(std::move(i.position)) + : iter_path{std::move(i.iter_path)} // move constructor + , node{std::move(i.node)} + , position{std::move(i.position)} { } // FListViewIterator operators @@ -683,7 +683,7 @@ void FListViewIterator::parentElement() // constructor and destructor //---------------------------------------------------------------------- FListView::FListView (FWidget* parent) - : FWidget(parent) + : FWidget{parent} { init(); } diff --git a/src/fmenu.cpp b/src/fmenu.cpp index a101d454..c0a7b956 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -45,15 +45,15 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FMenu::FMenu(FWidget* parent) - : FWindow(parent) + : FWindow{parent} { init(parent); } //---------------------------------------------------------------------- FMenu::FMenu (const FString& txt, FWidget* parent) - : FWindow(parent) - , menuitem(txt, parent) + : FWindow{parent} + , menuitem{txt, parent} { init(parent); } diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index 9f5c4951..449d9c80 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -42,7 +42,7 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FMenuBar::FMenuBar(FWidget* parent) - : FWindow(parent) + : FWindow{parent} { init(); } diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index e6013171..2bbc12db 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -42,24 +42,24 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FMenuItem::FMenuItem (FWidget* parent) - : FWidget(parent) + : FWidget{parent} { init (parent); } //---------------------------------------------------------------------- FMenuItem::FMenuItem (const FString& txt, FWidget* parent) - : FWidget(parent) - , text(txt) + : FWidget{parent} + , text{txt} { init (parent); } //---------------------------------------------------------------------- FMenuItem::FMenuItem (FKey k, const FString& txt, FWidget* parent) - : FWidget(parent) - , text(txt) - , accel_key(k) + : FWidget{parent} + , text{txt} + , accel_key{k} { init (parent); } diff --git a/src/fmessagebox.cpp b/src/fmessagebox.cpp index 69e66ef1..d47b1e4d 100644 --- a/src/fmessagebox.cpp +++ b/src/fmessagebox.cpp @@ -50,7 +50,7 @@ static const char* const button_text[] = // constructors and destructor //---------------------------------------------------------------------- FMessageBox::FMessageBox (FWidget* parent) - : FDialog(parent) + : FDialog{parent} { setTitlebarText("Message for you"); init(FMessageBox::Ok, 0, 0); @@ -58,15 +58,15 @@ FMessageBox::FMessageBox (FWidget* parent) //---------------------------------------------------------------------- FMessageBox::FMessageBox (const FMessageBox& mbox) - : FDialog(mbox.getParentWidget()) - , headline_text(mbox.headline_text) - , text(mbox.text) - , text_components(mbox.text_components) - , max_line_width(mbox.max_line_width) - , emphasis_color(mbox.emphasis_color) - , num_buttons(mbox.num_buttons) - , text_num_lines(mbox.text_num_lines) - , center_text(mbox.center_text) + : FDialog{mbox.getParentWidget()} + , headline_text{mbox.headline_text} + , text{mbox.text} + , text_components{mbox.text_components} + , max_line_width{mbox.max_line_width} + , emphasis_color{mbox.emphasis_color} + , num_buttons{mbox.num_buttons} + , text_num_lines{mbox.text_num_lines} + , center_text{mbox.center_text} { setTitlebarText (mbox.getTitlebarText()); init ( mbox.button_digit[0] @@ -81,8 +81,8 @@ FMessageBox::FMessageBox ( const FString& caption , int button1 , int button2 , FWidget* parent ) - : FDialog(parent) - , text(message) + : FDialog{parent} + , text{message} { setTitlebarText(caption); init(button0, button1, button2); diff --git a/src/fmouse.cpp b/src/fmouse.cpp index 767ac819..3cd8f6f2 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -308,7 +308,7 @@ bool FMouse::isDblclickTimeout (const timeval* time) // constructors and destructor //---------------------------------------------------------------------- FMouseGPM::FMouseGPM() - : FMouse() + : FMouse{} { gpm_ev.x = -1; } diff --git a/src/fobject.cpp b/src/fobject.cpp index 8006056d..77fdf11a 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -43,7 +43,7 @@ const FString* fc::emptyFString::empty_string{nullptr}; // constructors and destructor //---------------------------------------------------------------------- FObject::FObject (FObject* parent) - : parent_obj(parent) + : parent_obj{parent} { if ( parent ) // add object to parent { diff --git a/src/foptimove.cpp b/src/foptimove.cpp index f3ee03be..083b071f 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -36,7 +36,7 @@ namespace finalcut // constructors and destructor //---------------------------------------------------------------------- FOptiMove::FOptiMove (int baud) - : baudrate(baud) + : baudrate{baud} { assert ( baud >= 0 ); diff --git a/src/fprogressbar.cpp b/src/fprogressbar.cpp index 2e12dc6a..030274db 100644 --- a/src/fprogressbar.cpp +++ b/src/fprogressbar.cpp @@ -36,7 +36,7 @@ namespace finalcut // constructors and destructor //---------------------------------------------------------------------- FProgressbar::FProgressbar(FWidget* parent) - : FWidget(parent) + : FWidget{parent} { unsetFocusable(); setShadow(); diff --git a/src/fradiobutton.cpp b/src/fradiobutton.cpp index cfdbaf78..5f511b6b 100644 --- a/src/fradiobutton.cpp +++ b/src/fradiobutton.cpp @@ -33,14 +33,14 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FRadioButton::FRadioButton(FWidget* parent) - : FToggleButton(parent) + : FToggleButton{parent} { init(); } //---------------------------------------------------------------------- FRadioButton::FRadioButton (const FString& txt, FWidget* parent) - : FToggleButton(txt, parent) + : FToggleButton{txt, parent} { init(); } diff --git a/src/fradiomenuitem.cpp b/src/fradiomenuitem.cpp index f34667dc..b3be0246 100644 --- a/src/fradiomenuitem.cpp +++ b/src/fradiomenuitem.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2019 Markus Gans * +* Copyright 2015-2020 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -34,14 +34,14 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FRadioMenuItem::FRadioMenuItem (FWidget* parent) - : FMenuItem(parent) + : FMenuItem{parent} { init (parent); } //---------------------------------------------------------------------- FRadioMenuItem::FRadioMenuItem (const FString& txt, FWidget* parent) - : FMenuItem(txt, parent) + : FMenuItem{txt, parent} { init (parent); } diff --git a/src/frect.cpp b/src/frect.cpp index 9376703f..2d88eb6e 100644 --- a/src/frect.cpp +++ b/src/frect.cpp @@ -36,18 +36,18 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FRect::FRect (const FPoint& p, const FSize& s) - : X1(p.getX()) - , Y1(p.getY()) - , X2(p.getX() + int(s.getWidth()) - 1) - , Y2(p.getY() + int(s.getHeight()) - 1) + : X1{p.getX()} + , Y1{p.getY()} + , X2{p.getX() + int(s.getWidth()) - 1} + , Y2{p.getY() + int(s.getHeight()) - 1} { } //---------------------------------------------------------------------- FRect::FRect (const FPoint& p1, const FPoint& p2) - : X1(p1.getX()) - , Y1(p1.getY()) - , X2(p2.getX()) - , Y2(p2.getY()) + : X1{p1.getX()} + , Y1{p1.getY()} + , X2{p2.getX()} + , Y2{p2.getY()} { } //---------------------------------------------------------------------- diff --git a/src/fscrollbar.cpp b/src/fscrollbar.cpp index 56a5814c..b956cbcf 100644 --- a/src/fscrollbar.cpp +++ b/src/fscrollbar.cpp @@ -37,7 +37,7 @@ namespace finalcut // constructors and destructor //---------------------------------------------------------------------- FScrollbar::FScrollbar(FWidget* parent) - : FWidget(parent) + : FWidget{parent} { // The default scrollbar orientation is vertical setGeometry(FPoint{1, 1}, FSize{1, length}, false); @@ -46,7 +46,7 @@ FScrollbar::FScrollbar(FWidget* parent) //---------------------------------------------------------------------- FScrollbar::FScrollbar(fc::orientation o, FWidget* parent) - : FWidget(parent) + : FWidget{parent} { setOrientation (o); init(); diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index 627da247..134d6c6f 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -38,7 +38,7 @@ namespace finalcut // constructors and destructor //---------------------------------------------------------------------- FScrollView::FScrollView (FWidget* parent) - : FWidget(parent) + : FWidget{parent} { init(parent); } diff --git a/src/fspinbox.cpp b/src/fspinbox.cpp index fccb1263..e19e99bc 100644 --- a/src/fspinbox.cpp +++ b/src/fspinbox.cpp @@ -42,7 +42,7 @@ namespace finalcut // constructors and destructor //---------------------------------------------------------------------- FSpinBox::FSpinBox (FWidget* parent) - : FWidget(parent) + : FWidget{parent} { init(); } diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index 70a8cbc5..8b8c2326 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -36,16 +36,16 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FStatusKey::FStatusKey(FWidget* parent) - : FWidget(parent) + : FWidget{parent} { init (parent); } //---------------------------------------------------------------------- FStatusKey::FStatusKey (FKey k, const FString& txt, FWidget* parent) - : FWidget(parent) - , text(txt) - , key(k) + : FWidget{parent} + , text{txt} + , key{k} { init (parent); } @@ -126,7 +126,7 @@ void FStatusKey::processActivate() // constructor and destructor //---------------------------------------------------------------------- FStatusBar::FStatusBar(FWidget* parent) - : FWindow(parent) + : FWindow{parent} { init(); } diff --git a/src/fstring.cpp b/src/fstring.cpp index d4f350ec..53dcc6dd 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -76,16 +76,15 @@ FString::FString (const FString& s) // copy constructor //---------------------------------------------------------------------- FString::FString (FString&& s) noexcept // move constructor + : string{std::move(s.string)} + , length{s.length} + , bufsize{s.bufsize} + , c_string{std::move(s.c_string)} { - string = std::move(s.string); - c_string = std::move(s.c_string); - length = s.length; - bufsize = s.bufsize; - s.string = nullptr; - s.c_string = nullptr; s.length = 0; s.bufsize = 0; + s.c_string = nullptr; } //---------------------------------------------------------------------- @@ -175,22 +174,34 @@ FString::~FString() // destructor //---------------------------------------------------------------------- FString& FString::operator = (const FString& s) { - _assign (s.string); + if ( &s != this ) + _assign (s.string); + return *this; } //---------------------------------------------------------------------- FString& FString::operator = (FString&& s) noexcept { - string = std::move(s.string); - c_string = std::move(s.c_string); - length = s.length; - bufsize = s.bufsize; + if ( &s != this ) + { + if ( string ) + delete[](string); + + if ( c_string ) + delete[](c_string); + + string = std::move(s.string); + length = s.length; + bufsize = s.bufsize; + c_string = std::move(s.c_string); + + s.string = nullptr; + s.length = 0; + s.bufsize = 0; + s.c_string = nullptr; + } - s.string = nullptr; - s.c_string = nullptr; - s.length = 0; - s.bufsize = 0; return *this; } diff --git a/src/fstringstream.cpp b/src/fstringstream.cpp index 3aa6b3fd..3b94b8ed 100644 --- a/src/fstringstream.cpp +++ b/src/fstringstream.cpp @@ -44,7 +44,7 @@ FStringStream::FStringStream (const FString& str, openmode mode) { } //---------------------------------------------------------------------- -FStringStream::FStringStream (FStringStream&& sstream) +FStringStream::FStringStream (FStringStream&& sstream) noexcept : std::wiostream{std::move(sstream)} , buffer{std::move(sstream.buffer)} { @@ -65,7 +65,7 @@ FStringStream& FStringStream::operator = (FStringStream&& sstream) } //---------------------------------------------------------------------- -void FStringStream::swap (FStringStream& sstream) +void FStringStream::swap (FStringStream& sstream) noexcept { std::wiostream::swap(sstream); buffer.swap(sstream.buffer); diff --git a/src/fswitch.cpp b/src/fswitch.cpp index 572a5890..6bef30ec 100644 --- a/src/fswitch.cpp +++ b/src/fswitch.cpp @@ -35,14 +35,14 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FSwitch::FSwitch(FWidget* parent) - : FToggleButton(parent) + : FToggleButton{parent} { setButtonWidth(11); } //---------------------------------------------------------------------- FSwitch::FSwitch (const FString& txt, FWidget* parent) - : FToggleButton(txt, parent) + : FToggleButton{txt, parent} , switch_offset_pos(txt.getLength() + 1) { setButtonWidth(11); diff --git a/src/ftextview.cpp b/src/ftextview.cpp index 96aacf77..b23fae45 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -42,7 +42,7 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FTextView::FTextView(FWidget* parent) - : FWidget(parent) + : FWidget{parent} { init(); } diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index 792b2144..eff08b2b 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -40,7 +40,7 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FToggleButton::FToggleButton (FWidget* parent) - : FWidget(parent) + : FWidget{parent} { init(); @@ -55,7 +55,7 @@ FToggleButton::FToggleButton (FWidget* parent) //---------------------------------------------------------------------- FToggleButton::FToggleButton (const FString& txt, FWidget* parent) - : FWidget(parent) + : FWidget{parent} { FToggleButton::setText(txt); // call own method init(); diff --git a/src/ftooltip.cpp b/src/ftooltip.cpp index cb4086a8..570b24d0 100644 --- a/src/ftooltip.cpp +++ b/src/ftooltip.cpp @@ -34,14 +34,14 @@ namespace finalcut // constructor and destructor //---------------------------------------------------------------------- FToolTip::FToolTip (FWidget* parent) - : FWindow(parent) + : FWindow{parent} { init(); } //---------------------------------------------------------------------- FToolTip::FToolTip (const FString& txt, FWidget* parent) - : FWindow(parent) + : FWindow{parent} , text{txt} { init(); diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 3fd5de25..13769994 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -60,8 +60,8 @@ uInt FWidget::modal_dialog_counter{}; // constructors and destructor //---------------------------------------------------------------------- FWidget::FWidget (FWidget* parent, bool disable_alt_screen) - : FVTerm( ! (bool(parent) || root_widget), disable_alt_screen) - , FObject(parent) + : FVTerm{ ! (bool(parent) || root_widget), disable_alt_screen} + , FObject{parent} { // init bit field with 0 memset (&flags, 0, sizeof(flags)); diff --git a/src/fwindow.cpp b/src/fwindow.cpp index f3ce0f02..79e09eb4 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -44,7 +44,7 @@ FWindow* FWindow::previous_window{nullptr}; // constructor and destructor //---------------------------------------------------------------------- FWindow::FWindow(FWidget* parent) - : FWidget(parent) + : FWidget{parent} { setWindowWidget(); FRect geometry {getTermGeometry()}; diff --git a/src/include/final/fapplication.h b/src/include/final/fapplication.h index 94483c7c..565ce44e 100644 --- a/src/include/final/fapplication.h +++ b/src/include/final/fapplication.h @@ -149,6 +149,7 @@ class FApplication : public FWidget void init (uInt64, uInt64); static void cmd_options (const int&, char*[]); static FStartOptions& getStartOptions(); + void destroyLog(); void findKeyboardWidget(); bool isKeyPressed() const; void keyPressed(); diff --git a/src/include/final/flistbox.h b/src/include/final/flistbox.h index 5ae4058e..85742216 100644 --- a/src/include/final/flistbox.h +++ b/src/include/final/flistbox.h @@ -350,7 +350,7 @@ inline FListBox::FListBox ( Iterator first , Iterator last , InsertConverter convert , FWidget* parent ) - : FWidget(parent) + : FWidget{parent} { init(); @@ -366,7 +366,7 @@ template inline FListBox::FListBox ( Container container , LazyConverter convert , FWidget* parent ) - : FWidget(parent) + : FWidget{parent} { init(); insert (container, convert); diff --git a/src/include/final/fstringstream.h b/src/include/final/fstringstream.h index f6b2458e..c691c125 100644 --- a/src/include/final/fstringstream.h +++ b/src/include/final/fstringstream.h @@ -69,7 +69,7 @@ class FStringStream : public std::wiostream FStringStream (const FStringStream&) = delete; // Move constructor - FStringStream (FStringStream&&); + FStringStream (FStringStream&&) noexcept; // Destructor ~FStringStream(); @@ -81,7 +81,7 @@ class FStringStream : public std::wiostream FStringStream& operator = (FStringStream&& sstream); virtual const FString getClassName() const; - void swap (FStringStream&); + void swap (FStringStream&) noexcept; void clear(); std::wstringbuf* rdbuf() const; FString str() const; @@ -111,7 +111,7 @@ inline FString FStringStream::str() const // FStringStream non-member function //---------------------------------------------------------------------- -inline void swap (FStringStream& a, FStringStream& b) +inline void swap (FStringStream& a, FStringStream& b) noexcept { a.swap(b); } diff --git a/src/sgr_optimizer.cpp b/src/sgr_optimizer.cpp index 87eba5b4..74cc3c57 100644 --- a/src/sgr_optimizer.cpp +++ b/src/sgr_optimizer.cpp @@ -35,7 +35,7 @@ namespace finalcut // constructors and destructor //---------------------------------------------------------------------- SGRoptimizer::SGRoptimizer (attributebuffer& sequence) - : seq(sequence) + : seq{sequence} { } //---------------------------------------------------------------------- diff --git a/test/fstring-test.cpp b/test/fstring-test.cpp index 5e468441..8e7c9d28 100644 --- a/test/fstring-test.cpp +++ b/test/fstring-test.cpp @@ -447,6 +447,7 @@ void FStringTest::assignmentTest() CPPUNIT_ASSERT ( ! s9 ); CPPUNIT_ASSERT ( s9.isNull() ); CPPUNIT_ASSERT ( s9.isEmpty() ); + finalcut::FString s10("abc"); const finalcut::FString s11 = std::move(s10); CPPUNIT_ASSERT ( s11 );