Skip to content
  • Kai Uwe Broulik's avatar
    [Image Wallpaper] Fix thumbnail generation when model is reloaded in-flight · 49230140
    Kai Uwe Broulik authored
    GHNS Quick Button signals changedEntriesChanged initially even if nothing changed.
    While this is a bug that should be fixed in GHNS, the wallpaper model didn't handle the case well,
    when the model was reloaded while a preview was being generated.
    
    It looks up whether a preview exists by QUrl and stores a QPersistentModelIndex.
    However, when the model is reloaded and it accesses data for the same QUrl, the job might still be in-flight,
    but the QPersistentModelIndex is invalid as the model has been reset.
    
    This fixes it by performing all lookups exclusively on QPersistentModelIndex.
    The hash lookup is optimized for data() (loads of accesses) with the slower key() lookup being done only
    when the less frequently occurring thumbnail generation finishes/fails.
    It will now do two preview jobs initially, but at least it shows something again...
    
    BUG: 419234
    FIXED-IN: 5.18.4
    
    Differential Revision: https://phabricator.kde.org/D28420
    49230140