Page 1 of 1
BUG: Can't open two MDLs at same time
Posted: Thu Dec 12, 2024 10:59 pm
by Travis
I have the setting to Close Active Model turned off. I used to be able to open multiple files. This doesn't seem to work any more. Not sure when it broke, but I think this was working several months ago.
macOS 15.2
Vensim 10.2.1
[attachment=0]Screenshot 2024-12-12 at 5.58.37 PM.png[/attachment]
Re: BUG: Can't open two MDLs at same time
Posted: Fri Dec 13, 2024 1:53 pm
by aliakhavan89
Hi Travis, are you opening the new model using 'open' menu or double-clicking? Double-clicking has always been problematic but the 'open' menu works on my end
macOS 15.2
Vensim 10.2.2
Re: BUG: Can't open two MDLs at same time
Posted: Fri Dec 13, 2024 3:40 pm
by Travis
Double-clicking mostly. Maybe even cmd-O in the Finder.
So two different behaviors (meaning two different code paths) depending on how a file is opened? That is confusing for users (ie. Me!).
Re: BUG: Can't open two MDLs at same time
Posted: Fri Dec 13, 2024 4:02 pm
by aliakhavan89
As far as I know, yes. The only workaround for this bug is to have a Vensim session open already. We have an open discussion for it here:
viewtopic.php?t=8328&sid=bd7d2d6e04ba6b ... 0729dc4202
Re: BUG: Can't open two MDLs at same time
Posted: Mon Dec 16, 2024 1:13 pm
by Administrator
I'll look into this.
There are at least 4 different code paths to open a model on the Mac, possibly more.
1. File->Open.
2. Double click in Finder when Vensim is not open.
3. Double click in Finder when Vensim is open.
4. Drag a model onto the Vensim app.
Paths 2 and 3 are extremely difficult to debug as MacOS/Xcode does not provide a way to associate a debug executable with a file type.
Re: BUG: Can't open two MDLs at same time
Posted: Mon Dec 16, 2024 7:10 pm
by Travis
It seems like all the paths should call the same Vensim function, though, and that should handle all the windowing in Vensim the same. The four code paths seem to differ too early in the opening process.
I assume that each of the four paths should all do the following steps:
String model_path = SPECIFIC_WAY_TO_GET_MDL_BASED_ON_OPENING_METHOD()
VensimFunctionOpenMDL(model_path) {
Handle all the opening and windows and tab creation the same
}
But the code doesn't seem to be factored that way, since not all MDLs are handled the same way.
Re: BUG: Can't open two MDLs at same time
Posted: Mon Dec 16, 2024 10:01 pm
by Administrator
Of course the paths all call the same function to open a model. I'm sure you realise it's just not that simple. Passing the model via the command line is easy. Double clicking on a file, the entry point is just after the app initialises but before the main window is created. If you double click when then app and main windows are already created, there is a different path.
Everything is straightforward if the ability to debug is available. Sadly on the Mac, you don't have that luxury.
I haven't had the chance to even look at this yet. If Apple have changed something (again), that would explain it.
Re: BUG: Can't open two MDLs at same time
Posted: Tue Dec 17, 2024 4:51 pm
by aliakhavan89
I found a very useful workaround for this double-click issue:
1. Open Automator
2. Create a New Application
3. Add a Shell Script Action (Run Shell Script)
4. Add the following Shell Script:
Code: Select all
open -n /Applications/VensimDSSMC.app --args "$@"
5. Set Pass Input 'as argument'

- Screenshot 2024-12-17 at 11.44.14 AM.png (883.65 KiB) Viewed 7285 times
6. Save the application as 'Vensim New Instance' (or any other name)
7. From a .mdl file: Right-click > Get Info
8. Under 'open with', select 'Vensim New Instance' and click 'Change All'
Now, double-click will open a .mdl file in a new instance without closing/replacing the previous one