Revert on closing doesn't revert

When I use Panorama X on a database and close it, I get the dialog asking me if I want to save changes (in accordance with my settings in the General system prefs).

I say Revert Changes. But sometimes I find that the modified date is changed to now, and when I open the database again, the changes did not revert.

This is not how other Cocoa apps behave. Revert Changes works on them, and the modified date does not change. So something is wrong with the Cocoa document saving here.

I think this only happens the first time the database is opened (on any particular day?). Weird.

It’s difficult for me to conceive of how Panorama could be behaving differently than other Cocoa apps. Panorama is entirely relying on NSDocument for this behavior – Panorama doesn’t even know what the state of the Ask to keep changes when closing documents setting is. As you know, I wasn’t even aware of this setting until you pointed it out a couple of years ago, and Panorama definitely does not have any special code that operates based on that setting.

I have had this setting turned on myself since that earlier discussion, and I sometimes use the Revert Changes option. I haven’t run into the problem you are describing, but then again, I haven’t been watching closely either, so it possibly could have happened without my noticing it. I’ll try to watch closer in the future.

Panorama documents are packages, not flat files. I wonder if the other apps you have tried this with are flat file or packages? Of course Panorama is not unique in using packages.

This would have been an excellent question to bring up at the WWDC labs … sigh. As it turned out the two major Panorama X problems I discussed with Apple engineers at the labs this year turned out to be AppKit bugs, so this might be another. If you come up with any additional clues, please report back.

Will do, although apart from filming the whole thing happening so you believe me, it’s hard to see what info I can bring to it. :frowning:

I’m sure you wouldn’t make this up, you’ve got better things to do with your time.

Since my last post, I have tried to duplicate this problem, and I wasn’t able to – it worked perfectly for me. If you think you can film it, that perhaps means you can make it happen over and over again? Even if I can duplicate the problem I imagine it will be tough to fix, but if I can’t, a fix seems very unlikely. (Though I think I did recently fix a problem with permanent variables that I couldn’t duplicate “on command”, so you never know.)

I did try it on a database that hadn’t been opened in many months, and it worked, so there must be more to it than just the first time it is opened in a session. I’ll keep my eye on this.

This is exactly what I am experiencing consistently.

I often have a need to open a database, modify it and then close it without saving the changes. I consistently run into the problem that Matt describes and generally have to force quit to overcome it. One solution is to have a procedure (I just leave it named Procedure_A) containing one line: closefile. That always works perfectly.

I also experience an issue, which I have mentioned before offline, where I launch Panorama and my database is not among the recent databases in Open Recent — in fact, Open Recent has been stripped of its databases. I mention this because I have a theory that the times when I experience that issue and the times I experience this issue might be the same.

The File>Database Options dialog has an option to exclude a database from the Recent menu. This option was primarily included for internal Panorama databases (so libraries and wizards don’t show up in the Recent menu), but you might want to enable this option that is normally opened automatically by other databases (for example an invisible tax rate database that is always opened secretly).

A couple of users have apparently had this option turn itself on by itself, or at least they didn’t remember ever enabling it. This would cause that database to not appear in the Recent menu. In the couple of instances where this has happened (literally two, I believe), unchecking the option fixed the problem permanently. (It also happened to me once, on one database.)

It sounds like you are saying that your Recent menu is completely empty. If so, that is something I don’t recall ever hearing of before. You say you mentioned this before offline, which presumably means to me, but I must apologize that I don’t recall hearing of anything like a completely empty Recent menu, just the problem with individual files I described above.

Super technical note – when you check the Exclude from Recent Menu option, Panorama actually does this by overriding the NSDocument - (void)noteNewRecentDocument:(NSDocument *)targetDocument method. If the exclude option is set, I simply don’t call the superclass method (NSDocument’s method that actually adds the file to the recent menu). Here is the actual code:

- (void)noteNewRecentDocument:(NSDocument *)targetDocument
{
	DatabaseDocument * targetDatabaseDocument = (DatabaseDocument *)targetDocument;
	Database * targetDatabase = [targetDatabaseDocument documentDatabase];
	if ([targetDatabase excludeFromRecentMenu]) {
		return; // used for wizards, etc.
	}
	[super noteNewRecentDocument:targetDocument];
}

Apples’ documentation for noteNewRecentDocument says:

This method is called by NSDocument objects at appropriate times for managing the recent-documents list.
This method constructs a URL and calls noteNewRecentDocumentURL:. Subclasses might override this method to prevent certain documents or kinds of documents from getting into the list.

I suppose anything is possible, but I would think that internal version handling within a document would be completely different code than the Open Recent list, which is kept in a plist. But of course I can’t see into Apple’s source code so I can’t say for sure there isn’t a correlation.

I’ll check the “include in recents” setting, but I hardly see how that would cause a database to be missing from the Recents sometimes. m.

I think this macOS feature may get affected when you intentionally or accidentally change the number of objects in System Preferences > General > Recent Objects. (I have set this number to 20.)

I don’t either. Are you saying that an item appears and disappears and reappears from the Recents menu? I haven’t heard of that.

In any case, the code I posted above is the only code in Panorama that involves the Recents menu. Everything else is in Apple’s code, in the NSDocument class. This class handles every aspect of recent documents – displaying the menu, opening recent items when choosing from the menu, etc. So if there is a problem there, I wouldn’t have the first idea of how to investigate it.

Right, sorry if I wasn’t clear. So what happens is, I use Panorama every day and there’s the database in my Recents — until one day, unaccountably, it isn’t. So I find it in some other way (like Find and Open), and open it, and now it’s in my Recents again — until it isn’t. Rinse, lather, repeat. Curious how it just intermittently goes away like that, eh?

And I’m suggesting that maybe, just maybe, the times when that happens are also the times when asking not to save on close fails (i.e. it saves against my will).

My experience definitely contradicts this theory.

I just opened PanX and Recent showed zero recent docs…related to upgrading to 10.1 (2790)?

There is no reason why the upgrade should affect the list of recent databases. It sounds like you might be seeing the same problem that Matt experienced, though.

Yep, I just did the upgrade to 10.1.1 and that absolutely did it. The Recents list was cleared, plus choosing Find and Open froze Panorama and I had to force quit. So you can say whatever you like about “there is no reason why”, but that was certainly the proximate cause.