From 409eb644c8f2bf90edf9bbe6b083fb0588929918 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 10 Oct 2023 07:47:10 -0400 Subject: [PATCH] MacPDF: Unbreak persisting the current page I broke this when moving from a xib file to creating the UI in code. https://developer.apple.com/documentation/appkit/nsuserinterfaceitemidentification/1396829-identifier says: "Identifiers are used during window restoration operations to uniquely identify the windows of the application. [...] If you create an item in Interface Builder and do not set a value for this string, a unique value is created for the item when the nib file is loaded. For programmatically created views, you typically set this value after creating the item but before adding it to a window." Without this, encodeRestorableStateWithCoder: / restoreStateWithCoder: in MacPDFView weren't getting called. --- Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.mm b/Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.mm index 2bf6438948a..022c2af2ea1 100644 --- a/Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.mm +++ b/Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.mm @@ -33,6 +33,7 @@ return nil; _pdfView = [[MacPDFView alloc] initWithFrame:NSZeroRect]; + _pdfView.identifier = @"PDFView"; // To make state restoration work. [_pdfView setDelegate:self]; NSSplitViewController* split_view = [[NSSplitViewController alloc] initWithNibName:nil bundle:nil];