Skip to content

Commit

Permalink
Lots of bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
blablack committed Nov 3, 2014
1 parent c2a1ac5 commit fba1650
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/core/src/basics/drumkit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Drumkit* Drumkit::load_from( XMLNode* node, const QString& dk_path )
}
else {
WARNINGLOG( "componentList node not found" );
DrumkitComponent* pDrumkitComponent = new DrumkitComponent( 0, "main" );
DrumkitComponent* pDrumkitComponent = new DrumkitComponent( 0, "Main" );
drumkit->get_components()->push_back(pDrumkitComponent);
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/src/basics/song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ Song* SongReader::readSong( const QString& filename )
}
}
else {
DrumkitComponent* pDrumkitComponent = new DrumkitComponent( 0, "main" );
DrumkitComponent* pDrumkitComponent = new DrumkitComponent( 0, "Main" );
song->get_components()->push_back(pDrumkitComponent);
}

Expand Down
36 changes: 30 additions & 6 deletions src/core/src/helpers/legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,44 @@ Drumkit* Legacy::load_drumkit( const QString& dk_path ) {
if( sFilename.isEmpty() ) {
ERRORLOG( "filename back compability node is empty" );
} else {

Sample* sample = new Sample( dk_path+"/"+sFilename );
DrumkitComponent* dmCompo = new DrumkitComponent( 0, "Main" );
drumkit->get_components()->push_back(dmCompo);
InstrumentComponent* component = new InstrumentComponent( 0 );

InstrumentLayer* layer = new InstrumentLayer( sample );
bool p_foundMainCompo = false;
for (std::vector<DrumkitComponent*>::iterator it = drumkit->get_components()->begin() ; it != drumkit->get_components()->end(); ++it) {
DrumkitComponent* existing_compo = *it;
if( existing_compo->get_name().compare("Main") == 0) {
p_foundMainCompo = true;
break;
}
}

if ( !p_foundMainCompo ) {
DrumkitComponent* dmCompo = new DrumkitComponent( 0, "Main" );
drumkit->get_components()->push_back(dmCompo);
}

InstrumentComponent* component = new InstrumentComponent( 0 );
InstrumentLayer* layer = new InstrumentLayer( sample );
component->set_layer( layer, 0 );
instrument->get_components()->push_back( component );

}
} else {
int n = 0;
DrumkitComponent* dmCompo = new DrumkitComponent( 0, "Main" );
drumkit->get_components()->push_back(dmCompo);
bool p_foundMainCompo = false;
for (std::vector<DrumkitComponent*>::iterator it = drumkit->get_components()->begin() ; it != drumkit->get_components()->end(); ++it) {
DrumkitComponent* existing_compo = *it;
if( existing_compo->get_name().compare("Main") == 0) {
p_foundMainCompo = true;
break;
}
}

if ( !p_foundMainCompo ) {
DrumkitComponent* dmCompo = new DrumkitComponent( 0, "Main" );
drumkit->get_components()->push_back(dmCompo);
}
InstrumentComponent* component = new InstrumentComponent( 0 );

XMLNode layer_node = instrument_node.firstChildElement( "layer" );
Expand Down
1 change: 0 additions & 1 deletion src/core/src/hydrogen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2489,7 +2489,6 @@ int Hydrogen::loadDrumkit( Drumkit *drumkitInfo )
songCompoList->push_back( p_newCompo );
}


//current instrument list
InstrumentList *songInstrList = getSong()->get_instrument_list();

Expand Down
28 changes: 28 additions & 0 deletions src/gui/src/Mixer/Mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,34 @@ void Mixer::updateMixer()
pLine->updateMixerLine();
}

if( compoList->size() < m_pComponentMixerLine.size() ) {
std::vector<int>* p_ids_to_delete = new std::vector<int>();
for (std::map<int, ComponentMixerLine*>::iterator it=m_pComponentMixerLine.begin(); it!=m_pComponentMixerLine.end(); ++it) {

bool p_foundExistingRelatedComponent = false;
for ( std::vector<DrumkitComponent*>::iterator it2 = compoList->begin() ; it2 != compoList->end(); ++it2 ) {
DrumkitComponent* p_compo = *it2;
if( p_compo->get_id() == it->first ) {
p_foundExistingRelatedComponent = true;
break;
}
}
if( !p_foundExistingRelatedComponent )
p_ids_to_delete->push_back( it->first ) ;
}

for ( std::vector<int>::iterator it = p_ids_to_delete->begin() ; it != p_ids_to_delete->end(); ++it ) {
int p_compoID = *it;
delete m_pComponentMixerLine[p_compoID];
m_pComponentMixerLine.erase( p_compoID );

int newWidth = MIXER_STRIP_WIDTH * ( nInstruments + nCompo );
if ( m_pFaderPanel->width() != newWidth ) {
m_pFaderPanel->resize( newWidth, height() );
}
}
}

if (nMuteClicked == nInstruments - 1) {
// find the not muted button
for (uint i = 0; i < nInstruments; i++) {
Expand Down
2 changes: 0 additions & 2 deletions src/gui/src/PatternEditor/DrumPatternEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,6 @@ void DrumPatternEditor::functionDropInstrumentRedoAction( QString sDrumkitName,
QString DrumPatternEditor::renameCompo( QString OriginalName )
{
std::string utf8_text = OriginalName.toUtf8().constData();
std::cerr<<"renameCompo "<<utf8_text<<std::endl;
std::vector<DrumkitComponent*>* compoList = Hydrogen::get_instance()->getSong()->get_components();
for (std::vector<DrumkitComponent*>::iterator it = compoList->begin() ; it != compoList->end(); ++it) {
DrumkitComponent* p_compo = *it;
Expand All @@ -1339,7 +1338,6 @@ QString DrumPatternEditor::renameCompo( QString OriginalName )

int DrumPatternEditor::findFreeCompoID( int startingPoint )
{
std::cerr<<"findFreeCompoID "<<startingPoint<<std::endl;
bool p_foundFreeSlot = true;
std::vector<DrumkitComponent*>* compoList = Hydrogen::get_instance()->getSong()->get_components();
for (std::vector<DrumkitComponent*>::iterator it = compoList->begin() ; it != compoList->end(); ++it) {
Expand Down

0 comments on commit fba1650

Please sign in to comment.