Bug 132835 - Select S&S indentation. Type '///', followed by enter. Segfaults.
Summary: Select S&S indentation. Type '///', followed by enter. Segfaults.
Status: RESOLVED DUPLICATE of bug 131933
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: HI crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 133087 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-08-23 02:00 UTC by Tim Hutt
Modified: 2007-08-30 10:41 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Hutt 2006-08-23 02:00:47 UTC
Version:            (using KDE KDE 3.5.4)
Installed from:    Ubuntu Packages
OS:                Linux

See subject.

Weak.

(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[KCrash handler]
#6  0xb634c54a in KateTextLine::stringAtPos ()
   from /usr/lib/kde3/libkatepart.so
#7  0xb63df5d8 in KateCSAndSIndent::handleDoxygen ()
   from /usr/lib/kde3/libkatepart.so
#8  0xb63df99e in KateCSAndSIndent::processNewline ()
   from /usr/lib/kde3/libkatepart.so
#9  0xb6410605 in KateDocument::newLine () from /usr/lib/kde3/libkatepart.so
#10 0xb64179aa in KateViewInternal::doReturn ()
   from /usr/lib/kde3/libkatepart.so
#11 0xb643aee7 in KateView::keyReturn () from /usr/lib/kde3/libkatepart.so
#12 0xb641977e in KateViewInternal::keyPressEvent ()
   from /usr/lib/kde3/libkatepart.so
#13 0xb63fdc69 in KateViewInternal::eventFilter ()
   from /usr/lib/kde3/libkatepart.so
#14 0xb721a002 in QObject::activate_filters () from /usr/lib/libqt-mt.so.3
#15 0xb721a080 in QObject::event () from /usr/lib/libqt-mt.so.3
#16 0xb72575aa in QWidget::event () from /usr/lib/libqt-mt.so.3
#17 0xb71b2e56 in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3
#18 0xb71b31ee in QApplication::notify () from /usr/lib/libqt-mt.so.3
#19 0xb78917ab in KApplication::notify () from /usr/lib/libkdecore.so.4
#20 0xb71441c5 in QApplication::sendSpontaneousEvent ()
   from /usr/lib/libqt-mt.so.3
#21 0xb7137e65 in QETWidget::translateKeyEvent () from /usr/lib/libqt-mt.so.3
#22 0xb713ddcc in QApplication::x11ProcessEvent () from /usr/lib/libqt-mt.so.3
#23 0xb71574db in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3
#24 0xb71cb947 in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3
#25 0xb71cb86a in QEventLoop::exec () from /usr/lib/libqt-mt.so.3
#26 0xb71b1965 in QApplication::exec () from /usr/lib/libqt-mt.so.3
#27 0xb6758dea in kdemain () from /usr/lib/libkdeinit_kate.so
#28 0xb7f2b4f0 in kdeinitmain () from /usr/lib/kde3/kate.so
#29 0x0804e173 in ?? ()
#30 0x00000002 in ?? ()
#31 0x081386c8 in ?? ()
#32 0x00000001 in ?? ()
#33 0x00000000 in ?? ()

Btw, just tested and it doesn't do it in a blank file - load some C++ file and do it in a function or something.
Comment 1 Tim Hutt 2006-08-23 02:23:54 UTC
Changed to high as you can lose work just by typing!

Also, it didn't work in a blank file, because that didn't seem to do indentation even after getting tools->indentation->SS [sic - fixed in trunk I noticed!] style.

Is that another bug?

I'll try and fix this tomorrow.
Comment 2 Andreas Kling 2006-08-23 07:30:05 UTC
Indenter depends on highlighter. Set a highlighting mode and the indenter will work in a blank document too.

*** This bug has been marked as a duplicate of 131933 ***
Comment 3 Tim Hutt 2006-08-23 14:51:37 UTC
Are you sure?

I did these exact steps:

a) Start kate (gives you an 'untitled' document)
b) Tools->Indentation->S&S style
c) Tools->Highlighting->Sources->C++
d) Type this:
int main()
{ <enter>

And it doesn't indent it. Maybe I'm missing something.

Thanks for fixing the other bug!
Comment 4 Dominik Haumann 2006-08-25 11:42:44 UTC
a) Start kate (gives you an 'untitled' document)
b) Tools->Indentation->S&S style
c) Tools->Highlighting->Sources->C++
d) Type this:
int main()
{ <enter>

result: No indentation

Now, step b and c swapped:

a) Start kate (gives you an 'untitled' document)
b) Tools->Highlighting->Sources->C++
c) Tools->Indentation->S&S style
d) Type this:
int main()
{ <enter>

result: Indentation works.

Reason for the bug:
KateAutoIndent::updateConfig() is called when creating an instance of the indenter, it then reads highlighting information and caches them. Highlighting is not set yet, so the cached infos are wrong.

That's why it works, if we swap b and c.

Fix: Call m_indenter->updateConfig() whenever the Highlighting changes.

Todo: find the right place for this call ;)
Comment 5 Dominik Haumann 2006-08-25 14:01:55 UTC
Maybe it would even be better, if the indenters that rely on highlighting connect themselves to the signal KateDocument::hlChanged().

