GUI: fix sample paste crash
This commit is contained in:
parent
a8da4f0dba
commit
9c4fed2f4e
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
#include "../ta-log.h"
|
||||||
#include <fmt/printf.h>
|
#include <fmt/printf.h>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
|
@ -712,6 +713,9 @@ void FurnaceGUI::doAction(int what) {
|
||||||
DivSample* sample=e->song.sample[curSample];
|
DivSample* sample=e->song.sample[curSample];
|
||||||
sample->prepareUndo(true);
|
sample->prepareUndo(true);
|
||||||
int pos=(sampleSelStart==-1 || sampleSelStart==sampleSelEnd)?sample->samples:sampleSelStart;
|
int pos=(sampleSelStart==-1 || sampleSelStart==sampleSelEnd)?sample->samples:sampleSelStart;
|
||||||
|
if (pos>=(int)sample->samples) pos=sample->samples-1;
|
||||||
|
if (pos<0) pos=0;
|
||||||
|
logV("paste position: %d",pos);
|
||||||
|
|
||||||
e->lockEngine([this,sample,pos]() {
|
e->lockEngine([this,sample,pos]() {
|
||||||
if (!sample->insert(pos,sampleClipboardLen)) {
|
if (!sample->insert(pos,sampleClipboardLen)) {
|
||||||
|
@ -739,6 +743,8 @@ void FurnaceGUI::doAction(int what) {
|
||||||
DivSample* sample=e->song.sample[curSample];
|
DivSample* sample=e->song.sample[curSample];
|
||||||
sample->prepareUndo(true);
|
sample->prepareUndo(true);
|
||||||
int pos=(sampleSelStart==-1 || sampleSelStart==sampleSelEnd)?0:sampleSelStart;
|
int pos=(sampleSelStart==-1 || sampleSelStart==sampleSelEnd)?0:sampleSelStart;
|
||||||
|
if (pos>=(int)sample->samples) pos=sample->samples-1;
|
||||||
|
if (pos<0) pos=0;
|
||||||
|
|
||||||
e->lockEngine([this,sample,pos]() {
|
e->lockEngine([this,sample,pos]() {
|
||||||
if (sample->depth==8) {
|
if (sample->depth==8) {
|
||||||
|
@ -767,6 +773,8 @@ void FurnaceGUI::doAction(int what) {
|
||||||
DivSample* sample=e->song.sample[curSample];
|
DivSample* sample=e->song.sample[curSample];
|
||||||
sample->prepareUndo(true);
|
sample->prepareUndo(true);
|
||||||
int pos=(sampleSelStart==-1 || sampleSelStart==sampleSelEnd)?0:sampleSelStart;
|
int pos=(sampleSelStart==-1 || sampleSelStart==sampleSelEnd)?0:sampleSelStart;
|
||||||
|
if (pos>=(int)sample->samples) pos=sample->samples-1;
|
||||||
|
if (pos<0) pos=0;
|
||||||
|
|
||||||
e->lockEngine([this,sample,pos]() {
|
e->lockEngine([this,sample,pos]() {
|
||||||
if (sample->depth==8) {
|
if (sample->depth==8) {
|
||||||
|
|
Loading…
Reference in a new issue