mirror of
https://github.com/LMMS/lmms.git
synced 2026-03-28 19:03:07 -04:00
Revert some of the changes made in commit88e0e94dcd. The underlying idea was that the `InstrumentTrackView` should be responsible for assigning the icon that's shown by its `TrackLabelButton`. However, this does not work because in some cases the `InstrumentTrack` that's passed into `InstrumentTrackView::determinePixmap` does not have an `Instrument` assigned. This in turn seems to be caused due to initalizations that are running in parallel in different threads. Here are the steps to reproduce the threading problem (line numbers refer to commit360254f): 1. Set a break point in line 1054 of `InstrumentTrack`, i.e. the line in `InstrumentTrack::loadInstrument` where `m_instrument` is being assigned to. 2. Set a break point in `InstrumentTrackView::determinePixmap`, e.g. inside of the first if statement. 3. Drop an instance of "Sf2 Player" onto the Song Editor. 4. The first break point in `InstrumentTrack` is hit in a thread called "lmms::Instrumen" (shown like that in my debugger). Try to step over it. 5. The second break point in `InstrumentTrackView` now gets hit before the code is stepped over. This time we are in the thread called "lmms". I guess this is the GUI main thread. 6. Continue execution. If you now switch to the application then the icon is shown. I guess the debugger is halted long enough in the main thread so that the InstrumentTrack gets an instrument assigned in another thread. If you delete/disable the break point in `InstrumentTrack::determinePixmap` and follow the coarse steps above then the icon is not shown because the track has no instrument. The current fix still delegates to the `InstrumentTrackView` to determine the pixmap in hopes that one day there will be a better solution where the parent component can be fully responsible for its child component. Fixes #7116.
132 lines
3.0 KiB
C++
132 lines
3.0 KiB
C++
/*
|
|
* InstrumentTrackView.h - declaration of InstrumentTrackView class
|
|
*
|
|
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
|
*
|
|
* This file is part of LMMS - https://lmms.io
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public
|
|
* License along with this program (see COPYING); if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
* Boston, MA 02110-1301 USA.
|
|
*
|
|
*/
|
|
|
|
#ifndef LMMS_GUI_INSTRUMENT_TRACK_VIEW_H
|
|
#define LMMS_GUI_INSTRUMENT_TRACK_VIEW_H
|
|
|
|
#include "MixerChannelLcdSpinBox.h"
|
|
#include "TrackView.h"
|
|
|
|
#include "InstrumentTrack.h"
|
|
|
|
|
|
namespace lmms::gui
|
|
{
|
|
|
|
|
|
class InstrumentTrackWindow;
|
|
class Knob;
|
|
class MidiCCRackView;
|
|
class TrackContainerView;
|
|
class TrackLabelButton;
|
|
|
|
|
|
class InstrumentTrackView : public TrackView
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
InstrumentTrackView( InstrumentTrack * _it, TrackContainerView* tc );
|
|
~InstrumentTrackView() override;
|
|
|
|
InstrumentTrackWindow * getInstrumentTrackWindow();
|
|
|
|
InstrumentTrack * model()
|
|
{
|
|
return castModel<InstrumentTrack>();
|
|
}
|
|
|
|
const InstrumentTrack * model() const
|
|
{
|
|
return castModel<InstrumentTrack>();
|
|
}
|
|
|
|
static InstrumentTrackWindow * topLevelInstrumentTrackWindow();
|
|
|
|
QMenu * midiMenu()
|
|
{
|
|
return m_midiMenu;
|
|
}
|
|
|
|
// Create a menu for assigning/creating channels for this track
|
|
QMenu * createMixerMenu( QString title, QString newMixerLabel ) override;
|
|
|
|
QPixmap determinePixmap();
|
|
|
|
|
|
protected:
|
|
void modelChanged() override;
|
|
void dragEnterEvent( QDragEnterEvent * _dee ) override;
|
|
void dropEvent( QDropEvent * _de ) override;
|
|
|
|
|
|
private slots:
|
|
void toggleInstrumentWindow( bool _on );
|
|
void toggleMidiCCRack();
|
|
void activityIndicatorPressed();
|
|
void activityIndicatorReleased();
|
|
|
|
void midiInSelected();
|
|
void midiOutSelected();
|
|
void midiConfigChanged();
|
|
|
|
void assignMixerLine( int channelIndex );
|
|
void createMixerLine();
|
|
|
|
void handleConfigChange(QString cls, QString attr, QString value);
|
|
|
|
private:
|
|
static QPixmap determinePixmap(InstrumentTrack* instrumentTrack);
|
|
|
|
private:
|
|
InstrumentTrackWindow * m_window;
|
|
|
|
// widgets in track-settings-widget
|
|
TrackLabelButton * m_tlb;
|
|
MixerChannelLcdSpinBox* m_mixerChannelNumber;
|
|
Knob * m_volumeKnob;
|
|
Knob * m_panningKnob;
|
|
FadeButton * m_activityIndicator;
|
|
|
|
QMenu * m_midiMenu;
|
|
|
|
QAction * m_midiInputAction;
|
|
QAction * m_midiOutputAction;
|
|
|
|
std::unique_ptr<MidiCCRackView> m_midiCCRackView;
|
|
|
|
QPoint m_lastPos;
|
|
|
|
FadeButton * getActivityIndicator() override
|
|
{
|
|
return m_activityIndicator;
|
|
}
|
|
|
|
friend class InstrumentTrackWindow;
|
|
} ;
|
|
|
|
|
|
} // namespace lmms::gui
|
|
|
|
#endif // LMMS_GUI_INSTRUMENT_TRACK_VIEW_H
|