/[svn]/qsampler/trunk/src/qsamplerDeviceStatusForm.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerDeviceStatusForm.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2039 by capela, Thu Jan 7 19:39:47 2010 UTC revision 3667 by schoenebeck, Sun Dec 22 13:29:09 2019 UTC
# Line 1  Line 1 
1  // qsamplerDeviceStatusForm.cpp  // qsamplerDeviceStatusForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4       Copyright (C) 2010-2019, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2008, Christian Schoenebeck     Copyright (C) 2008, Christian Schoenebeck
    Copyright (C) 2010, rncbc aka Rui Nuno Capela. All rights reserved.  
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 14  Line 14 
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.     GNU General Public License for more details.
16    
17     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License along
18     along with this program; if not, write to the Free Software     with this program; if not, write to the Free Software Foundation, Inc.,
19     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20    
21  *****************************************************************************/  *****************************************************************************/
22    
# Line 27  Line 27 
27    
28  #include <QGridLayout>  #include <QGridLayout>
29    
30    #if QT_VERSION < QT_VERSION_CHECK(4, 5, 0)
31    namespace Qt {
32    const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000);
33    }
34    #endif
35    
36    
37  namespace QSampler {  namespace QSampler {
38    
# Line 36  namespace QSampler { Line 42  namespace QSampler {
42    
43  // MIDI activity pixmap common resources.  // MIDI activity pixmap common resources.
44  int      MidiActivityLED::g_iMidiActivityRefCount = 0;  int      MidiActivityLED::g_iMidiActivityRefCount = 0;
45  QPixmap *MidiActivityLED::g_pMidiActivityLedOn    = NULL;  QPixmap *MidiActivityLED::g_pMidiActivityLedOn    = nullptr;
46  QPixmap *MidiActivityLED::g_pMidiActivityLedOff   = NULL;  QPixmap *MidiActivityLED::g_pMidiActivityLedOff   = nullptr;
47    
48    
49  MidiActivityLED::MidiActivityLED ( QString sText, QWidget *pParent )  MidiActivityLED::MidiActivityLED ( QString sText, QWidget *pParent )
50          : QLabel(sText, pParent)          : QLabel(sText, pParent)
51  {  {
52          if (++g_iMidiActivityRefCount == 1) {          if (++g_iMidiActivityRefCount == 1) {
53                  g_pMidiActivityLedOn  = new QPixmap(":/icons/ledon1.png");                  g_pMidiActivityLedOn  = new QPixmap(":/images/ledon1.png");
54                  g_pMidiActivityLedOff = new QPixmap(":/icons/ledoff1.png");                  g_pMidiActivityLedOff = new QPixmap(":/images/ledoff1.png");
55          }          }
56    
57          setPixmap(*g_pMidiActivityLedOff);          setPixmap(*g_pMidiActivityLedOff);
# Line 65  MidiActivityLED::~MidiActivityLED (void) Line 71  MidiActivityLED::~MidiActivityLED (void)
71          if (--g_iMidiActivityRefCount == 0) {          if (--g_iMidiActivityRefCount == 0) {
72                  if (g_pMidiActivityLedOn)                  if (g_pMidiActivityLedOn)
73                          delete g_pMidiActivityLedOn;                          delete g_pMidiActivityLedOn;
74                  g_pMidiActivityLedOn = NULL;                  g_pMidiActivityLedOn = nullptr;
75                  if (g_pMidiActivityLedOff)                  if (g_pMidiActivityLedOff)
76                          delete g_pMidiActivityLedOff;                          delete g_pMidiActivityLedOff;
77                  g_pMidiActivityLedOff = NULL;                  g_pMidiActivityLedOff = nullptr;
78          }          }
79  }  }
80    
# Line 186  DeviceStatusForm *DeviceStatusForm::getI Line 192  DeviceStatusForm *DeviceStatusForm::getI
192  {  {
193          std::map<int, DeviceStatusForm *>::iterator iter          std::map<int, DeviceStatusForm *>::iterator iter
194                  = g_instances.find(iDeviceID);                  = g_instances.find(iDeviceID);
195          return ((iter != g_instances.end()) ? iter->second : NULL);          return ((iter != g_instances.end()) ? iter->second : nullptr);
196  }  }
197    
198    
# Line 215  void DeviceStatusForm::onDevicesChanged Line 221  void DeviceStatusForm::onDevicesChanged
221                          = Device::getDeviceIDs(pMainForm->client(), Device::Midi);                          = Device::getDeviceIDs(pMainForm->client(), Device::Midi);
222                  // hide and delete status forms whose device has been destroyed                  // hide and delete status forms whose device has been destroyed
223                  std::map<int, DeviceStatusForm *>::iterator iter = g_instances.begin();                  std::map<int, DeviceStatusForm *>::iterator iter = g_instances.begin();
224                  for ( ; iter != g_instances.end(); ++iter) {                  while (iter != g_instances.end()) {
225                          if (deviceIDs.find(iter->first) == deviceIDs.end()) {                          if (deviceIDs.find(iter->first) == deviceIDs.end()) {
226                                  iter->second->hide();                                  iter->second->hide();
227                                  delete iter->second;                                  delete iter->second;
228                                  g_instances.erase(iter);                                  // postfix increment here to avoid iterator invalidation (crash)
229                          }                                  g_instances.erase(iter++);
230                            } else ++iter;
231                  }                  }
232                  // create status forms for new devices                  // create status forms for new devices
233                  std::set<int>::iterator it = deviceIDs.begin();                  std::set<int>::iterator it = deviceIDs.begin();
# Line 238  void DeviceStatusForm::onDevicesChanged Line 245  void DeviceStatusForm::onDevicesChanged
245                                          wflags |= Qt::Tool;                                          wflags |= Qt::Tool;
246                                  // Create the form, giving it the device id.                                  // Create the form, giving it the device id.
247                                  DeviceStatusForm *pStatusForm                                  DeviceStatusForm *pStatusForm
248                                          = new DeviceStatusForm(*it, NULL, wflags);                                          = new DeviceStatusForm(*it, nullptr, wflags);
249                                  g_instances[*it] = pStatusForm;                                  g_instances[*it] = pStatusForm;
250                          }                          }
251                  }                  }

Legend:
Removed from v.2039  
changed lines
  Added in v.3667

  ViewVC Help
Powered by ViewVC