Bug 86916 - Textarea is empty in particular Dokuwiki page
Summary: Textarea is empty in particular Dokuwiki page
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml forms (show other bugs)
Version: 3.3
Platform: unspecified Linux
: NOR grave
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-10 15:50 UTC by Hasso Tepper
Modified: 2004-09-07 12:14 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
proposed fix (3.51 KB, patch)
2004-08-25 12:00 UTC, Leo Savernik
Details
better fix (3.37 KB, patch)
2004-08-25 16:47 UTC, Leo Savernik
Details
alternative patch (1.33 KB, patch)
2004-08-29 20:54 UTC, Germain Garand
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hasso Tepper 2004-08-10 15:50:59 UTC
Version:           3.3 (using KDE 3.3.0, compiled sources)
Compiler:          gcc version 3.3.4 (Debian 1:3.3.4-7)
OS:                Linux (i686) release 2.6.7-ipv6conntrack

Open http://www.splitbrain.org/dokuwiki/wiki:users and click "Edit this page" - textarea is empty. No problem with Mozilla and no problems with other pages from Dokuwiki site.
Comment 1 Stephan Kulow 2004-08-10 16:44:08 UTC
eek, it worked two times and the third time got an empty textarea - the HTML source contained the textarea, but of course that's another reload
Comment 2 Stephan Kulow 2004-08-10 16:49:51 UTC
it's possibly related to #49828
Comment 3 Hasso Tepper 2004-08-11 06:54:45 UTC
Yes, I discovered that happens with other http://www.splitbrain.org/dokuwiki/ pages as well. You just have to reload page to make it happen.
Comment 4 Leo Savernik 2004-08-25 12:00:19 UTC
Created attachment 7272 [details]
proposed fix

Combo fix for both bug 49868 and this one.
Comment 5 Leo Savernik 2004-08-25 12:26:34 UTC
Comment on attachment 7272 [details]
proposed fix

