Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#6174 closed defect (fixed)

OMC loads the wrong package

Reported by: massimo ceraolo Owned by: Adrian Pop
Priority: blocker Milestone: 1.16.1
Component: Interactive Environment Version: v1.16.0-dev
Keywords: Cc: Martin Sjölund

Description (last modified by massimo ceraolo)

The zip file MultifileIssue contains two multi-file packages: "Test_multifile" and "Test_multifile - Copia". The first contains a model named "test", the second contains a model named testNew"
Put the folders in the same disk area. e.g. c:\Work

Then, if we load package.mo from Test_multifile, OMEdit opens the package from "Test_multifile - Copia"!

This is probably due to spaces in names. Tested with Windows

Attachments (2)

MultifileIssue.zip (2.7 KB ) - added by massimo ceraolo 4 years ago.
MultifileIssueWithScript.zip (2.2 KB ) - added by Adeel Asghar 4 years ago.

Download all attachments as: .zip

Change History (13)

by massimo ceraolo, 4 years ago

Attachment: MultifileIssue.zip added

comment:1 by massimo ceraolo, 4 years ago

Description: modified (diff)
Summary: Omedit loads the wrokng packageOmedit loads the wrong package

comment:2 by massimo ceraolo, 4 years ago

Description: modified (diff)

by Adeel Asghar, 4 years ago

comment:3 by Adeel Asghar, 4 years ago

Cc: Martin Sjölund added
Component: OMEditInteractive Environment
Owner: changed from Adeel Asghar to Adrian Pop
Status: newassigned

Simplified the provided test case and added a script to reproduce the issue.

comment:4 by Adrian Pop, 4 years ago

I think this is the class loader implemented by @sjoelund.se but I will have a look.

comment:5 by Adrian Pop, 4 years ago

ClassLoader.mo:149

(mp,name,isDir) := System.getLoadModelPath(id,prios,mps,requireExactVersion);

This one returns name="Test_multifile - Copia" when called with:

System.getLoadModelPath("Test_multifile",{""},"path/to/test/",false);

comment:6 by Adrian Pop, 4 years ago

Summary: Omedit loads the wrong packageOMC loads the wrong package

comment:7 by Adrian Pop, 4 years ago

The problem is that omc thinks that the part "- Copia" is the version number.
I guess this is the wrong code:
https://github.com/OpenModelica/OpenModelica/blob/master/OMCompiler/Compiler/runtime/systemimpl.c#L2180

  if (version > 0 && !*versionExtra) {

as version is an array of long so the first condition will *always* true!

comment:8 by Adrian Pop, 4 years ago

I guess in splitVersion we should init version array with -1 so that we know if the split worked or not. One can have version 0.0.1 so version[0] > 0 is not a good check.
I don't get the code too much so I will let @sjoelund.se fix it if he has time.

Last edited 4 years ago by Adrian Pop (previous) (diff)

comment:9 by Martin Sjölund, 4 years ago

I'll fix this in https://github.com/OpenModelica/OpenModelica/pull/6930 but I will not add a testcase since it seemed random which one was used before.

comment:10 by Adrian Pop, 4 years ago

Resolution: fixed
Status: assignedclosed

comment:11 by massimo ceraolo, 4 years ago

Thank you

Note: See TracTickets for help on using tickets.