Преглед изворни кода

REA round 134: guard the browser index against links, whole bars in the export info, round doc

Ka1-S пре 1 месец
родитељ
комит
6ce2dca763
4 измењених фајлова са 29 додато и 5 уклоњено
  1. 11 1
      docs/analise/REA_rodada134.md
  2. 2 0
      src/core/SearchIndex.cpp
  3. 15 3
      src/ui/BrowserComponent.cpp
  4. 1 1
      src/ui/ExportDialog.cpp

+ 11 - 1
docs/analise/REA_rodada134.md

@@ -162,4 +162,14 @@ the record menu (r131 works on recording), the browser's details box.
 
 ## Where I stopped
 
-(see below)
+- Done (landing 1): Part B items B1–B7 and Part A rows 1, 3, 4, 5, 6, 7 (code + tests `tests/Rea134Tests.inc`).
+- Build note: `scripts/build-windows-zig.sh` recompiles every app source each run, but Zig's own cache can hand back
+  an object compiled before a header changed when the header is edited while a build runs; a stale `Song.h`
+  (EffectSlot copy constructor from the old layout) crashed `.flp` imports. Clearing `ZIG_GLOBAL_CACHE_DIR` fixed it.
+- Next candidates: FL's per-format Export entries and "Last exported format(s)"; "Disable maximum polyphony" for
+  exports; the record menu's Quantize section and recording markers; the Browser's details box (date, path) for the
+  selected result; FL's "Use maximum buffer size from host" (report the device buffer to a fixed-buffer plugin);
+  "Allow smart disable" per plugin (bit `0x20000000`) with smart disable for hosted plugins; "Delete recorded files to
+  recycle bin" as a choice (LYNX always uses the recycle bin); the consumer of the render window's HQ bit in FLEngine.
+- Not confirmed: what exactly FL forces with "HQ for all plugins" inside its own plugins; `0x400` / `0x10000000` and
+  the other record-`0x02` flags.

+ 2 - 0
src/core/SearchIndex.cpp

@@ -50,6 +50,8 @@ int Index::refresh (const std::string& root, const FileSystem& fs, const std::fu
 
         const auto folder = pending.back();
         pending.pop_back();
+        if (folder.size() > 1024) // a runaway path (a link loop the file system did not report): not followed
+            continue;
         const auto time = fs.folderTime (folder);
 
         if (time < 0)

+ 15 - 3
src/ui/BrowserComponent.cpp

@@ -83,7 +83,11 @@ search::FileSystem diskFileSystem()
         for (const auto& c : children)
         {
             if (c.isDirectory())
-                listing.subfolders.push_back (c.getFileName().toStdString());
+            {
+                // junctions and links (Windows' "My Music" inside Documents points back to itself) are not followed
+                if (! c.isSymbolicLink())
+                    listing.subfolders.push_back (c.getFileName().toStdString());
+            }
             else if (isListed (c))
                 listing.files.push_back (c.getFileName().toStdString());
         }
@@ -100,8 +104,16 @@ bool refreshIndex (const juce::Array<juce::File>& roots, const std::function<boo
     shared.loadOnce();
     const auto fs = diskFileSystem();
     int listed = 0;
-    for (const auto& root : roots)
-        listed += shared.index.refresh (root.getFullPathName().toStdString(), fs, shouldStop);
+    try
+    {
+        for (const auto& root : roots)
+            listed += shared.index.refresh (root.getFullPathName().toStdString(), fs, shouldStop);
+    }
+    catch (const std::exception& e) // never takes the app down: the search falls back to what is indexed
+    {
+        DBG ("browser index: " << e.what());
+        std::fprintf (stderr, "browser index: %s\n", e.what());
+    }
     if (listed > 0)
         shared.save();
     return listed > 0;

+ 1 - 1
src/ui/ExportDialog.cpp

@@ -518,7 +518,7 @@ private:
         const auto seconds = exportMusicSeconds (song, options);
         // FL's line: "Length: 144 bars  Total time: 3'57''  Disk space: 38.76 MB" (REA round 134)
         const auto bars = lengthInBars (seconds, song.bpm, song.beatsPerBar);
-        auto info = tr ("Length: {0} bars", { juce::String (bars, bars < 10.0 && std::abs (bars - std::round (bars)) > 0.01 ? 1 : 0) }) + "  ·  "
+        auto info = tr ("Length: {0} bars", { juce::String ((int) std::ceil (bars - 0.01)) }) + "  ·  " // whole bars, as FL
                     + tr ("Total time: {0}", { juce::String (formatDuration (seconds)) });
         if (options.tail == TailMode::leave)
             info << " " << tr ("(+ tail up to {0} s)", { juce::String ((int) options.maxTailSeconds) });