I certainly meant bug 49828. Once you don't copy&paste ...
Comment 6 Hasso Tepper 2004-08-25 12:30:10 UTC
Leo Savernik wrote:
> ------- Created an attachment (id=7272)
>  --> (http://bugs.kde.org/attachment.cgi?id=7272&action=view)
> proposed fix

Tested with 3.3 branch. Works. Many thanks.

> Combo fix for both bug 49868 and this one.

I think you meant bug 49828.

Comment 7 Leo Savernik 2004-08-25 16:47:15 UTC
Created attachment 7278 [details]
better fix

The last fix crashed in HTMLTextAreaElementImpl::state. This one doesn't.
Comment 8 Leo Savernik 2004-08-26 12:37:44 UTC
Also fixes bug 48879.
Comment 9 Germain Garand 2004-08-28 19:34:11 UTC
re #7: mmh, but then it won't set the textarea as initialized on the first run... see even on the bugzilla textarea: type something, then click outside => it's cleared.

somehow, your patch looks to me like replicating what m_dirtyvalue already provides... it could be just that somewhere along the chain, m_dirtyvalue isn't reset?
Comment 10 Germain Garand 2004-08-29 20:44:01 UTC
More precisely, what I mean is there are two issues:
1- the bogus textChanged signal
2 - the fact that we rely on close() to initialize the textarea, which only works when parsing (#48879)

I don't think it's a good idea to mix a turnaround for 1) with a solution for 2), because such a solution belongs to html/*, not to rendering/*

Comment 11 Germain Garand 2004-08-29 20:54:27 UTC
Created attachment 7349 [details]
alternative patch

using m_value.isNull() as the "initialized" flag and
fixing the textChanged signal on setStyle.
Leo, what do you think?
Comment 12 Leo Savernik 2004-09-01 22:41:58 UTC
Comment #11: It seems to fix the reset of initially empty text areas.

The reason why I refrained from using blockSignals is that a later Qt version may decide to emit textChanged in even more places. OTOH, with your patch, all places susceptible to a textChanged emission should be protected now (unless Qt starts throwing it in the QTextEdit constructor ;-) ).

I wonder why m_value cannot become empty any more after its initialization when m_dirtyvalue is true. If you rely on the fact that QTextEdit::text() never returns a null QString, this is likely going to break in Qt4 when Trolltech removes the difference between QString::null and "".

As attachment 7349 [details] is still the patch that causes the least amount of malfunctions, I'd say we should commit this instead of waiting any longer.
Comment 13 Leo Savernik 2004-09-02 11:51:36 UTC
CVS commit by savernik: 

Fixed spurious deletion of textarea contents. Original patch by me, improved patch
by Germain Garand.

CCMAIL: 49828-done@bugs.kde.org, 48879-done@bugs.kde.org, 86916-done@bugs.kde.org


  M +12 -0     ChangeLog   1.283
  M +7 -3      html/html_formimpl.cpp   1.383
  M +4 -3      html/html_formimpl.h   1.155
  M +3 -1      rendering/render_form.cpp   1.271


--- kdelibs/khtml/html/html_formimpl.cpp  #1.382:1.383
@@ -2204,4 +2204,5 @@ HTMLTextAreaElementImpl::HTMLTextAreaEle
     m_wrap = ta_Virtual;
     m_dirtyvalue = true;
+    m_initialized = false;
     m_unsubmittedFormChange = false;
 }
@@ -2313,8 +2314,10 @@ DOMString HTMLTextAreaElementImpl::value
 {
     if ( m_dirtyvalue) {
-        if ( m_render )
+        if ( m_render && m_initialized )
             m_value = static_cast<RenderTextArea*>( m_render )->text();
-        else
+        else {
             m_value = defaultValue().string();
+            m_initialized = true;
+        }
 
         m_dirtyvalue = false;
@@ -2332,4 +2335,5 @@ void HTMLTextAreaElementImpl::setValue(D
     m_value = str.replace( '\r', '\n' );
     m_dirtyvalue = false;
+    m_initialized = true;
     setChanged(true);
 }

--- kdelibs/khtml/html/html_formimpl.h  #1.154:1.155
@@ -537,6 +537,7 @@ protected:
     WrapMethod m_wrap;
     QString m_value;
-    bool m_dirtyvalue;
-    bool m_unsubmittedFormChange;
+    bool m_dirtyvalue: 1;
+    bool m_unsubmittedFormChange: 1;
+    bool m_initialized: 1;
 };
 

--- kdelibs/khtml/rendering/render_form.cpp  #1.270:1.271
@@ -1587,6 +1587,8 @@ void RenderTextArea::setStyle(RenderStyl
     RenderFormElement::setStyle(_style);
 
+    widget()->blockSignals(true);
     widget()->setAlignment( _style->direction() == RTL ?
                             Qt::AlignRight : Qt::AlignLeft );
+    widget()->blockSignals(false);
 
     scrollbarsStyled = false;

--- kdelibs/khtml/ChangeLog  #1.282:1.283
@@ -1,2 +1,14 @@
+2004-09-02  Leo Savernik  <l.savernik@aon.at>
+
+        * html_formimpl.{cpp,h} (HTMLTextAreaElementImpl::value):
+        Only take text from RenderTextArea when it has been fully initialized.
+        Mark it fully initialized when RenderTextArea has been initialized
+        from the DOM.
+        (HTMLTextAreaElementImpl::setValue): Mark element as initialized after
+        setting. 
+        * render_form.cpp (RenderTextArea::setStyle):
+        Block signals on call to QTextEdit::setAlignment. Otherwise, a bogus
+        textChanged signal is emitted. 
+
 2004-08-27  Germain Garand  <germain@ebooksfrance.org>
         


Comment 14 Leo Savernik 2004-09-07 12:14:53 UTC
CVS commit by savernik: 

Backport: Fixed spurious deletion of textarea contents.

CCMAIL: 49828@bugs.kde.org, 48879@bugs.kde.org, 86916@bugs.kde.org


  M +7 -3      html/html_formimpl.cpp   1.380.2.2
  M +4 -3      html/html_formimpl.h   1.154.2.1
  M +3 -1      rendering/render_form.cpp   1.269.2.2


--- kdelibs/khtml/html/html_formimpl.cpp  #1.380.2.1:1.380.2.2
@@ -2204,4 +2204,5 @@ HTMLTextAreaElementImpl::HTMLTextAreaEle
     m_wrap = ta_Virtual;
     m_dirtyvalue = true;
+    m_initialized = false;
     m_unsubmittedFormChange = false;
 }
@@ -2313,8 +2314,10 @@ DOMString HTMLTextAreaElementImpl::value
 {
     if ( m_dirtyvalue) {
-        if ( m_render )
+        if ( m_render && m_initialized )
             m_value = static_cast<RenderTextArea*>( m_render )->text();
-        else
+        else {
             m_value = defaultValue().string();
+            m_initialized = true;
+        }
 
         m_dirtyvalue = false;
@@ -2332,4 +2335,5 @@ void HTMLTextAreaElementImpl::setValue(D
     m_value = str.replace( '\r', '\n' );
     m_dirtyvalue = false;
+    m_initialized = true;
     setChanged(true);
 }

--- kdelibs/khtml/html/html_formimpl.h  #1.154:1.154.2.1
@@ -537,6 +537,7 @@ protected:
     WrapMethod m_wrap;
     QString m_value;
-    bool m_dirtyvalue;
-    bool m_unsubmittedFormChange;
+    bool m_dirtyvalue: 1;
+    bool m_unsubmittedFormChange: 1;
+    bool m_initialized: 1;
 };
 

--- kdelibs/khtml/rendering/render_form.cpp  #1.269.2.1:1.269.2.2
@@ -1587,6 +1587,8 @@ void RenderTextArea::setStyle(RenderStyl
     RenderFormElement::setStyle(_style);
 
+    widget()->blockSignals(true);
     widget()->setAlignment( _style->direction() == RTL ?
                             Qt::AlignRight : Qt::AlignLeft );
+    widget()->blockSignals(false);
 
     scrollbarsStyled = false;