From 45ab56dd71f38a203ea899af6b664451254cfc59 Mon Sep 17 00:00:00 2001 From: regulus79 <117475203+regulus79@users.noreply.github.com> Date: Fri, 13 Jun 2025 21:30:11 -0400 Subject: [PATCH] Fix Auto Resize when Dragging Sample Files onto Sample Clips (#7952) Changes things so that only sample clips with auto-resize enabled will automatically resize to the sample length when dragging-dropping a sample from the sidebar onto a sample clip. Non-auto-resize clips will keep their original length, but still update so that their start time offset is 0. --- src/core/SampleClip.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/core/SampleClip.cpp b/src/core/SampleClip.cpp index 11aabc2ff..007265c0c 100644 --- a/src/core/SampleClip.cpp +++ b/src/core/SampleClip.cpp @@ -179,26 +179,21 @@ void SampleClip::setSampleBuffer(std::shared_ptr sb) void SampleClip::setSampleFile(const QString& sf) { - int length = 0; - + // Remove any prior offset in the clip + setStartTimeOffset(0); if (!sf.isEmpty()) { - //Otherwise set it to the sample's length m_sample = Sample(gui::SampleLoader::createBufferFromFile(sf)); - length = sampleLength(); + updateLength(); } - - if (length == 0) + else { - //If there is no sample, make the clip a bar long + // If there is no sample, make the clip a bar long float nom = Engine::getSong()->getTimeSigModel().getNumerator(); float den = Engine::getSong()->getTimeSigModel().getDenominator(); - length = DefaultTicksPerBar * (nom / den); + changeLength(DefaultTicksPerBar * (nom / den)); } - changeLength(length); - setStartTimeOffset(0); - emit sampleChanged(); emit playbackPositionChanged(); }