Menu

#1612 Incorrect formatting of "Category Groups" on 10.14 and 10.15

unverified
closed-fixed
nobody
None
5
2021-09-27
2021-09-13
Will
No

I hope you'll forgive me for opening a new ticket for the issue that was discussed in #1611.

On Mac OS 10.14 and 10.15, the latest release (1.8.5) of BibDesk renders the category group names incorrectly (it appends a brace to the category name). See the attached screenshot. The tooltips also render incorrectly.

I did some digging in the code, and I saw that BDSKCategoryFormatter's stringForObjectValue method is eventually being called with an NSConcereteAttributedString, for which [obj description] returns

@"Empty Keywords{\n    NSColor = \"Catalog color: System labelColor\";\n    NSFont = \"\\\".AppleSystemUIFont 11.00 pt. P [] (0x100f0ce80) fobj=0x100f0ce80, spc=3.17\\\"\";\n    NSOriginalFont = \"\\\".AppleSystemUIFont 11.00 pt. P [] (0x100f0ce80) fobj=0x100f0ce80, spc=3.17\\\"\";\n    NSParagraphStyle = \"Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 4, Tabs (\\n    28L,\\n    56L,\\n    84L,\\n    112L,\\n    140L,\\n    168L,\\n    196L,\\n    224L,\\n    252L,\\n    280L,\\n    308L,\\n    336L\\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningForTruncation NO, HeaderLevel 0 LineBreakStrategy 1\";\n}"

You can see that there is an open brace immediately before the newline, which causes the incorrect name. The long text and newlines are also evidently what causes the tooltip to render incorrectly.

Probably on Big Sur this behavior is different, which is why you can't reproduce it.

The following patch fixes the issue for me. Perhaps there is a more elegant way to fix it, I'm not familiar with BibDesk's source code.

--- BDSKCategoryFormatter.m (revision 26862)
+++ BDSKCategoryFormatter.m (working copy)
@@ -61,7 +61,12 @@
 }


 - (NSString *)stringForObjectValue:(id)obj {
-    NSString *string = [obj description];
+    NSString *string;
+    if ([obj isKindOfClass:[NSAttributedString class]]) {
+        string = [obj string];
+    } else {
+        string = [obj description];
+    }
     return [NSString isEmptyString:string] ? [NSString stringWithFormat:NSLocalizedString(@"Empty %@", @""), key] : string;
 }
1 Attachments

