aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2019-12-02 11:55:52 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2019-12-02 11:55:52 +0800
commit81c26b4dd3c3d11471bacfe7a4a83d2a8edac751 (patch)
tree6db653f625bf2765738f3a2169d3344e52626e7d
parentc34daa26c67f4a879ff541775c099ddc19a1dec5 (diff)
downloadQMidiPlayer-81c26b4dd3c3d11471bacfe7a4a83d2a8edac751.tar.xz
No more creepy blank action buttons that cause crashes if clicked.
If a plugin has been removed and the toolbar is reconfigured afterwards, a blank button will appear in the toolbar, which will cause a crash when clicked.
-rw-r--r--qmidiplayer-desktop/qmpcustomizewindow.cpp1
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.cpp5
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.hpp6
3 files changed, 6 insertions, 6 deletions
diff --git a/qmidiplayer-desktop/qmpcustomizewindow.cpp b/qmidiplayer-desktop/qmpcustomizewindow.cpp
index b7017b7..a2ff19c 100644
--- a/qmidiplayer-desktop/qmpcustomizewindow.cpp
+++ b/qmidiplayer-desktop/qmpcustomizewindow.cpp
@@ -44,6 +44,7 @@ void qmpCustomizeWindow::launch(int w)
std::set<std::string> s;
for(auto i=v.begin();i!=v.end();++i)
{
+ if(m.find(*i)==m.end())continue;
s.insert(*i);
QListWidgetItem* it=new QListWidgetItem(
m[*i].icon(),
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index 1715539..1df2d8e 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -625,10 +625,9 @@ void qmpMainWindow::setupWidget()
i->second.setAssignedControl((QReflectiveAction*)nullptr),
i->second.setAssignedControl((QReflectivePushButton*)nullptr);
QList<QWidget*>w=ui->buttonwidget->findChildren<QWidget*>("",Qt::FindDirectChildrenOnly);
- for(unsigned i=0;i<w.size();++i)
- delete w[i];
+ qDeleteAll(w);
QList<QAction*>a=ui->lbFileName->actions();
- for(unsigned i=0;i<a.size();++i)
+ for(int i=0;i<a.size();++i)
{
ui->lbFileName->removeAction(a[i]);
delete a[i];
diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp
index ea5209c..c8f3827 100644
--- a/qmidiplayer-desktop/qmpmainwindow.hpp
+++ b/qmidiplayer-desktop/qmpmainwindow.hpp
@@ -86,12 +86,12 @@ class QReflectivePushButton:public QPushButton
class qmpFuncPrivate
{
private:
- qmpFuncBaseIntf* _i;
+ qmpFuncBaseIntf* _i=nullptr;
QIcon _icon;
std::string des;
bool _checkable,checked;
- QReflectiveAction* asgna;
- QReflectivePushButton* asgnb;
+ QReflectiveAction* asgna=nullptr;
+ QReflectivePushButton* asgnb=nullptr;
public:
qmpFuncPrivate(){}
qmpFuncPrivate(qmpFuncBaseIntf* i,std::string _desc,const char* icon,int iconlen,bool checkable);