<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>334624</bug_id>
          
          <creation_ts>2014-05-11 22:09:28 +0000</creation_ts>
          <short_desc>KCModule::save() unable to access combobox values on OK</short_desc>
          <delta_ts>2014-06-13 07:41:44 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>Frameworks and Libraries</classification>
          <product>frameworks-kconfigwidgets</product>
          <component>general</component>
          <version>4.99.0</version>
          <rep_platform>unspecified</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Sebastian Kügler">sebas</reporter>
          <assigned_to name="kdelibs bugs">kdelibs-bugs-null</assigned_to>
          <cc>agateau</cc>
    
    <cc>cfeck</cc>
    
    <cc>kdelibs-bugs-null</cc>
          
          <cf_commitlink>http://commits.kde.org/kcmutils/cc99fac3af737619ea220ccb7059f0d8f0623efa</cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1447675</commentid>
    <comment_count>0</comment_count>
    <who name="Sebastian Kügler">sebas</who>
    <bug_when>2014-05-11 22:09:28 +0000</bug_when>
    <thetext>I have a KCModule that uses a .ui file. When OK&apos;ing the dialog, the ::save() function gets called, but values of a combobox in my .ui are gone by that time. When the module isn&apos;t deleted afterwards (Apply), everything works.

This is an issue showing with kcmshell5, but not with systemsettings, since systemsettings doesn&apos;t show an OK button.

Reproducible: Always

Steps to Reproduce:
1. Open &quot;Formats&quot; KCM
2. Change value of a combobox
3. Hit OK
Actual Results:  
When reopening the Formats KCM, values have not been applied.

Expected Results:  
Combobox values should have been saved correctly.

I&apos;ve debugged this in the KCM as far as counting values of the combox, and in the problematic case, it&apos;s always zero. There seems to be a race condition that the comboboxes are emptied before we can save the config on deletion. My .ui file resulting widget is only deleted in the KCM dtor.

Code in plasma-desktop/kcms/formats/kcmformats.cpp show the problematic behavior. (Currently in branch sebas/locale, soon to be merged into master.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1447687</commentid>
    <comment_count>1</comment_count>
    <who name="Christoph Feck">cfeck</who>
    <bug_when>2014-05-12 00:02:15 +0000</bug_when>
    <thetext>Hm, I am probably not understanding correctly, but do you think this bug is in kcombobox (which is in kcompletion) or in kcmodule (which is in kconfigwidgets)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1447701</commentid>
    <comment_count>2</comment_count>
    <who name="Sebastian Kügler">sebas</who>
    <bug_when>2014-05-12 01:01:49 +0000</bug_when>
    <thetext>I think it&apos;s a bug in KCModule, I&apos;m using QComboBox.

That&apos;s basically the following going wrong:

void KCMFormats::save()
{
    // m_ui-&gt;comboBox ends up empty here when OK button is clicked from kcmshell5,
    // apparently the data in the combo is gone by the time save() is called.
    // This might be a problem in KCModule, but does not directly affect us
    // since within systemsettings, it works fine.
    // See https://bugs.kde.org/show_bug.cgi?id=334624
    if (m_ui-&gt;comboBox-&gt;count() == 0) {
        qWarning() &lt;&lt; &quot;Couldn&apos;t read data from UI, writing configuration failed.&quot;;
        return;
    }
   //[...]
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1447704</commentid>
    <comment_count>3</comment_count>
    <who name="Christoph Feck">cfeck</who>
    <bug_when>2014-05-12 01:21:04 +0000</bug_when>
    <thetext>Thanks for the update, reassigning for further investigation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1454410</commentid>
    <comment_count>4</comment_count>
    <who name="Aurelien Gateau">agateau</who>
    <bug_when>2014-06-10 20:46:41 +0000</bug_when>
    <thetext>I have a fix for an issue with one of KWin KCM which looks very similar: https://git.reviewboard.kde.org/r/118639/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1454771</commentid>
    <comment_count>5</comment_count>
    <who name="Sebastian Kügler">sebas</who>
    <bug_when>2014-06-12 15:55:40 +0000</bug_when>
    <thetext>This patch fixes the problem, indeed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1454896</commentid>
    <comment_count>6</comment_count>
    <who name="Aurelien Gateau">agateau</who>
    <bug_when>2014-06-13 07:41:44 +0000</bug_when>
    <thetext>Git commit cc99fac3af737619ea220ccb7059f0d8f0623efa by Aurélien Gâteau.
Committed on 10/06/2014 at 14:40.
Pushed by gateau into branch &apos;master&apos;.

KCMultiDialog: Fix crash when clicking OK

When one closes KCMultiDialog with OK, QDialog::finished() can be emitted
before the clicked() signal of the OK button. This causes the following
sequence to happen:

- KCMultiDialogPrivate::_k_dialogClosed
  * deletes the KCModule
    - KCModuleProxyPrivate::_k_moduleDestroyed
      * sets kcm to 0

- KCMultiDialog::slotOkClicked
  - KCMultiDialogPrivate::apply
    - KCModuleProxy::save
      - KCModuleProxyPrivate::realModule
        * notices kcm is 0, so recreates it
        * calls kcm-&gt;save()
          - KWinDesktopConfig::save()
            * crashes because it expects kcm-&gt;load() to have been called

To avoid this, trigger the cleanup code in closeEvent() rather than when
finished() is emitted, as we can be sure closeEvent() is always called
*after* the methods connected to the button box signals has executed.

REVIEW: 118639

M  +15   -15   src/kcmultidialog.cpp
M  +2    -1    src/kcmultidialog.h

http://commits.kde.org/kcmutils/cc99fac3af737619ea220ccb7059f0d8f0623efa</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>