Bug 458654

Summary: Error when Import QIF dialog is pre-populated (from previous import) with a qif file that no longer exists.
Product: [Applications] kmymoney Reporter: antoine <antoine>
Component: importerAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: CONFIRMED ---    
Severity: normal CC: nick, ostroffjh
Priority: NOR    
Version: 5.1.3   
Target Milestone: ---   
Platform: Kubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: File access error when import QIF

Description antoine 2022-09-03 07:51:39 UTC
SUMMARY

An error message appears when importing a qif file.
(Kmymoney tries to read an old qif file.)


STEPS TO REPRODUCE
1.  File > Import > Qif  
2. import a qif file
3. erase the qif file
4. File > Import > Qif
 
OBSERVED RESULT

an error message appears because Kmymoney tries to read the previous qif file

EXPECTED RESULT

no error message, Kmymoney should ask for the new file

SOFTWARE/OS VERSIONS

Informations sur paquet kmymoney :
----------------------------------
Dépôt                     : openSUSE-Tumbleweed-Oss
Nom                       : kmymoney
Version                   : 5.1.3-1.3
Architecture              : x86_64
Fabricant                 : openSUSE
Taille une fois installé  : 22,0 MiB
Installé                  : Oui
État                      : à jour
Paquet source             : kmymoney-5.1.3-1.3.src
URL en amont              : https://www.kmymoney.org/
Résumé                    : A Personal Finance Manager by KDE


ADDITIONAL INFORMATION
Comment 1 Jack 2022-09-05 23:03:37 UTC
If you import a qif file, and then do File/Import/QIF, it brings up the QIF import dialog with the previously imported file selected, but it doesn't automatically import it again.   I see the error says "Error while loading file ..." but from testing, I'm pretty sure it's not actually trying to import that file.  It's just trying to use that file to pre-populate the file selection field in the import dialog, and the field is failing to "load" the filename.  It's still a bug, but it needs a slightly different description.  I don't know if there is a flag to that field to ignore a non-existing file, or if KMM needs to explicitly test to the existence of the file before opening the dialog.
Comment 2 Nick Elliott 2023-10-05 09:22:12 UTC
Created attachment 162095 [details]
File access error when import QIF
Comment 3 Nick Elliott 2023-10-05 09:25:20 UTC
I see the same behaviour, every time I attempt to import a QIF there is a file access error as the import dialog attempts to open the QIF file from a previous import which no longer exists.
Comment 4 Jack 2023-10-05 14:07:34 UTC
I have not re-tested, but in my previous tests, the "old" qif file was just listed in the dialog, but the not found error would not happen unless you clicked the button to actually perform the import.  Are you saying you get the error just by selecting Import/QIF... and not clicking anything else?  Also, as you did not expand the details, it is not certain what your specific error is.
Comment 5 Jack 2023-10-05 19:41:41 UTC
I finally got a change to try this again, and I confirm that it does immediately pop up an error if the file cannot be found.   This message is from kmymoney/plugins/qif/import/kimportdlg.cpp (line 138 in master branch,) where it is checking the validity of the file name in the dialog whenever the file name changes.  I suspect (but have not actually traced the code) that this is being triggered when the dialog is first presented as if the file name had just been typed in.  It is not actually trying to open the file at that point, just test whether it exists.  I don't know how easy it will be to skip the warning if the file name is simply there from having been used the last time a qif file was imported.