Changeset 1287

Show
Ignore:
Timestamp:
10/16/07 13:52:29 (11 months ago)
Author:
calvin
Message:

pattern editor wave dropdown updates when a wave column is changed, fix crash when working on selections bigger than current pattern, also fix crash on song-clear or app-close or delete-machine because of wrongly attached/detached plugin event handlers in pattern editor

Location:
trunk/src/buzelib
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/buzelib/PatternEditor/PatternEditorInner.cpp

    r1270 r1287  
    223223        rc->bottom = select_end.y * skip; 
    224224        if (select_start.x == -1) return false; 
     225 
     226        // make sure selection is valid in case we made the selection on a bigger 
     227        // pattern and now try to copy from a smaller where the selection goes  
     228        // outside the pattern extensions 
     229        if (rc->left < 0) rc->left = 0; 
     230        if (rc->left >= columns.size()) rc->left = columns.size() -1; 
     231        if (rc->right < 0) rc->right = 0; 
     232        if (rc->right >= columns.size()) rc->right = columns.size() -1; 
     233        if (rc->top < 0) rc->top = 0; 
     234        if (rc->top >= total_rows) rc->top = total_rows -1; 
     235        if (rc->bottom < 0) rc->bottom = 0; 
     236        if (rc->bottom >= total_rows) rc->bottom = total_rows -1; 
    225237        return true; 
    226238} 
  • trunk/src/buzelib/PatternView.cpp

    r1286 r1287  
    221221        mainFrame->addTimerHandler(this); 
    222222 
    223         machine->addEventHandler(this); 
    224223        return 0; 
    225224} 
     
    233232 
    234233LRESULT CPatternView::OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { 
    235         machine->removeEventHandler(this); 
    236234 
    237235        setPattern(0,0); // in case pattern is deleted and window updated before window is fully destroyed 
     
    10381036void CPatternView::setPattern(zzub::metaplugin* toMachine, zzub::pattern* toPattern) { 
    10391037 
     1038        if (machine != 0) machine->removeEventHandler(this); 
     1039 
    10401040        if (toMachine == 0 && toPattern == 0) { 
    10411041                this->pattern = 0; 
     
    10511051        bindPatternEditor(); 
    10521052        bindMachinePatternPanel(); 
     1053 
     1054        if (machine != 0) machine->addEventHandler(this); 
    10531055} 
    10541056 
     
    15531555        const PATTERNCOLUMN& col = patternEditor.GetColumn(patternEditor.editor.drag_to.x); 
    15541556        pastePatternTrack(selection, patternEditor.editor.drag_to.y * patternEditor.GetSkip(), col.group, col.track, col.column); 
     1557        delete selection; 
    15551558        return 0; 
    15561559} 
     
    15751578        undo->addEdit(cursor.y, col.group, col.track, col.column, oldv); 
    15761579 
    1577         if (col.type == pattern_column_type_note) { 
     1580        size_t wavec = track->getWaveColumn(); 
     1581 
     1582        if (col.type == pattern_column_type_note && ccol.index == 0) { 
    15781583                int wave = getSelectedWave(); 
    15791584                if (wave != -1) { 
    1580                         size_t wavec = track->getWaveColumn(); 
    1581  
    15821585                        if (wavec != no_column) { 
    15831586                                if (v == 255 || v == col.novalue) wave = track->getParam(wavec)->value_none; 
     
    15891592                } 
    15901593        } 
    1591  
    1592  
    15931594        document->undoManager.insertAndCommit(redo, undo); 
     1595 
     1596        // change selected wave in dropdown if a wave was entered 
     1597        if (wavec != no_column && col.column == wavec) { 
     1598                int wave = track->getValue(cursor.y, wavec); 
     1599                int wave_index = 0; 
     1600                for (size_t i = 0; wave > 0 && i < document->player->getWaves(); i++) { 
     1601                        wave_info_ex* entry = document->player->getWave(i); 
     1602                        int levelcount = entry->get_levels(); 
     1603                        if (levelcount) { 
     1604                                if (i == wave - 1) { 
     1605                                        waveDropDown.SetCurSel(wave_index); 
     1606                                        break; 
     1607                                } 
     1608                                wave_index++; 
     1609                        } 
     1610                } 
     1611        } 
    15941612 
    15951613        // play note 
     
    17261744        menu.InsertMenu(-1, (document->player->getSoloMachine() == machine?MF_CHECKED:0)|MF_BYPOSITION|MF_STRING, (UINT_PTR)ID_MACHINE_SOLO, "Solo Machine\tCtrl+L"); 
    17271745        menu.InsertMenu(-1, (machine->isMuted()?MF_CHECKED:0)|MF_BYPOSITION|MF_STRING, (UINT_PTR)ID_MACHINE_MUTE, "Mute Machine\tCtrl+M"); 
    1728         menu.InsertMenu(-1, (!hasPattern?MF_GRAYED:0)|MF_BYPOSITION|MF_STRING, (UINT_PTR)ID_MACHINE_PARAMETERS, "Machine Parameters"); 
     1746        menu.InsertMenu(-1, (!hasPattern?MF_GRAYED:0)|MF_BYPOSITION|MF_STRING, (UINT_PTR)ID_MACHINE_PARAMETERS, "Machine Parameters\tShift+Enter"); 
    17291747        menu.InsertMenu(-1, MF_BYPOSITION|MF_SEPARATOR); 
    17301748        menu.InsertMenu(-1, (!hasPattern?MF_GRAYED:0)|MF_BYPOSITION|MF_STRING, (UINT_PTR)ID_PATTERN_PROPERTIES, "Pattern Properties\tCtrl+Backspace");