Summary: | Textarea is empty in particular Dokuwiki page | ||
---|---|---|---|
Product: | [Applications] konqueror | Reporter: | Hasso Tepper <hasso> |
Component: | khtml forms | Assignee: | Konqueror Developers <konq-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | grave | CC: | germain, l.savernik |
Priority: | NOR | ||
Version: | 3.3 | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: |
proposed fix
better fix alternative patch |
Description
Hasso Tepper
2004-08-10 15:50:59 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 it's possibly related to #49828 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. Created attachment 7272 [details] proposed fix Combo fix for both bug 49868 and this one. Comment on attachment 7272 [details] proposed fix I certainly meant bug 49828. Once you don't copy&paste ... 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. Created attachment 7278 [details]
better fix
The last fix crashed in HTMLTextAreaElementImpl::state. This one doesn't.
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? 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/* 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 #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. 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> 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; |