Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Fix palette docker lockup on Qt 6.11.0
Dmitry Kazakove1440fe0e4ca
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 505dc79599..e83dbf72b1 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -794,7 +794,6 @@ QWindowsWindowFunctions::setHasBorderInFullScreenDefault(true);endif (WIN32)-CHECK_CXX_SOURCE_COMPILES("#include <QCoreApplication>int main(int argc, char *argv[]) {@@ -856,6 +855,20 @@ return screen->densityAdjustment();KRITA_QT_HAS_ANDROID_QPLATFORMSCREEN_DENSITY_ADJUSTMENT)+set(CMAKE_REQUIRED_INCLUDES ${Qt${QT_MAJOR_VERSION}Widgets_INCLUDE_DIRS})++CHECK_CXX_SOURCE_COMPILES("+#include <QHeaderView>+#ifndef KRITA_HEADER_VIEW_MEMORY_MODE_INITIALIZATION_FIX+#error \"patch is missing\"+#endif+int main(int argc, char *argv[]) {+return 0;+}+"+KRITA_QT_HEADER_VIEW_MEMORY_MODE_INITIALIZATION_FIX+)+configure_file(config-qt-patches-present.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-qt-patches-present.h)unset(CMAKE_REQUIRED_INCLUDES)diff --git a/config-qt-patches-present.h.cmake b/config-qt-patches-present.h.cmakeindex ff348bd4b0..3accae2fdf 100644--- a/config-qt-patches-present.h.cmake+++ b/config-qt-patches-present.h.cmake@@ -7,3 +7,4 @@#cmakedefine01 KRITA_QT_HAS_QSCROLLER_FILTER#cmakedefine01 KRITA_QT_HAS_ANDROID_INPUT_PLATFORM_DATA_SOFT_INPUT_ADJUST_NOTHING#cmakedefine01 KRITA_QT_HAS_ANDROID_QPLATFORMSCREEN_DENSITY_ADJUSTMENT+#cmakedefine01 KRITA_QT_HEADER_VIEW_MEMORY_MODE_INITIALIZATION_FIX\ No newline at end of filediff --git a/libs/widgets/KisPaletteModel.cpp b/libs/widgets/KisPaletteModel.cppindex d00e712f77..4df771cb48 100644--- a/libs/widgets/KisPaletteModel.cpp+++ b/libs/widgets/KisPaletteModel.cpp@@ -107,10 +107,10 @@ void KisPaletteModel::setColorSet(KoColorSetSP colorSet)}beginResetModel();- m_colorSet = colorSet;if (m_colorSet) {m_colorSet->disconnect(this);}+ m_colorSet = colorSet;if (colorSet) {connect(colorSet.data(), SIGNAL(modified()), this, SIGNAL(sigPaletteModified()));connect(colorSet.data(), SIGNAL(layoutChanged()), this, SLOT(slotLayoutChanged()));diff --git a/libs/widgets/kis_palette_view.cpp b/libs/widgets/kis_palette_view.cppindex 165755f139..6de2193886 100644--- a/libs/widgets/kis_palette_view.cpp+++ b/libs/widgets/kis_palette_view.cpp@@ -19,6 +19,7 @@#include <KLocalizedString>#include <kis_icon_utils.h>+#include <config-qt-patches-present.h>#include <KisKineticScroller.h>@@ -70,6 +71,32 @@ KisPaletteView::KisPaletteView(QWidget *parent)verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);verticalHeader()->setMinimumSectionSize(MINIMUM_ROW_HEIGHT);+#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0) && !KRITA_QT_HEADER_VIEW_MEMORY_MODE_INITIALIZATION_FIX+ // Qt 6.9.0 got a "feature" that lets QHeaderView avoid+ // memory allocations until some custom row/column size+ // request comes from the user. This feature has a problem.+ // When calling resizeSections(QHeaderView::Fixed) on a non-+ // empty header view, it half-initialized the header,+ // leaving it in a broken state. All the following+ // initialization requests will not be able to complete+ // or fix this state.+ //+ // Hence we should switch the header into "memory" mode+ // explicitly, while it has zero sections in it. It will+ // properly initialize it.+ //+ // Offending commit:+ // https://github.com/qt/qtbase/commit/9e3a96189d9db8a458e65cd5078509afe7a160db+ //+ // Krita's copy has a fix for this issue, which is declared by+ // a special definition.++ verticalHeader()->setStretchLastSection(true);+ verticalHeader()->setStretchLastSection(false);+ horizontalHeader()->setStretchLastSection(true);+ horizontalHeader()->setStretchLastSection(false);+#endif+connect(horizontalHeader(), SIGNAL(sectionResized(int,int,int)),SLOT(slotHorizontalHeaderResized(int,int,int)));setAutoFillBackground(true);@@ -277,22 +304,12 @@ void KisPaletteView::slotAdditionalGuiUpdate()clearSpans();resizeRows(verticalHeader()->defaultSectionSize());-// int row = -1;-for (const QString &groupName : d->model->colorSet()->swatchGroupNames()) {if (groupName.isEmpty()) continue;-// KisSwatchGroupSP group = d->model->colorSet()->getGroup(groupName);-// row += group->rowCount() + 1;-// setSpan(row, 0, 1, d->model->columnCount());-// setRowHeight(row, fontMetrics().lineSpacing() + 6);-// verticalHeader()->resizeSection(row, fontMetrics().lineSpacing() + 6);--int rowNumber = d->model->colorSet()->startRowForGroup(groupName);setSpan(rowNumber, 0, 1, d->model->columnCount());setRowHeight(rowNumber, fontMetrics().lineSpacing() + 6);- verticalHeader()->resizeSection(rowNumber, fontMetrics().lineSpacing() + 6);}}