Bug 508239 - Assert when trying to zoom documentation view with ctrl+wheel
Summary: Assert when trying to zoom documentation view with ctrl+wheel
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Documentation viewer (other bugs)
Version First Reported In: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Igor Kushnir
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-08-14 12:33 UTC by David Redondo
Modified: 2025-08-21 08:46 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 6.3.250801
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Redondo 2025-08-14 12:33:14 UTC
SUMMARY
When trying to zoom the documentation view we run into an assert

STEPS TO REPRODUCE
1.  ctrl+wheel on documentation view

OBSERVED RESULT

ASSERT failure in KConfigGroup::writeEntry: "writing to a read-only group", file /home/david/kde/src/kconfig/src/core/kconfiggroup.cpp, line 888


EXPECTED RESULT
zoom 

SOFTWARE/OS VERSIONS
KDE Plasma Version: git master
KDE Frameworks Version:  git master
Qt Version:  6.9.1

ADDITIONAL INFORMATION

#8  0x00007ffff612b779 in QMessageLogger::fatal (this=<optimized out>, msg=0x7ffff5e47708 "ASSERT failure in %s: \"%s\", file %s, line %d")
    at /usr/src/qt6-base-6.9.1-0zneon+24.04+noble+unstable+build121/src/corelib/global/qlogging.cpp:883
#9  0x00007ffff6115fae in qt_assert_x (where=<optimized out>, what=<optimized out>, file=<optimized out>, line=<optimized out>) at /usr/src/qt6-base-6.9.1-0zneon+24.04+noble+unstable+build121/src/corelib/global/qassert.cpp:114
#10 0x00007ffff6f41436 in KConfigGroup::writeEntry (this=0x55555b98e630, key=0x7ffff7f82785 "Zoom Factor", value=..., flags=...) at /home/david/kde/src/kconfig/src/core/kconfiggroup.cpp:888
#11 0x00007ffff7f2c11f in KConfigGroup::writeEntry<double> (this=0x55555b98e630, key=0x7ffff7f82785 "Zoom Factor", value=@0x55555b98e640: 0.90702947845804982, pFlags=...)
    at /home/david/kde/usr/include/KF6/KConfigCore/kconfiggroup.h:931
#12 0x00007ffff7f2b321 in KDevelop::ZoomControllerPrivate::writeConfig (this=0x55555b98e630) at /home/david/kde/src/kdevelop/kdevplatform/util/zoomcontroller.cpp:54
#13 0x00007ffff7f2b506 in KDevelop::ZoomController::setFactor (this=0x55555b9b6970, factor=0.90702947845804982) at /home/david/kde/src/kdevelop/kdevplatform/util/zoomcontroller.cpp:82
#14 0x00007ffff7f2b594 in KDevelop::ZoomController::zoomBy (this=0x55555b9b6970, scale=-1) at /home/david/kde/src/kdevelop/kdevplatform/util/zoomcontroller.cpp:90
#15 0x00007ffff7f2b7b4 in KDevelop::ZoomController::handleWheelEvent (this=0x55555b9b6970, event=0x7fffffffc600) at /home/david/kde/src/kdevelop/kdevplatform/util/zoomcontroller.cpp:130
#16 0x00007ffff62459e6 in KDevelop::StandardDocumentationView::eventFilter (this=0x555556f3ad40, object=0x55555ba243c0, event=0x7fffffffc600) at /home/david/kde/src/kdevelop/kdevplatform/documentation/standarddocumentationview.cpp:344
#17 0x00007ffff60b57d8 in QCoreApplicationPrivate::sendThroughObjectEventFilters (receiver=receiver@entry=0x55555ba243c0, event=event@entry=0x7fffffffc600)
Comment 1 Igor Kushnir 2025-08-15 09:31:51 UTC
KConfigGroup::KConfigGroup(const KConfigBase *master, const QString &_group) sets KConfigGroupPrivate::bConst to true. I suspect the assertion has been failing since the ZoomController class was introduced many years ago, but no one has tested KDevelop with KF assertions enabled.

When the KF assertions are disabled, the m_configGroup.sync() call in ZoomControllerPrivate::writeConfig() returns false and the zoom level is not updated in kdeveloprc until KDevelop exit. When I make KConfigGroup outerGroup non-const in StandardDocumentationView::initZoom(), m_configGroup.sync() returns true, and the assertion failure should be gone too.

I am going to create a merge request with the fix soon. Too late for the 25.08.0 release unfortunately. Could be released in 25.08.1.

