Skip to content

Commit

Permalink
Prevention of any virtual function being called by constructors or de…
Browse files Browse the repository at this point in the history
…structors
  • Loading branch information
gansm committed Jul 16, 2024
1 parent 2c86fc8 commit 51ee4d4
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 20 deletions.
4 changes: 2 additions & 2 deletions final/dialog/fdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ void FDialog::setBorder (bool enable)
void FDialog::resetColors()
{
const auto& wc = getColorTheme();
setForegroundColor (wc->dialog.fg);
setBackgroundColor (wc->dialog.bg);
FWidget::setForegroundColor (wc->dialog.fg);
FWidget::setBackgroundColor (wc->dialog.bg);
FWidget::resetColors();
}

Expand Down
2 changes: 1 addition & 1 deletion final/dialog/fmessagebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ void FMessageBox::adjustButtons()
const auto& root_widget = getRootWidget();
FDialog::setWidth(btn_width + 5);
max_width = root_widget ? root_widget->getClientWidth() : 80;
setX (int((max_width - getWidth()) / 2));
FWindow::setX (int((max_width - getWidth()) / 2));
}

const auto btn_x = int((getWidth() - btn_width) / 2);
Expand Down
4 changes: 2 additions & 2 deletions final/menu/fmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ void FMenu::calculateDimensions()
const int adjust_X = adjustX(getX());

// set widget geometry
setGeometry ( FPoint{adjust_X, getY()}
, FSize{max_item_width + 2, getCount() + 2} );
FWindow::setGeometry ( FPoint{adjust_X, getY()}
, FSize{max_item_width + 2, getCount() + 2} );

// set geometry of all items
const int item_X = 1;
Expand Down
4 changes: 2 additions & 2 deletions final/menu/fmenubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ FMenuBar::~FMenuBar() // destructor
void FMenuBar::resetColors()
{
const auto& wc = getColorTheme();
setForegroundColor (wc->menu.fg);
setBackgroundColor (wc->menu.bg);
FWidget::setForegroundColor (wc->menu.fg);
FWidget::setBackgroundColor (wc->menu.bg);
FWidget::resetColors();
}

Expand Down
5 changes: 4 additions & 1 deletion final/widget/fbutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2012-2023 Markus Gans *
* Copyright 2012-2024 Markus Gans *
* *
* FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
Expand Down Expand Up @@ -60,6 +60,9 @@ namespace finalcut
class FButton : public FWidget
{
public:
// Using-declaration
using FWidget::delAccelerator;

// Constructors
explicit FButton (FWidget* = nullptr);
explicit FButton (FString&&, FWidget* = nullptr);
Expand Down
3 changes: 2 additions & 1 deletion final/widget/flabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2014-2023 Markus Gans *
* Copyright 2014-2024 Markus Gans *
* *
* FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
Expand Down Expand Up @@ -64,6 +64,7 @@ class FLabel : public FWidget
public:
// Using-declaration
using FWidget::setEnable;
using FWidget::delAccelerator;

// Constructor
explicit FLabel (FWidget* = nullptr);
Expand Down
12 changes: 6 additions & 6 deletions final/widget/flineedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,19 @@ void FLineEdit::resetColors()
{
if ( hasFocus() )
{
setForegroundColor (wc->input_field.focus_fg);
setBackgroundColor (wc->input_field.focus_bg);
FWidget::setForegroundColor (wc->input_field.focus_fg);
FWidget::setBackgroundColor (wc->input_field.focus_bg);
}
else
{
setForegroundColor (wc->input_field.fg);
setBackgroundColor (wc->input_field.bg);
FWidget::setForegroundColor (wc->input_field.fg);
FWidget::setBackgroundColor (wc->input_field.bg);
}
}
else // inactive
{
setForegroundColor (wc->input_field.inactive_fg);
setBackgroundColor (wc->input_field.inactive_bg);
FWidget::setForegroundColor (wc->input_field.inactive_fg);
FWidget::setBackgroundColor (wc->input_field.inactive_bg);
}

FWidget::resetColors();
Expand Down
4 changes: 2 additions & 2 deletions final/widget/fscrollview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ void FScrollView::setViewportPrint (bool enable)
void FScrollView::resetColors()
{
const auto& wc = getColorTheme();
setForegroundColor (wc->dialog.fg);
setBackgroundColor (wc->dialog.bg);
FWidget::setForegroundColor (wc->dialog.fg);
FWidget::setBackgroundColor (wc->dialog.bg);
FWidget::resetColors();
}

Expand Down
1 change: 1 addition & 0 deletions final/widget/fscrollview.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class FScrollView : public FWidget
public:
// Using-declaration
using FWidget::setGeometry;
using FWidget::delAccelerator;
using FWidget::print;

// Constructor
Expand Down
8 changes: 7 additions & 1 deletion final/widget/fstatusbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2014-2023 Markus Gans *
* Copyright 2014-2024 Markus Gans *
* *
* FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
Expand Down Expand Up @@ -73,6 +73,9 @@ class FStatusBar;
class FStatusKey : public FWidget
{
public:
// Using-declaration
using FWidget::delAccelerator;

// Constructors
explicit FStatusKey (FWidget* = nullptr);
FStatusKey (FKey, FString&&, FWidget* = nullptr);
Expand Down Expand Up @@ -184,6 +187,9 @@ inline void FStatusKey::setConnectedStatusbar (FStatusBar* sb)
class FStatusBar : public FWindow
{
public:
// Using-declaration
using FWidget::delAccelerator;

// Constructor
explicit FStatusBar (FWidget* = nullptr);

Expand Down
3 changes: 2 additions & 1 deletion final/widget/ftogglebutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2014-2023 Markus Gans *
* Copyright 2014-2024 Markus Gans *
* *
* FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
Expand Down Expand Up @@ -64,6 +64,7 @@ class FToggleButton : public FWidget
public:
// Using-declaration
using FWidget::setGeometry;
using FWidget::delAccelerator;

// Constructors
explicit FToggleButton (FWidget* = nullptr);
Expand Down
2 changes: 1 addition & 1 deletion final/widget/ftooltip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void FToolTip::calculateDimensions()
const auto& r = getRootWidget();
int x = r ? 1 + int((r->getWidth() - w) / 2) : 1;
int y = r ? 1 + int((r->getHeight() - h) / 2) : 1;
setGeometry (FPoint{x, y}, FSize{w, h});
FWidget::setGeometry (FPoint{x, y}, FSize{w, h});
}

//----------------------------------------------------------------------
Expand Down

0 comments on commit 51ee4d4

Please sign in to comment.