Bug 473485 - QAbstractItemModel::endInsertColumns: Invalid index
Summary: QAbstractItemModel::endInsertColumns: Invalid index
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Animation (show other bugs)
Version: 5.2.0-beta2
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Emmet O'Neill
URL:
Keywords: regression, release_blocker
: 473282 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-08-17 17:40 UTC by grum999
Modified: 2023-08-23 09:27 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description grum999 2023-08-17 17:40:58 UTC
SUMMARY
The first file I open in Krita, whatever the format (jpg, png, kra) generate the following message in terminal:
```
QAbstractItemModel::endInsertColumns:  Invalid index ( 0 , 101 ) in model KisAnimTimelineFramesModel(0x5607b0855610)
```

STEPS TO REPRODUCE
1. Start Krita from terminal
2. Open a file

OBSERVED RESULT
- An invalid index message related to KisAnimTimelineFramesModel is displayed
- Next files opened don't generate message

Note: if Animation Timeline docker is visible, there's no error message 

EXPECTED RESULT
- No error message?

SOFTWARE/OS VERSIONS
Krita
 Version: 5.2.0-beta2
 Hidpi: false
Qt
  Version (compiled): 5.15.7
  Version (loaded): 5.15.7
OS Information
  Build ABI: x86_64-little_endian-lp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: linux
  Kernel Version: 5.19.0-45-generic
  Pretty Productname: KDE neon 5.27
  Product Type: neon
  Product Version: 22.04
  Desktop: KDE
  Appimage build: Yes
Comment 1 grum999 2023-08-17 17:57:23 UTC
Opening an animation file with 75 frames (0 to 74)  generate a different message :)
```
QAbstractItemModel::endInsertColumns:  Invalid index ( 1 , 75 ) in model KisAnimTimelineFramesModel(0x55f8e4ef8380)
```
Comment 2 Emmet O'Neill 2023-08-18 21:30:17 UTC
Yep, you're right. 

I'm not sure why this is happening yet, but it'll be on my list of things to look into next week.

Thanks for the report as always grum!
Comment 3 Freya Lupen 2023-08-20 13:22:34 UTC
*** Bug 473282 has been marked as a duplicate of this bug. ***
Comment 4 grum999 2023-08-20 15:09:38 UTC
Ah thanks!

Didn't saw the bug 473282 as I didn't searched in resolved... :-/
Comment 5 Dmitry Kazakov 2023-08-23 09:25:44 UTC
Git commit 2157e5c8a4d36c13f7b69be739f136639faeb2ca by Dmitry Kazakov.
Committed on 23/08/2023 at 11:24.
Pushed by dkazakov into branch 'master'.

Fix a model warning in KisTimeBasedItemModel

There were two issues:

1) KisTimeBasedItemModel::columnCount() could return the value that
   has already changed in the image without calling to
   begin/endInsertColumns. That is not really welcome by Qt.

2) In KisTimeBasedItemModel::setImage() we reset the model (and therefore
   updated its columns list), but didn't update m_d->numFramesOverride,
   which caused double insertion of the columns in
   slotPlaybackRangeChanged() a bit later.

M  +2    -1    plugins/dockers/animation/KisTimeBasedItemModel.cpp

https://invent.kde.org/graphics/krita/-/commit/2157e5c8a4d36c13f7b69be739f136639faeb2ca
Comment 6 Dmitry Kazakov 2023-08-23 09:27:00 UTC
Git commit de673feee8f20079e54b51f7799d48e267703035 by Dmitry Kazakov.
Committed on 23/08/2023 at 11:26.
Pushed by dkazakov into branch 'krita/5.2'.

Fix a model warning in KisTimeBasedItemModel

There were two issues:

1) KisTimeBasedItemModel::columnCount() could return the value that
   has already changed in the image without calling to
   begin/endInsertColumns. That is not really welcome by Qt.

2) In KisTimeBasedItemModel::setImage() we reset the model (and therefore
   updated its columns list), but didn't update m_d->numFramesOverride,
   which caused double insertion of the columns in
   slotPlaybackRangeChanged() a bit later.

M  +2    -1    plugins/dockers/animation/KisTimeBasedItemModel.cpp

https://invent.kde.org/graphics/krita/-/commit/de673feee8f20079e54b51f7799d48e267703035