On another note, the sync() call was ineffective, but no one has complained about losing zoom levels after a KDevelop crash. Syncing in one session does not affect another session until it is restarted. I wonder - should sync() be called each time something is written to config? Do you know about best practices?
Comment 2 David Redondo 2025-08-18 07:29:49 UTC
Generally sync is not called manually that often in "normal" programs. The destructor of KConfig writes to disk. Setting pages however tend to write on save()
Comment 3 Igor Kushnir 2025-08-18 17:26:04 UTC
Created a merge request hours ago: https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/812
But the status of this bug is still not updated for some reason. Updating manually.
Comment 4 Igor Kushnir 2025-08-21 08:44:24 UTC
Git commit 84f1b96492c48d742ac57c27871dfc44de530e88 by Igor Kushnir.
Committed on 21/08/2025 at 08:43.
Pushed by igorkushnir into branch 'master'.

Pass a non-read-only config group to ZoomController

ZoomControllerPrivate() copies and stores the config group passed to
ZoomController(). If the original group is read-only, the stored group
is read-only as well. When ZoomControllerPrivate::writeConfig() calls
KConfigGroup::writeEntry() on the read-only stored group, the following
assertion failure occurs in case KConfig has been compiled with
assertions enabled:
ASSERT failure in KConfigGroup::writeEntry: "writing to a read-only group", file kconfig/src/core/kconfiggroup.cpp, line 888

When KConfig assertions are disabled, there is no crash and
documentation zoom factors are preserved between KDevelop launches.
However, the KConfigGroup::sync() call in
ZoomControllerPrivate::writeConfig() returns false, and consequently the
updated zoom factors are written to kdeveloprc only when the
KSharedConfig object is destroyed on KDevelop exit or when the config is
synced for some other reason (such as applying changes to KDevelop
settings).

The stored config group has been read-only and the sync() call has been
fruitless ever since 253d9c54a688403acfeaba9e30eb79fdd0c7bb44 introduced
the documentation zoom feature. Yet no one has complained about losing
documentation zoom factors after a KDevelop crash, probably because they
can be easily adjusted anew. Wheel events are not compressed, so sync()
is called repeatedly while the user scales a documentation view via the
mouse wheel. Remove the inessential sync() call to optimize (instead of
making it work as a side effect of the assertion failure fix).
FIXED-IN: 6.3.250801

M  +2    -1    kdevplatform/documentation/standarddocumentationview.cpp
M  +0    -1    kdevplatform/util/zoomcontroller.cpp
M  +1    -1    kdevplatform/util/zoomcontroller.h

https://invent.kde.org/kdevelop/kdevelop/-/commit/84f1b96492c48d742ac57c27871dfc44de530e88
Comment 5 Igor Kushnir 2025-08-21 08:46:49 UTC
Git commit 1d3cf67f8a0ae9187a813d06f5e02b98c355a784 by Igor Kushnir.
Committed on 21/08/2025 at 08:46.
Pushed by igorkushnir into branch 'release/25.08'.

Pass a non-read-only config group to ZoomController

ZoomControllerPrivate() copies and stores the config group passed to
ZoomController(). If the original group is read-only, the stored group
is read-only as well. When ZoomControllerPrivate::writeConfig() calls
KConfigGroup::writeEntry() on the read-only stored group, the following
assertion failure occurs in case KConfig has been compiled with
assertions enabled:
ASSERT failure in KConfigGroup::writeEntry: "writing to a read-only group", file kconfig/src/core/kconfiggroup.cpp, line 888

When KConfig assertions are disabled, there is no crash and
documentation zoom factors are preserved between KDevelop launches.
However, the KConfigGroup::sync() call in
ZoomControllerPrivate::writeConfig() returns false, and consequently the
updated zoom factors are written to kdeveloprc only when the
KSharedConfig object is destroyed on KDevelop exit or when the config is
synced for some other reason (such as applying changes to KDevelop
settings).

The stored config group has been read-only and the sync() call has been
fruitless ever since 253d9c54a688403acfeaba9e30eb79fdd0c7bb44 introduced
the documentation zoom feature. Yet no one has complained about losing
documentation zoom factors after a KDevelop crash, probably because they
can be easily adjusted anew. Wheel events are not compressed, so sync()
is called repeatedly while the user scales a documentation view via the
mouse wheel. Remove the inessential sync() call to optimize (instead of
making it work as a side effect of the assertion failure fix).
FIXED-IN: 6.3.250801
(cherry picked from commit 84f1b96492c48d742ac57c27871dfc44de530e88)

M  +2    -1    kdevplatform/documentation/standarddocumentationview.cpp
M  +0    -1    kdevplatform/util/zoomcontroller.cpp
M  +1    -1    kdevplatform/util/zoomcontroller.h

https://invent.kde.org/kdevelop/kdevelop/-/commit/1d3cf67f8a0ae9187a813d06f5e02b98c355a784