Any comments of kate devs? :)
Comment 6 Dominik Haumann 2006-08-25 14:05:51 UTC
proposal:
1. make KateAutoIndent::updateConfig() a public slot.
2. connect signal doc->hlChanged() to updateConfig() in KateNormalIndenter's constructor.
Comment 7 Dominik Haumann 2006-08-25 18:26:53 UTC
SVN commit 577126 by dhaumann:

fix the bug state in comment #3 of bug #132835.
(This includes deriving KateAutoIndent from QObject.)
CCBUG: 132835


 M  +5 -4      kateautoindent.cpp  
 M  +21 -2     kateautoindent.h  


--- branches/KDE/3.5/kdelibs/kate/part/kateautoindent.cpp #577125:577126
@@ -148,7 +148,7 @@
 }
 
 KateAutoIndent::KateAutoIndent (KateDocument *_doc)
-: doc(_doc)
+: QObject(), doc(_doc)
 {
 }
 KateAutoIndent::~KateAutoIndent ()
@@ -186,7 +186,10 @@
 KateNormalIndent::KateNormalIndent (KateDocument *_doc)
  : KateAutoIndent (_doc)
 {
+  // if highlighting changes, update attributes
+  connect(_doc, SIGNAL(hlChanged()), this, SLOT(updateConfig()));
 }
+
 KateNormalIndent::~KateNormalIndent ()
 {
 }
@@ -2022,7 +2025,7 @@
 };
 
 KateVarIndent::KateVarIndent( KateDocument *doc )
-: QObject( 0, "variable indenter"), KateNormalIndent( doc )
+: KateNormalIndent( doc )
 {
   d = new KateVarIndentPrivate;
   d->reIndentAfter = QRegExp( doc->variable( "var-indent-indent-after" ) );
@@ -2070,8 +2073,6 @@
 
 void KateVarIndent::processLine ( KateDocCursor &line )
 {
-  updateConfig(); // ### is it really nessecary *each time* ??
-
   QString indent; // store the indent string here
 
   // find the first line with content that is not starting with comment text,
--- branches/KDE/3.5/kdelibs/kate/part/kateautoindent.h #577125:577126
@@ -67,8 +67,10 @@
  * This baseclass is a real dummy, does nothing beside remembering the document it belongs too,
  * only to have the object around
  */
-class KateAutoIndent
+class KateAutoIndent : public QObject
 {
+  Q_OBJECT
+
   /**
    * Static methods to create and list indention modes
    */
@@ -133,11 +135,13 @@
      */
     virtual ~KateAutoIndent ();
 
+  public slots:
     /**
      * Update indenter's configuration (indention width, attributes etc.)
      */
     virtual void updateConfig () {};
 
+  public:
     /**
      * does this indenter support processNewLine
      * @return can you do it?
@@ -212,6 +216,8 @@
  */
 class KateNormalIndent : public KateAutoIndent
 {
+  Q_OBJECT
+
 public:
     /**
      * Constructor
@@ -224,11 +230,13 @@
      */
   virtual ~KateNormalIndent ();
 
+public slots:
     /**
      * Update indenter's configuration (indention width, attributes etc.)
      */
   virtual void updateConfig ();
 
+public:
     /**
      * does this indenter support processNewLine
      * @return can you do it?
@@ -334,6 +342,8 @@
 
 class KateCSmartIndent : public KateNormalIndent
 {
+  Q_OBJECT
+
   public:
     KateCSmartIndent (KateDocument *doc);
     ~KateCSmartIndent ();
@@ -363,6 +373,8 @@
 
 class KatePythonIndent : public KateNormalIndent
 {
+  Q_OBJECT
+
   public:
     KatePythonIndent (KateDocument *doc);
     ~KatePythonIndent ();
@@ -381,6 +393,8 @@
 
 class KateXmlIndent : public KateNormalIndent
 {
+  Q_OBJECT
+
   public:
     KateXmlIndent (KateDocument *doc);
     ~KateXmlIndent ();
@@ -408,6 +422,8 @@
 
 class KateCSAndSIndent : public KateNormalIndent
 {
+  Q_OBJECT
+
   public:
     KateCSAndSIndent (KateDocument *doc);
     ~KateCSAndSIndent ();
@@ -467,9 +483,10 @@
  * The idea is to provide a somewhat intelligent indentation for perl, php,
  * bash, scheme and in general formats with humble indentation needs.
  */
-class KateVarIndent :  public QObject, public KateNormalIndent
+class KateVarIndent : public KateNormalIndent
 {
   Q_OBJECT
+
   public:
     /**
      * Purely for readability, couples we know and love
@@ -519,6 +536,8 @@
 
 class KateScriptIndent : public KateNormalIndent
 {
+  Q_OBJECT
+
   public:
     KateScriptIndent( KateDocument *doc );
     ~KateScriptIndent();
Comment 8 Andreas Kling 2006-08-27 22:15:34 UTC
*** Bug 133087 has been marked as a duplicate of this bug. ***