Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit d81ebd6b authored by Thomas Eschenbacher's avatar Thomas Eschenbacher

partially reverted bad commit 23a21c69

which removed the keyword 'virtual' in many places and caused
several defects, including memory leaks
parent b45b8501
......@@ -108,42 +108,42 @@ namespace Kwave
virtual ~MainWidget();
/** Returns the current zoom factor [samples/pixel] */
double zoom() const Q_DECL_OVERRIDE;
virtual double zoom() const Q_DECL_OVERRIDE;
/** Returns the width of the current view in pixels */
int visibleWidth() const Q_DECL_OVERRIDE;
virtual int visibleWidth() const Q_DECL_OVERRIDE;
/** Returns the width of the current view in samples */
sample_index_t visibleSamples() const Q_DECL_OVERRIDE;
virtual sample_index_t visibleSamples() const Q_DECL_OVERRIDE;
/** Returns the current start position of the visible area [samples] */
virtual sample_index_t visibleOffset() { return m_offset; }
/** Returns the preferred size of the widget */
QSize sizeHint () const Q_DECL_OVERRIDE { return m_preferred_size; }
virtual QSize sizeHint () const Q_DECL_OVERRIDE { return m_preferred_size; }
protected:
/** @see Qt XDND documentation */
void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
virtual void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
/**
* For dropping data into an empty signal
* @see Qt XDND documentation
*/
void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
virtual void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
/**
* Called if the main widget has been resized and resizes/moves
* the signal widget and the channel controls
*/
void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
/** slot for mouse wheel events, for scrolling/zooming */
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
/** @see QWidget::closeEvent() */
void closeEvent(QCloseEvent *e) Q_DECL_OVERRIDE;
virtual void closeEvent(QCloseEvent *e) Q_DECL_OVERRIDE;
protected slots:
......@@ -159,7 +159,7 @@ namespace Kwave
* @retval -ENOSYS is returned if the command is unknown in this
* component
*/
int executeCommand(const QString &command) Q_DECL_OVERRIDE;
virtual int executeCommand(const QString &command) Q_DECL_OVERRIDE;
/**
* Sets the display offset [samples] and refreshes the screen.
......@@ -172,7 +172,7 @@ namespace Kwave
* Scrolls the display so that the given position gets visible,
* centered within the display if possible.
*/
void scrollTo(sample_index_t pos) Q_DECL_OVERRIDE;
virtual void scrollTo(sample_index_t pos) Q_DECL_OVERRIDE;
/**
* sets a new zoom factor [samples/pixel], does not refresh the screen
......@@ -180,7 +180,7 @@ namespace Kwave
* to [length/width...1/width] (from full display to
* one visible sample only)
*/
void setZoom(double new_zoom) Q_DECL_OVERRIDE;
virtual void setZoom(double new_zoom) Q_DECL_OVERRIDE;
/**
* Zooms into the selected range between the left and right marker.
......
......@@ -50,10 +50,10 @@ namespace Kwave
static void showMessage(const QString &message);
/** handles the painting of this splash screen */
void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
virtual void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
/** hides the splash screen on mouse click */
void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
/** should be called when the splashscreen is no longer needed */
void done();
......
......@@ -153,16 +153,16 @@ namespace Kwave
protected slots:
/** @see QWidget::closeEvent() */
void closeEvent(QCloseEvent *e) Q_DECL_OVERRIDE;
virtual void closeEvent(QCloseEvent *e) Q_DECL_OVERRIDE;
/** @see Qt XDND documentation */
void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
virtual void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
/**
* For dropping data into an empty signal
* @see Qt XDND documentation
*/
void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
virtual void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
private slots:
......
......@@ -114,10 +114,10 @@ namespace Kwave
protected slots:
void mousePressEvent(QMouseEvent * ) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent * ) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent * ) Q_DECL_OVERRIDE;
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QMouseEvent * ) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent(QMouseEvent * ) Q_DECL_OVERRIDE;
virtual void mouseMoveEvent(QMouseEvent * ) Q_DECL_OVERRIDE;
virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
protected:
......
......@@ -128,7 +128,7 @@ namespace Kwave
protected slots:
/** overwritten to call accept() of the KFileWidget and saveConfig() */
void accept() Q_DECL_OVERRIDE;
virtual void accept() Q_DECL_OVERRIDE;
/** save current settings */
void saveConfig();
......
......@@ -70,13 +70,13 @@ namespace Kwave
* Shows a dialog for setting up the filter plugin
* @see Kwave::Plugin::setup
*/
QStringList *setup(QStringList &previous_params) Q_DECL_OVERRIDE;
virtual QStringList *setup(QStringList &previous_params) Q_DECL_OVERRIDE;
/**
* Does the filter operation and/or pre-listen
* @param params list of strings with parameters
*/
void run(QStringList params) Q_DECL_OVERRIDE;
virtual void run(QStringList params) Q_DECL_OVERRIDE;
/**
* Returns true if the parameters have changed during pre-listen.
......@@ -105,7 +105,7 @@ namespace Kwave
* Returns a text for the progress dialog if enabled.
* (should already be localized)
*/
QString progressText() Q_DECL_OVERRIDE;
virtual QString progressText() Q_DECL_OVERRIDE;
signals:
......
......@@ -59,7 +59,7 @@ namespace Kwave
virtual void setFilter(Kwave::TransmissionFunction *func);
/** @see QWidget::paintEvent() */
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
private:
......
......@@ -81,11 +81,11 @@ namespace Kwave
protected:
void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
virtual void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
private:
/**
......
......@@ -59,7 +59,7 @@ namespace Kwave
* Returns flags describing the possible interactions with this object
* @see Kwave::ViewItem::Flags
*/
Kwave::ViewItem::Flags flags() const Q_DECL_OVERRIDE;
virtual Kwave::ViewItem::Flags flags() const Q_DECL_OVERRIDE;
/**
* Can be overwritten to return a tooltip.
......@@ -67,31 +67,31 @@ namespace Kwave
* @param ofs sample index the tooltip should refer to (unused)
* @return an already localized tooltip
*/
QString toolTip(sample_index_t &ofs) Q_DECL_OVERRIDE;
virtual QString toolTip(sample_index_t &ofs) Q_DECL_OVERRIDE;
/**
* Called to append entries to a context menu.
* @param parent context menu to add items
*/
void appendContextMenu(QMenu *parent) Q_DECL_OVERRIDE;
virtual void appendContextMenu(QMenu *parent) Q_DECL_OVERRIDE;
/**
* Returns a mouse cursor used when moving the item
*/
QCursor mouseCursor() const Q_DECL_OVERRIDE;
virtual QCursor mouseCursor() const Q_DECL_OVERRIDE;
/**
* handles updates when being moved with the mouse
* @param mouse_pos position of the mouse, in pixel coordinates
* relative to the parent widget
*/
void moveTo(const QPoint &mouse_pos) Q_DECL_OVERRIDE;
virtual void moveTo(const QPoint &mouse_pos) Q_DECL_OVERRIDE;
/**
* Called when leaving the move mode, when the mouse button
* has been released.
*/
void done() Q_DECL_OVERRIDE;
virtual void done() Q_DECL_OVERRIDE;
private slots:
......
......@@ -59,31 +59,31 @@ namespace Kwave
/**
* Called to notify the item that it has been selected.
*/
void actionSelected() Q_DECL_OVERRIDE;
virtual void actionSelected() Q_DECL_OVERRIDE;
/**
* Handles/interpretes special menu commands.
* @param command name of a menu node or command
* @return true if the name was recognized as a command and handled
*/
bool specialCommand(const QString &command) Q_DECL_OVERRIDE;
virtual bool specialCommand(const QString &command) Q_DECL_OVERRIDE;
/**
* Shows/hides the current menu node.
* @param visible true to show the item, false to hide
*/
void setVisible(bool visible) Q_DECL_OVERRIDE;
virtual void setVisible(bool visible) Q_DECL_OVERRIDE;
/**
* Returns true if the node is enabled.
*/
bool isEnabled() Q_DECL_OVERRIDE;
virtual bool isEnabled() Q_DECL_OVERRIDE;
/**
* Enables/disables the current menu node.
* @param enable true to enable the item, false to disable
*/
void setEnabled(bool enable) Q_DECL_OVERRIDE;
virtual void setEnabled(bool enable) Q_DECL_OVERRIDE;
/**
* Enables/disabled checking/selecting the item
......@@ -98,28 +98,28 @@ namespace Kwave
* Sets/removes the checkmark from the current menu item.
* @param check true to set the mark, false to remove
*/
void setChecked(bool check) Q_DECL_OVERRIDE;
virtual void setChecked(bool check) Q_DECL_OVERRIDE;
/**
* Sets the visible text of an item to a new value. (Only useful
* for a MenuItem)
* @param text the new text
*/
void setText(const QString &text) Q_DECL_OVERRIDE;
virtual void setText(const QString &text) Q_DECL_OVERRIDE;
/**
* Returns the menu nodes' icon.
*/
const QIcon icon() Q_DECL_OVERRIDE;
virtual const QIcon icon() Q_DECL_OVERRIDE;
/**
* Sets a new icon of a menu node.
* @param icon QPixmap with the icon
*/
void setIcon(const QIcon &icon) Q_DECL_OVERRIDE;
virtual void setIcon(const QIcon &icon) Q_DECL_OVERRIDE;
/** Returns the corresponding menu action */
QAction *action() Q_DECL_OVERRIDE { return &m_action; }
virtual QAction *action() Q_DECL_OVERRIDE { return &m_action; }
private slots:
......
......@@ -56,12 +56,12 @@ namespace Kwave
/**
* Always returns true, as the nodes of this type are no branches.
*/
bool isBranch() const Q_DECL_OVERRIDE { return false; }
virtual bool isBranch() const Q_DECL_OVERRIDE { return false; }
/**
* Removes all entries from the list menu.
*/
void clear() Q_DECL_OVERRIDE;
virtual void clear() Q_DECL_OVERRIDE;
/**
* Inserts a new leaf node under the corresponding submenu.
......@@ -73,7 +73,7 @@ namespace Kwave
* @param uid unique id string (might be 0)
* @return pointer to the new leaf node
*/
Kwave::MenuNode *insertLeaf(const QString &name,
virtual Kwave::MenuNode *insertLeaf(const QString &name,
const QString &command,
const QKeySequence &shortcut,
const QString &uid) Q_DECL_OVERRIDE;
......
......@@ -21,6 +21,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <new>
#include <QKeySequence>
#include <QLatin1Char>
#include <QRegExp>
......@@ -48,7 +50,7 @@ QMap<QString, QKeySequence> Kwave::MenuManager::m_standard_keys;
Kwave::MenuManager::MenuManager(QWidget *parent, QMenuBar &bar)
:QObject(parent)
{
m_menu_root = new Kwave::MenuRoot(bar);
m_menu_root = new(std::nothrow) Kwave::MenuRoot(bar);
Q_ASSERT(m_menu_root);
if (m_menu_root) {
connect(
......
......@@ -17,6 +17,8 @@
#include "config.h"
#include <new>
#include <QLatin1Char>
#include <QPixmap>
......@@ -52,7 +54,7 @@ Kwave::MenuNode::~MenuNode()
group = m_groups.begin();
}
// remove all clients
// remove all childs
clear();
// de-register from our parent
......@@ -387,7 +389,7 @@ void Kwave::MenuNode::joinGroup(const QString &group,
grp = group_list[group];
} else {
// group does not already exist, create a new one
grp = new Kwave::MenuGroup(rootNode(), group, mode);
grp = new(std::nothrow) Kwave::MenuGroup(rootNode(), group, mode);
if (grp) group_list.insert(group, grp);
}
......@@ -454,7 +456,8 @@ bool Kwave::MenuNode::specialCommand(const QString &command)
const QString uid = parser.firstParam();
const QString cmd = parser.nextParam();
if (!sub->findUID(uid)) {
Kwave::MenuList *placeholder = new Kwave::MenuList(sub, cmd, uid);
Kwave::MenuList *placeholder =
new(std::nothrow) Kwave::MenuList(sub, cmd, uid);
Q_ASSERT(placeholder);
if (!placeholder) return false;
......
......@@ -17,6 +17,8 @@
#include "config.h"
#include <new>
#include <QListIterator>
#include <KLocalizedString>
......@@ -77,8 +79,8 @@ Kwave::MenuSub *Kwave::MenuRoot::insertBranch(const QString &name,
Q_ASSERT(menu);
if (!menu) return 0;
Kwave::MenuSub *sub =
new Kwave::MenuSub(this, menu, name, command, shortcut, uid);
Kwave::MenuSub *sub = new(std::nothrow)
Kwave::MenuSub(this, menu, name, command, shortcut, uid);
Q_ASSERT(sub);
if (!sub) return 0;
......@@ -93,8 +95,8 @@ Kwave::MenuNode *Kwave::MenuRoot::insertLeaf(const QString &name,
const QKeySequence &shortcut,
const QString &uid)
{
Kwave::MenuItem *item =
new Kwave::MenuItem(this, name, command, shortcut, uid);
Kwave::MenuItem *item = new(std::nothrow)
Kwave::MenuItem(this, name, command, shortcut, uid);
Q_ASSERT(item);
if (!item) return 0;
......
......@@ -65,7 +65,7 @@ namespace Kwave
* @param shortcut keyboard shortcut, 0 if unused
* @param uid unique id string (might be 0)
*/
void insertNode(const QString &name,
virtual void insertNode(const QString &name,
const QString &position,
const QString &command,
const QKeySequence &shortcut,
......@@ -86,7 +86,7 @@ namespace Kwave
* @param uid unique id string (might be 0)
* @return pointer to the new branch node
*/
Kwave::MenuSub *insertBranch(const QString &name,
virtual Kwave::MenuSub *insertBranch(const QString &name,
const QString &command,
const QKeySequence &shortcut,
const QString &uid) Q_DECL_OVERRIDE;
......@@ -101,7 +101,7 @@ namespace Kwave
* @param uid unique id string (might be 0)
* @return pointer to the new leaf node
*/
Kwave::MenuNode *insertLeaf(const QString &name,
virtual Kwave::MenuNode *insertLeaf(const QString &name,
const QString &command,
const QKeySequence &shortcut,
const QString &uid) Q_DECL_OVERRIDE;
......@@ -111,19 +111,19 @@ namespace Kwave
* was not found or is already removed this does nothing.
* @param child pointer to the child node
*/
void removeChild(Kwave::MenuNode *child) Q_DECL_OVERRIDE;
virtual void removeChild(Kwave::MenuNode *child) Q_DECL_OVERRIDE;
/**
* Handles/interprets special menu commands.
* @param command name of a menu node or command
* @return true if the name was recognized as a command and handled
*/
bool specialCommand(const QString &command) Q_DECL_OVERRIDE;
virtual bool specialCommand(const QString &command) Q_DECL_OVERRIDE;
/**
* Returns a pointer to the list of groups
*/
QHash<QString, Kwave::MenuGroup *> &groupList() Q_DECL_OVERRIDE;
virtual QHash<QString, Kwave::MenuGroup *> &groupList() Q_DECL_OVERRIDE;
/**
* replacement for QObject::deleteLater(...), which does not work
......
......@@ -17,6 +17,8 @@
#include "config.h"
#include <new>
#include <QPixmap>
#include <KLocalizedString>
......@@ -102,8 +104,8 @@ Kwave::MenuSub *Kwave::MenuSub::insertBranch(const QString &name,
Q_ASSERT(menu);
if (!menu) return 0;
Kwave::MenuSub *sub =
new Kwave::MenuSub(this, menu, name, command, shortcut, uid);
Kwave::MenuSub *sub = new(std::nothrow)
Kwave::MenuSub(this, menu, name, command, shortcut, uid);
Q_ASSERT(sub);
if (!sub) return 0;
......@@ -122,8 +124,8 @@ Kwave::MenuNode *Kwave::MenuSub::insertLeaf(const QString &name,
Q_ASSERT(m_menu);
if (!name.length() || !m_menu) return 0;
Kwave::MenuItem *item =
new Kwave::MenuItem(this, name, command, shortcut, uid);
Kwave::MenuItem *item = new(std::nothrow)
Kwave::MenuItem(this, name, command, shortcut, uid);
Q_ASSERT(item);
if (!item) return 0;
......
......@@ -61,7 +61,7 @@ namespace Kwave
/**
* Always returns true, as the nodes of this type are branches.
*/
bool isBranch() const Q_DECL_OVERRIDE { return true; }
virtual bool isBranch() const Q_DECL_OVERRIDE { return true; }
/**
* Inserts a new branch node under the submenu. The new node
......@@ -78,7 +78,7 @@ namespace Kwave
* @param uid unique id string (might be 0)
* @return pointer to the new branch node
*/
Kwave::MenuSub *insertBranch(const QString &name,
virtual Kwave::MenuSub *insertBranch(const QString &name,
const QString &command,
const QKeySequence &shortcut,
const QString &uid) Q_DECL_OVERRIDE;
......@@ -93,13 +93,13 @@ namespace Kwave
* @param uid unique id string (might be 0)
* @return pointer to the new leaf node
*/
Kwave::MenuNode *insertLeaf(const QString &name,
virtual Kwave::MenuNode *insertLeaf(const QString &name,
const QString &command,
const QKeySequence &shortcut,
const QString &uid) Q_DECL_OVERRIDE;
/** Returns the corresponding menu action */
QAction *action() Q_DECL_OVERRIDE {
virtual QAction *action() Q_DECL_OVERRIDE {
return (m_menu) ? m_menu->menuAction() : 0;
}
......@@ -108,40 +108,40 @@ namespace Kwave
* was not found or is already removed this does nothing.
* @param child pointer to the child node
*/
void removeChild(Kwave::MenuNode *child) Q_DECL_OVERRIDE;
virtual void removeChild(Kwave::MenuNode *child) Q_DECL_OVERRIDE;
/**
* Handles/interpretes special menu commands.
* @param command name of a menu node or command
* @return true if the name was recognized as a command and handled
*/
bool specialCommand(const QString &command) Q_DECL_OVERRIDE;
virtual bool specialCommand(const QString &command) Q_DECL_OVERRIDE;
/**
* Shows/hides the current sub menu.
* @param visible true to show the sub menu, false to hide
*/
void setVisible(bool visible) Q_DECL_OVERRIDE;
virtual void setVisible(bool visible) Q_DECL_OVERRIDE;
/**
* Returns true if the node is enabled.
*/
bool isEnabled() Q_DECL_OVERRIDE;
virtual bool isEnabled() Q_DECL_OVERRIDE;
/**
* Enables/disables the current menu node.
* @param enable true to enable the item, false to disable
*/
void setEnabled(bool enable) Q_DECL_OVERRIDE;
virtual void setEnabled(bool enable) Q_DECL_OVERRIDE;
/** Returns the menu nodes' icon. */
const QIcon icon() Q_DECL_OVERRIDE;
virtual const QIcon icon() Q_DECL_OVERRIDE;
/**
* Sets a new icon of a menu node.
* @param icon QPixmap with the icon
*/
void setIcon(const QIcon &icon) Q_DECL_OVERRIDE;
virtual void setIcon(const QIcon &icon) Q_DECL_OVERRIDE;
protected:
friend class MenuRoot;
......
......@@ -100,10 +100,10 @@ namespace Kwave
private:
/** reacts to the mouse release (click) */
void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
/** repaints the pixmap */
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
private:
......
......@@ -59,7 +59,7 @@ namespace Kwave
virtual QSize minimumSize() const;
/** optimal size for the widget, @see QWidget::sizeHint() */
QSize sizeHint() const Q_DECL_OVERRIDE;
virtual QSize sizeHint() const Q_DECL_OVERRIDE;
public slots:
......@@ -96,19 +96,19 @@ namespace Kwave
protected:
/** refreshes the bitmap when resized */
void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
virtual void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
/**
* On mouse move:
* move the current viewport center to the clicked position.
*/
void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
virtual void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
/**
* On single-click with the left mouse button:
* move the current viewport center to the clicked position.
*/
void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
/**
* On double click with the left mouse button, without shift:
......@@ -119,7 +119,7 @@ namespace Kwave
* The same as above, but zoom out instead of in
* (by sending "view:zoom_out()").
*/
void mouseDoubleClickEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
virtual void mouseDoubleClickEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
protected slots:
......@@ -184,7 +184,7 @@ namespace Kwave
virtual ~WorkerThread();
/** thread function that calls calculateBitmap() */
void run() Q_DECL_OVERRIDE;
virtual void run() Q_DECL_OVERRIDE;
private:
......
......@@ -76,7 +76,7 @@ namespace Kwave
virtual QSize minimumSize() const;
/** optimal size for the widget, @see QWidget::sizeHint() */