Procházet zdrojové kódy

Helix: the first macro row fills 4 slots again, no write past its arrays (#396, round 190uy)

Reported by ycollet (Fedora RPM build: the LV2 manifest helper opens LYNX-Wavecoil's editor headless and libstdc++'s
assertions abort in std::array::operator[]). HelixPlusStrip's macros / macroHandle hold Helix+'s macros 1..4
(ext::macro + j, section 4, 236 px = four knobs); since 190ml made wt::macroCount 8 (190mi's 4 became plusMacroCount),
the loop that fills them and the layout loop ran to 8: a write past both arrays (memory overwritten without the
assertions), knobs "5".."8" bound to ext::macro + 4..7 (the drawn-LFO and distortion values) and a second set of
M5..M8 handles over Helix+ 2's own (macros2 / macroHandle2, section 13).

- The fill loop runs to wt::plusMacroCount, the layout loop to macros.size(); both arrays are sized from
  plusMacroCount, with a static_assert tying them to Helix+'s value block (ext::macro + 4 == ext::lfoDraw).
- Swept the other editors (src/ui, src/plugin) for a fixed std::array indexed by a loop over a larger constant: 35
  heuristic hits, all different classes / local arrays / equal sizes; HelixEditor was the only real one.
- --round190uytest part 4 (also in --selftest): Helix's channel window off-screen, the strip has 8 macro + 2 chaos
  handles, each once inside it (before: 14). With HelixEditor.cpp built with -D_GLIBCXX_ASSERTIONS the old code aborts
  there ("Assertion '__n < this->size()' failed", Ctl*, _Nm = 4); the fixed code passes.
- CHANGELOG 0.1.33 Fixed line.

(cherry picked from commit af039546c4261daf3da9d2d5b059a69c6a57c0cd)
Ka1-S před 1 dnem
rodič
revize
79444749db
3 změnil soubory, kde provedl 63 přidání a 5 odebrání
  1. 4 0
      CHANGELOG.md
  2. 50 1
      src/Round190uyCheck.inc
  3. 9 4
      src/ui/HelixEditor.cpp

+ 4 - 0
CHANGELOG.md

@@ -363,6 +363,10 @@ The feature release. This section grows as the work lands in the 0.1.33 rollup.
   FL Studio 360) and 32 x Surge XT **961 MB** (was 1,045; FL Studio 963).
 
 **Fixed**
+- Helix's channel window (and the Wavecoil plugin's editor) no longer writes past the end of its macro controls (#396).
+  Since macros 5 to 8 were added, opening it filled eight macro slots into room for four: builds with libstdc++
+  assertions (Fedora's RPM build, whose LV2 step opens the editor) aborted, and other builds overwrote memory. Its first
+  macro row now holds macros 1 to 4 again, and 5 to 8 stay in their own row. Reported by ycollet.
 - Hosted plugins are told where playback really is. With nothing in the Playlist, Song mode plays on, but plugins were
   told it looped one bar, so a synced arpeggiator or step sequencer restarted at every bar line. With the loop switch off
   and a loop range kept, they were told the transport loops that range, and the block at the song's end said a position

+ 50 - 1
src/Round190uyCheck.inc

@@ -7,7 +7,8 @@
     // Checks: the version gate (live::missesInsertItems, with keepsOwnSettings); this build's snapshot song (the same
     // ProjectFile::toJson the host sends) carries its version near the head and reads back silent; a 0.1.32 / 0.1.31.2
     // stamp reads back and gets the notice, an unstamped song none; the three notices in every language (translated,
-    // their name and version filled in), in English as shown.
+    // their name and version filled in), in English as shown; and issue #396 (same round): Helix's channel window opened
+    // off-screen, its Helix+ strip's macro handles (part 4).
     // Included in the app class of Main.cpp; --round190uytest <report> and --selftest "round190uy". No window, no network.
     juce::String round190uyCheck (juce::String& log)
     {
@@ -73,5 +74,53 @@
         check ("guest notice in English", shown == "The host uses LYNX SHARE 0.1.32: ask the host to update it so the Mixer's effects switches, pinned tracks and notes stay in sync", shown);
         check ("host notice in English", tr (hostItems, { "Ana", "0.1.32" }).startsWith ("Ana uses LYNX SHARE 0.1.32: update it so the Mixer's"));
         i18n::apply (languageWas);
+
+        // 4. issue #396 (ycollet): Helix's channel window, LYNX's look, opened off-screen (as the LV2 manifest helper opens
+        // Wavecoil's editor). Helix+'s strip filled and laid out macros 1…8 into arrays of 4 (since 190ml), writing past
+        // them (libstdc++ assertions abort there; without them memory is overwritten) and making 4 more handles "M5"…"M8"
+        // on top of Helix+ 2's own. Now: 8 macro handles and 2 chaos handles in the strip, each laid out inside it once.
+        // (A build with -D_GLIBCXX_ASSERTIONS on src/ui/HelixEditor.cpp aborts here before the fix.)
+        {
+            juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
+            AudioEngine offline (false);
+            offline.editSong ([] (Song& s) {
+                if (s.channels.empty())
+                    s.channels.resize (1);
+                ChannelDef c;
+                c.instrument = InstrumentKind::helix;
+                c.name = "Helix";
+                c.mixerTrack = s.channels[0].mixerTrack;
+                s.channels[0] = c;
+            }, false);
+            offline.dispatchPendingMessages();
+            auto page = makeHelixEditor (offline, [] (Song& s) -> ChannelDef* { return s.channels.empty() ? nullptr : &s.channels[0]; }, 0);
+            page->setSize (std::max (page->getWidth(), 1000), std::max (page->getHeight(), 600));
+            offline.dispatchPendingMessages();
+            juce::Component* strip = nullptr;
+            std::function<void (juce::Component&)> find = [&] (juce::Component& c) {
+                for (auto* child : c.getChildren())
+                {
+                    if (strip == nullptr && juce::String (typeid (*child).name()).contains ("HelixPlusStrip"))
+                        strip = child;
+                    find (*child);
+                }
+            };
+            find (*page);
+            check ("#396: Helix+'s strip in the channel window", strip != nullptr && strip->getWidth() > 0);
+            int handles = 0, inside = 0;
+            std::set<juce::String> places;
+            if (strip != nullptr)
+                for (auto* child : strip->getChildren())
+                    if (auto* t = dynamic_cast<juce::SettableTooltipClient*> (child))
+                        if (t->getTooltip() == tr ("Drag onto a knob to modulate it"))
+                        {
+                            ++handles;
+                            inside += ! child->getBounds().isEmpty() && strip->getLocalBounds().contains (child->getBounds()) ? 1 : 0;
+                            places.insert (child->getBounds().toString());
+                        }
+            check ("#396: 8 macro handles and 2 chaos handles, each laid out once inside the strip",
+                   handles == wt::macroCount + wt::chaosCount && inside == handles && (int) places.size() == handles,
+                   juce::String (handles) + " handles, " + juce::String (inside) + " inside, " + juce::String ((int) places.size()) + " places");
+        }
         return result;
     }

+ 9 - 4
src/ui/HelixEditor.cpp

@@ -1756,7 +1756,7 @@ public:
         unisonStack->setTooltip (tr ("Stack: unison voices an octave or a fifth apart"));
         for (int k = 0; k < 2; ++k)
             filterType[(std::size_t) k] = menu (Menu::of (page, [X, k] { return X (w::ext::filterType + k); }));
-        for (int j = 0; j < w::macroCount; ++j)
+        for (int j = 0; j < w::plusMacroCount; ++j) // (macros 1…4; 5…8 are Helix+ 2's row below: macros2, issue #396)
         {
             macros[(std::size_t) j] = knob (X (w::ext::macro + j), juce::String (j + 1));
             macroHandle[(std::size_t) j] = tab ("M" + juce::String (j + 1), [] { return false; }, [] {});
@@ -2057,7 +2057,7 @@ public:
             filterType[(std::size_t) k]->setBounds (f0.getX() + 16, f0.getY() + 20 + k * 22, f0.getWidth() - 22, 16);
         // macros: knob + handle
         const auto m0 = sections[4];
-        for (int j = 0; j < w::macroCount; ++j)
+        for (int j = 0; j < (int) macros.size(); ++j)
         {
             macros[(std::size_t) j]->setBounds (m0.getX() + 4 + j * 58, m0.getY() + 16, 38, 54);
             macroHandle[(std::size_t) j]->setBounds (m0.getX() + 42 + j * 58, m0.getY() + 34, 14, 16);
@@ -2246,8 +2246,13 @@ private:
     std::array<juce::Rectangle<int>, 23> sections {};
     std::array<Menu*, 2> warpMenu {}, filterType {};
     std::array<Ctl*, 2> warpAmt {};
-    std::array<Ctl*, 4> macros {};
-    std::array<Tab*, 4> macroHandle {};
+    // Helix+'s macros 1…4 (ext::macro + j, section 4); Helix+ 2's macros 5…8 are macros2 / macroHandle2 (section 13). Issue
+    // #396 (round 190uy): since 190ml made macroCount 8, the loops that fill and lay these out ran to 8 and wrote past both
+    // arrays (and bound knobs "5"…"8" to ext::macro + 4…7, which are the drawn-LFO and distortion values)
+    std::array<Ctl*, w::plusMacroCount> macros {};
+    std::array<Tab*, w::plusMacroCount> macroHandle {};
+    static_assert (w::plusMacroCount == 4 && w::ext::macro + w::plusMacroCount == w::ext::lfoDraw && w::plusMacroCount <= w::macroCount,
+                   "Helix+'s macro block: ext::macro … + 3, the rest are Helix+ 2's (macros2)");
     std::array<Tab*, 2> lfoDraw {};
     std::array<Tab*, 4> fxOn {};
     std::vector<Ctl*> fxKnobs;