diff options
author | Chris Xiong <chirs241097@gmail.com> | 2016-04-09 21:52:04 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2016-04-09 21:52:04 +0800 |
commit | e0e4f9f84bb8eed6cde71ff4d67286c2e26e4693 (patch) | |
tree | 3317c3ea2b67025fbf25c8a79ae6828b2a640220 /qmidiplayer-desktop/qmpchannelswindow.cpp | |
parent | 2b46ba471830d4e6e22be5afc720adc2489efcfe (diff) | |
download | QMidiPlayer-e0e4f9f84bb8eed6cde71ff4d67286c2e26e4693.tar.xz |
Blocked thread!
Diffstat (limited to 'qmidiplayer-desktop/qmpchannelswindow.cpp')
-rw-r--r-- | qmidiplayer-desktop/qmpchannelswindow.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/qmidiplayer-desktop/qmpchannelswindow.cpp b/qmidiplayer-desktop/qmpchannelswindow.cpp index 3e43c3d..17c0893 100644 --- a/qmidiplayer-desktop/qmpchannelswindow.cpp +++ b/qmidiplayer-desktop/qmpchannelswindow.cpp @@ -1,3 +1,4 @@ +#include <cstdio> #include <QCheckBox> #include <QPushButton> #include <QComboBox> @@ -15,7 +16,7 @@ qmpChannelsWindow::qmpChannelsWindow(QWidget *parent) : connect(this,SIGNAL(dialogClosing()),parent,SLOT(dialogClosed())); mapper=qmpMainWindow::getInstance()->getPlayer()->getMidiMapper(); cha=new QPixmap(":/img/ledon.png");chi=new QPixmap(":/img/ledoff.png"); - cb=new qmpCWNoteOnCB(); + cb=new qmpCWNoteOnCB();fused=callbacksc=cbcnt=0; qmpMainWindow::getInstance()->getPlayer()->setNoteOnCallBack(cb,NULL); connect(cb,SIGNAL(onNoteOn()),this,SLOT(updateChannelActivity())); int devc=mapper->enumDevices(); @@ -78,6 +79,7 @@ void qmpChannelsWindow::moveEvent(QMoveEvent *event) void qmpChannelsWindow::updateChannelActivity() { + ++callbacksc; for(int i=0;i<16;++i) ui->twChannels->item(i,0)->setIcon( qmpMainWindow::getInstance()->getPlayer()->getChstates()[i]?*cha:*chi); @@ -89,7 +91,19 @@ void qmpChannelsWindow::channelWindowsUpdate() { for(int i=0;i<16;++i) ((QLabel*)ui->twChannels->cellWidget(i,4))->setText(""); - return; + connect(cb,SIGNAL(onNoteOn()),this,SLOT(updateChannelActivity())); + fused=0;return; + } + ++cbcnt; + if(cbcnt>15) + { + if(callbacksc>8192) + { + disconnect(cb,SIGNAL(onNoteOn()),this,SLOT(updateChannelActivity())); + fprintf(stderr,"Fuse!\n");fused=1; + } + cbcnt=0; + callbacksc=0; } for(int i=0;i<16;++i) { @@ -97,6 +111,15 @@ void qmpChannelsWindow::channelWindowsUpdate() int b,p; qmpMainWindow::getInstance()->getPlayer()->getChannelPreset(i,&b,&p,nm); sprintf(data,"%d:%d %s",b,p,nm); + if(fused) + { + if(strcmp(((QLabel*)ui->twChannels->cellWidget(i,4))-> + text().toStdString().c_str(),data)) + { + connect(cb,SIGNAL(onNoteOn()),this,SLOT(updateChannelActivity())); + fused=0; + } + } ((QLabel*)ui->twChannels->cellWidget(i,4))->setText(data); ui->twChannels->item(i,0)->setIcon( qmpMainWindow::getInstance()->getPlayer()->getChstates()[i]?*cha:*chi); |