Skip to content

Commit f85eaae

Browse files
andyclaude
andcommitted
Organizer: always offer "Import Calculation from Output File" (#97)
getFileMenu() added the import entry only when the selected tree node was literally a "project" -- with a comment conceding the approach ("Hardwire the import entry, not sure if there is any better way to do it"). So File showed just "Upload File..." and "Quit" unless the user had happened to click a project first. Reported from a live session: "Only see it if I select users, or andy, and then click on File ... better to always have access to it". That is right, and it matters more than it looks: importing externally run output is the whole of #44 and half of #94, and the entry point was effectively hidden. Importing does not depend on what is selected, so it is now always offered. That change alone would have introduced a crash. CalcMgr::getContainer() dereferences p_treeCtrl->getSelection() with no null check, which was unreachable while the menu entry required a selected project and is not any more. It now returns 0, which is the contract WxCalcImport already expects -- it checks for it and reports "Can't access or write to the specified parent project for the import", the right message for "you have not said where to put it". Not changed: Upload File is still offered for any collection. The same report suggests it should appear only inside a job, which needs a definition of "in a job" I would be guessing at; left on #97. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFMUNbw2UpRPmgsqviAowb
1 parent 0890f81 commit f85eaae

1 file changed

Lines changed: 32 additions & 7 deletions

File tree

‎src/apps/organizer/CalcMgr.C‎

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,13 +2367,9 @@ void CalcMgr::getFileMenu(wxMenu & menu, WxResourceTreeItemData * itemData)
23672367
menu.AppendSeparator();
23682368
}
23692369

2370-
// Hardwire the import entry, not sure if there is any better way to do it
2371-
if (resType->getName() == "project") {
2372-
menu.Append(wxID_IMPORT, _("&Import Calculation from Output File..."),
2373-
_T(""), wxITEM_NORMAL);
2374-
// menu.Append(wxID_EXPORT, _("Export"), _T(""), wxITEM_NORMAL);
2375-
}
2376-
2370+
// (The import entry used to be added here, gated on the selected node
2371+
// being a "project". It is now added unconditionally below -- see there.)
2372+
23772373
bool isCollection = p_treeCtrl->setExpandable(itemData);
23782374
wxMenuItem * tmpMenuItem = new wxMenuItem(&menu,
23792375
isCollection ? wxID_UPLOAD : wxID_DOWNLOAD,
@@ -2385,6 +2381,22 @@ void CalcMgr::getFileMenu(wxMenu & menu, WxResourceTreeItemData * itemData)
23852381
menu.AppendSeparator();
23862382
}
23872383

2384+
// Importing a calculation from an output file does not depend on what is
2385+
// selected, so it is always offered.
2386+
//
2387+
// It used to be added only when the selected node was literally a
2388+
// "project" -- with a comment conceding the approach ("Hardwire the
2389+
// import entry, not sure if there is any better way to do it"). The
2390+
// effect was that File showed just "Upload File..." and "Quit" unless
2391+
// the user happened to have clicked a project first, which made the
2392+
// entry point for importing externally run output (issues #44 and #94)
2393+
// very hard to find. Reported from a live session 2026-09-22: "Only see
2394+
// it if I select users, or andy, and then click on File ... better to
2395+
// always have access to it".
2396+
menu.Append(wxID_IMPORT, _("&Import Calculation from Output File..."),
2397+
_T(""), wxITEM_NORMAL);
2398+
menu.AppendSeparator();
2399+
23882400
menu.Append(wxID_EXIT, _("&Quit\tCtrl+Q"), _T(""), wxITEM_NORMAL);
23892401
}
23902402

@@ -4771,6 +4783,19 @@ TaskJob *CalcMgr::getContainer(const string& name)
47714783
// get tree item data
47724784
WxResourceTreeItemData *itemData = p_treeCtrl->getSelection();
47734785

4786+
// getSelection() returns 0 when nothing is selected, and this used to
4787+
// dereference it immediately. It was unreachable while the Import menu
4788+
// entry was only offered for a selected "project"; now that the entry is
4789+
// always offered (see getFileMenu), it is not.
4790+
//
4791+
// Returning 0 is the documented contract here: WxCalcImport checks for it
4792+
// and reports "Can't access or write to the specified parent project for
4793+
// the import", which is the right message for "you have not told me
4794+
// where to put it".
4795+
if (itemData == (WxResourceTreeItemData*)0) {
4796+
return ret;
4797+
}
4798+
47744799
// make resource
47754800
Resource *itemDataRes = itemData->getResource();
47764801
Resource *childRes = 0;

0 commit comments

Comments
 (0)