Discussion

  • Christiaan Hofman

    Wow, this is really stupid! Why on earth should it be passed an NSAttributedString when we explicitly pass it an NSString. That is really a bug in those systems. Apple constantly messes things up by trying to be "smart" and knowing it better, thereby not thinking ahead.

     
  • Christiaan Hofman

    Anyway, thanks for figuring this out. It is now fixed for the next release. And let me add that this is really a (deliberate) bug in these systems, as it messes with the documented operation and leads to data loss. I can hardly wrap my mind about how stupid and shortsighted what they did is, and not for very good reasons.

     
  • Christiaan Hofman

    • status: open --> open-fixed
     
  • Christiaan Hofman

    I guess I now finally understand the whole problem for the hang as well. Basically, the system substitutes an NSAttributedString for the object, which we get the description of, and the system then replaces that by the an NSAttributedString with that string, which we get the description off, etc, without an end (getting larger and larger strings). It basically means that Apple has essentially made formatters in tables non-functional and even dangerous. Just to get some "nice special looks". Let me say I am really mad with Apple (again, they keep messing up).

     
  • Christiaan Hofman

    BTW, do you mean you can build BibDesk for yourself? Perhaps you can try the current code and check whether it displays correctly and does not hang again?

     
    • Will

      Will - 2021-09-14

      Yes, I can build locally. I just tried the most recent version from SVN and it works properly for me.

      Thanks again for your help with this and for the quick fixes! BibDesk is a great application that I rely on daily. I understand how frustrating it is to work around buggy APIs from Apple.

       
  • A BibDesk User

    A BibDesk User - 2021-09-14

    I just tested the most recent release (v1.8.5) in macOS 10.12 Sierra, and I still see the open brace at the end of groups.

     
    • Will

      Will - 2021-09-14

      This was fixed after the 1.8.5 release, so we'll probably have to wait for 1.8.6.

       
  • A BibDesk User

    A BibDesk User - 2021-09-20

    I just tested the latest nightly build in macOS 10.12 Sierra and can confirm that the open brace at the end of groups is fixed.

    I noticed another small oddity in the list of groups (again, in macOS 10.12 Sierra): If I hide the bottom field group, a blank space remains where the list of values was. You can see this in the "Author" field group in the attached screen shot: there is a blank space beneath the "Author" label that is exactly the same size as the list of authors that was there before I clicked "Hide". There is a long list of smart groups listed above (cropped out in the screen shot), so in previous versions of BibDesk, the field group at the bottom that has been hidden would "collapse" and slide down to be flush with the bottom of the window, but now it leaves a blank space. This is a merely cosmetic issue.

    Moreover, the groups pane also seems generally buggy in macOS 10.12 Sierra: sometimes not all of the values of a field group are listed, only the first value, or none at all. But I can't reliably reproduce this issue. And If I hide a long list of smart groups and then show it again, the scroll bar of the groups pane does not work: it will not scroll down. So, generally the code of the groups pane seems not to be performing reliably in macOS 10.12 Sierra.

     
    • Christiaan Hofman

      Weird. But it is a bug in 10.12, hiding and showing the items in the outline view is just a standard functionality of the outline view, so it is Apple's responsibility to implement that properly. All we do is tell it to reload the data for the whole section when it is updated, and it is Apple's responsibility to actually do that. There is no way we could even fix that. This is really a bug to be reported to Apple (though they certainly won't fix it).

       
      • A BibDesk User

        A BibDesk User - 2021-09-21

        You may want to drop the listed compatibility with macOS 10.12 and below in the next release. I could test it in 10.13 as well to see if there are similar problems in 10.13; I have a machine with 10.13 installed but I would have to take it out of storage.

        By the way, I consider the 2021-04-15 nightly build to be the last version that I tested that works well in 10.9. The next release after that worked considerably less well, and I wouldn't even bother to try more recent versions on 10.9; it's very unlikely that they would work reliably.

         

        Last edit: A BibDesk User 2021-09-21
        • Christiaan Hofman

          Could you test tomorrow's nightly build on 10.12? Perhaps auto layout is where Apple messes up the layout when running on 10.12 (but we have to use auto layout because otherwise Apple messes up the layout during development...)

           
          • A BibDesk User

            A BibDesk User - 2021-09-23

            I tested nightly build 2021-09-21 on macOS 10.12 and 10.13.

            The cosmetic issue in the groups table that I described above, "If I hide the bottom field group, a blank space remains where the list of values was", still occurs in both 10.12 and 10.13.

            Regarding the second issue in the groups table that I described above, "sometimes not all of the values of a field group are listed, only the first value, or none at all": What I see now in both 10.12 and 10.13 is that sometimes a field group will not show the list of values; nothing happens when I toggle "hide/show" next to the group name in the groups table. But I can't reliably reproduce the issue; if I remove the problematic field group and then add it again, it works fine. Still, the fact that it happens in two different OS versions on two different machines, in BibTeX files that work perfectly in older versions of BibDesk, suggests that it's a real bug in those OS versions.

            The third issue in the groups table that I described above, "If I hide a long list of smart groups and then show it again, the scroll bar of the groups pane does not work: it will not scroll down" still happens in some files in 10.12 (but I discovered that scrolling works again if I resize the window), but I can't reproduce it in 10.13.

            Perhaps the only conclusion from all this may be that there is some bugginess in Apple's auto layout of the groups table in these older OS versions. (No surprise?)

            By the way, I noticed a typo in the Files/Opening and Saving preferences pane: it says "Automaticall save documents in place". Should be "Automatically".

             
            • Christiaan Hofman

              That one does not have the changes. Could you please try the one from 2021-09-23 or later?

               
              • A BibDesk User

                A BibDesk User - 2021-09-25

                I tested nightly build 2021-09-24 on macOS 10.12 and 10.13. All issues in the groups table that I mentioned above appear to be fixed in 10.12.

                In 10.13, the cosmetic issue "If I hide the bottom field group, a blank space remains where the list of values was" still occurs, and I also noticed a field group not showing a list of values, but if I removed the field group and added it again it worked as expected.

                The typo in the Files/Opening and Saving preferences pane "Automaticall save documents in place" is still there.

                 
                • Christiaan Hofman

                  That shows that the 10.12 and 10.13 systems have a buggy auto layout implementation. I will also work around this for 10.13.

                   
  • Christiaan Hofman

    • Status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB