Bug 417164

Summary: when a .bib file is passed to KBibTex on startup, that file isn't selected in Open Files
Product: [Applications] KBibTeX Reporter: glyphimor
Component: Loading/saving filesAssignee: Thomas Fischer <fischer>
Status: RESOLVED FIXED    
Severity: minor    
Priority: NOR    
Version: 0.9.1   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In: 0.9.2

Description glyphimor 2020-02-04 20:29:44 UTC
SUMMARY

When KBibTex has previously had multiple "open" .bib files, starting KBibTex on 1 particular .bib file (whether by passing as command line argument or double-clicking a .bib file in e.g. Dolphin) doesn't result in that file's entries being displayed. Instead, the displayed entries are from the file which happens to be listed first in Open Files. The user has to select his desired .bib file in the Open Files tab.

STEPS TO REPRODUCE
1. Open KBibTex. Close any .bib files listed in Open Files. Then open test1.bib and test2.bib. Open Files lists those 2 files, in that order.
2. Close KBibTex.
3. Double-click on test2.bib in Dolphin, or run "kbibtex test2.bib".

OBSERVED RESULT

test1.bib's entries are displayed. In Open Files, test1.bib is selected. The user must select test2.bib to view its entries.

EXPECTED RESULT

test2.bib's entries are displayed. In Open Files, test2.bib is selected.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.17.4
KDE Frameworks Version: 5.64.0
Qt Version: 5.13.2

ADDITIONAL INFORMATION

I think I understand KBibTeX's terminology w/r/t "open" vs. "closed" files -- "open" files are the ones that KBibTex automatically loads when the program starts. The 1st opened file, the one at the top of the Open Files tab, is the one that's displayed by default. But when I start KBibTex by clicking on a particular .bib file, I'd like that .bib file to be displayed, not whichever file happens to be listed first in Open Files. Minor point, but saves me an extra click.
Comment 1 Thomas Fischer 2020-02-05 15:39:34 UTC
I can confirm this bug. At the same time, I shall look into that, even if KBibTeX is launched without command line arguments, among the restored-open files the one gets activated that was active when KBibTeX's last session was closed.
Comment 2 Thomas Fischer 2020-02-05 20:31:00 UTC
Please have a look at the following commit if it fixes your problem:
https://commits.kde.org/clones/kbibtex/thomasfischer/kbibtex/b6d8cdda7f79c25798dd85ecdc59be89079c950f

You can test this code without interfering with your default KBibTeX installation by following the "quick start" instructions:
https://userbase.kde.org/KBibTeX/Development#Quick_Start_to_Run_KBibTeX_from_Git

To test the Git version containing the fix for your bug, please run the following command:
bash run-kbibtex.sh https://anongit.kde.org/clones/kbibtex/thomasfischer/kbibtex.git bugs/kde417164 YOURBIBFILENAME
Comment 3 glyphimor 2020-02-06 00:51:48 UTC
Tried it, works. Thank you!
Comment 4 Thomas Fischer 2020-02-06 20:44:03 UTC
Git commit ce455dfd2ebb01b5685fb4a02615d95711f582a9 by Thomas Fischer.
Committed on 06/02/2020 at 20:43.
Pushed by thomasfischer into branch 'kbibtex/0.9'.

File URLs passed by command line preceed over LRU

At program start, bibliography files may be opened either because their
filenames/URLs were passed as command line arguments or because they
were open in the previous session.
Until now, the actual file being shown to the user was one of the
previously opened files as the list of recently opened files was read
with a small delay (got referred for unrelated reasons).

However, if a user invokes KBibTeX with a file name or URLs as argument,
it is reasonable to assume that this file should be shown directly
instead of any previously opened files (which still may get opened in
the background).

This commit also fixes the minor usability issue that if only previously
opened files are to be restored (and no command line argument was
given), the most recently used/opened bibliography file should be
preferrably shown instead of an arbitary one.
FIXED-IN: 0.9.2

M  +1    -0    ChangeLog
M  +37   -13   src/program/openfileinfo.cpp
M  +0    -1    src/program/openfileinfo.h

https://commits.kde.org/kbibtex/ce455dfd2ebb01b5685fb4a02615d95711f582a9
Comment 5 Thomas Fischer 2020-02-11 07:27:37 UTC
Git commit 85b14d2c74cd68cfca922dc8afa11ad7cd0ff234 by Thomas Fischer.
Committed on 06/02/2020 at 20:59.
Pushed by thomasfischer into branch 'master'.

File URLs passed by command line preceed over LRU

At program start, bibliography files may be opened either because their
filenames/URLs were passed as command line arguments or because they
were open in the previous session.
Until now, the actual file being shown to the user was one of the
previously opened files as the list of recently opened files was read
with a small delay (got referred for unrelated reasons).

However, if a user invokes KBibTeX with a file name or URLs as argument,
it is reasonable to assume that this file should be shown directly
instead of any previously opened files (which still may get opened in
the background).

This commit also fixes the minor usability issue that if only previously
opened files are to be restored (and no command line argument was
given), the most recently used/opened bibliography file should be
preferrably shown instead of an arbitary one.

Forward-port of commit f56c52e9baad7f6e5 from branch 'kbibtex/0.10'
which in its turn is a forward-port of commit ce455dfd2ebb01b5685fb
from branch 'kbibtex/0.9'.

M  +1    -0    ChangeLog
M  +37   -10   src/program/openfileinfo.cpp
M  +1    -1    src/program/openfileinfo.h

https://commits.kde.org/kbibtex/85b14d2c74cd68cfca922dc8afa11ad7cd0ff234
Comment 6 Thomas Fischer 2020-02-11 07:28:02 UTC
Git commit b766c3eee5cd9c70dcf2f8c8bbbff0d8260d2fb8 by Thomas Fischer.
Committed on 06/02/2020 at 21:00.
Pushed by thomasfischer into branch 'kbibtex/0.10'.

File URLs passed by command line preceed over LRU

At program start, bibliography files may be opened either because their
filenames/URLs were passed as command line arguments or because they
were open in the previous session.
Until now, the actual file being shown to the user was one of the
previously opened files as the list of recently opened files was read
with a small delay (got referred for unrelated reasons).

However, if a user invokes KBibTeX with a file name or URLs as argument,
it is reasonable to assume that this file should be shown directly
instead of any previously opened files (which still may get opened in
the background).

This commit also fixes the minor usability issue that if only previously
opened files are to be restored (and no command line argument was
given), the most recently used/opened bibliography file should be
preferrably shown instead of an arbitary one.

Forward-port of commit ce455dfd2ebb01b5685fb from branch 'kbibtex/0.9'.

M  +1    -0    ChangeLog
M  +37   -10   src/program/openfileinfo.cpp
M  +1    -1    src/program/openfileinfo.h

https://commits.kde.org/kbibtex/b766c3eee5cd9c70dcf2f8c8bbbff0d8260d2fb8