Author Topic: C::B crash (Settings-->Editor)  (Read 36924 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5209
Re: C::B crash (Settings-->Editor)
« Reply #60 on: April 21, 2006, 09:14:57 am »
it's weird that compiler/linker/loader/ ??? is mixing them up.
As said, no need to change the plug-in, I adjusted the name of the structure in the projectfileoptionsdlg.cpp :

LanguageDef --> SLanguageDef  (S from struct).


How about the following ideas :
 - plug-ins : use pimpl idiom
 - put the plug-in implementation in a seperate namespace

Now it was some kind of obvious because of the copy, but it might well be possible that a type might be created in the sdk and a plug-in (or in several plug-ins).

Should we make a guideline out of this : namespaces !!
 - for that matter we could put the CB core/code also in a namespace (lot's of files to adjust though), but it would be better. Maybe it's easier to start out with the plug-ins.

What do you think ?



[edit] : could you give it a try with the original codestats code and rev 2367 ?
« Last Edit: April 21, 2006, 09:25:01 am by killerbot »

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: C::B crash (Settings-->Editor)
« Reply #61 on: April 21, 2006, 03:38:39 pm »
it's weird that compiler/linker/loader/ ??? is mixing them up.
As said, no need to change the plug-in, I adjusted the name of the structure in the projectfileoptionsdlg.cpp :

LanguageDef --> SLanguageDef  (S from struct).


How about the following ideas :
 - plug-ins : use pimpl idiom
 - put the plug-in implementation in a seperate namespace

Now it was some kind of obvious because of the copy, but it might well be possible that a type might be created in the sdk and a plug-in (or in several plug-ins).

Should we make a guideline out of this : namespaces !!
 - for that matter we could put the CB core/code also in a namespace (lot's of files to adjust though), but it would be better. Maybe it's easier to start out with the plug-ins.

What do you think ?

I am not an expert with C++ namespaces, but their implementation within C::B would probably require some code re-designing.

[edit] : could you give it a try with the original codestats code and rev 2367 ?

No crashes, but codestats plugin does not work (it does not crash anyway). Still get the warning dialog "The project is empty" (even if it is not).

The only way to make happy both (codestats plugin & Settings-->Editor) was to add wxString name; to the structure in the sdk.... :?

Best wishes,
Michael

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2186
Re: C::B crash (Settings-->Editor)
« Reply #62 on: April 21, 2006, 03:45:13 pm »
No crashes, but codestats plugin does not work (it does not crash anyway). Still get the warning dialog "The project is empty" (even if it is not).

The only way to make happy both (codestats plugin & Settings-->Editor) was to add wxString name; to the structure in the sdk.... :?


Please don't do that. Give me some more time. I'll get
this fixed.

thanks
pecan

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: C::B crash (Settings-->Editor)
« Reply #63 on: April 21, 2006, 03:59:50 pm »
No crashes, but codestats plugin does not work (it does not crash anyway). Still get the warning dialog "The project is empty" (even if it is not).

The only way to make happy both (codestats plugin & Settings-->Editor) was to add wxString name; to the structure in the sdk.... :?


Please don't do that. Give me some more time. I'll get
this fixed.

I do no want to do that :). I just wanted to say what seems to work for both at this moment. There should be something that prevent the codestats to work. The project files are parsed, but then the warning message appears. This is strange. If the project is empty why parsing the files takes such a lot of time (e.g., C::B cbp)?

Best wishes,
Michael

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2186
Re: C::B crash (Settings-->Editor)
« Reply #64 on: April 21, 2006, 06:34:19 pm »
There should be something that prevent the codestats to work. The project files are parsed, but then the warning message appears. This is strange. If the project is empty why parsing the files takes such a lot of time (e.g., C::B cbp)?

Actually, it is working. Only very wierdly.

Make sure to clear data between <codestat> and </codestat> out of the
  default.conf (backup defautl.conf first please)
Start CB with codestat enabled.
Open a project.
Invoke Plugins/Code Statistics menu iitem.
     Do *NOT* invoke Settings/Editor
     (It scans and reports for me).
      (You can do this many times)
Now, invoke Setting Editor/Code Stat Settings
Note that all but the "name" fields are blank
Click on OK

Now when you invoke Plugins/CodeStat it reports there is no project
because it has no fields to compare against except "blank". All its settings have been set to blank.

There is a logic err somewhere. Will look at that now...

thanks
pecan

« Last Edit: April 21, 2006, 06:36:06 pm by Pecan »

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: C::B crash (Settings-->Editor)
« Reply #65 on: April 21, 2006, 07:11:18 pm »
There should be something that prevent the codestats to work. The project files are parsed, but then the warning message appears. This is strange. If the project is empty why parsing the files takes such a lot of time (e.g., C::B cbp)?

Actually, it is working. Only very wierdly.

Make sure to clear data between <codestat> and </codestat> out of the
  default.conf (backup defautl.conf first please)
Start CB with codestat enabled.
Open a project.
Invoke Plugins/Code Statistics menu iitem.
     Do *NOT* invoke Settings/Editor
     (It scans and reports for me).
      (You can do this many times)
Now, invoke Setting Editor/Code Stat Settings
Note that all but the "name" fields are blank
Click on OK

Now when you invoke Plugins/CodeStat it reports there is no project
because it has no fields to compare against except "blank". All its settings have been set to blank.

There is a logic err somewhere. Will look at that now...

Yes, I can confirm all what you have said. Doing Settings-->Editor makes the codestats plugin stopping to work (until you deleted the data between the codestat element).

Best wishes,
Michael

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2186
Re: C::B crash (Settings-->Editor)
« Reply #66 on: April 21, 2006, 09:20:42 pm »
Success! Both in windows and in Linux. Whew...!

It seems that there are a lot of evils one can perform under
wxMSW that bites you in the @ss when performed under
wxGTK.

For example, under wxMSW you can allocate a wxStaticText
in code, but define it as  a wxTextCtrl in XRC, then use SetLabel() on it when there is NO SetLabel() routine defined for wxTextCtrl.

This doesn't work under Linux.

And... this sort of thing will often cause a segfault when running under the
debug version of wxWidgets.

Code: [Select]
void CodeStatConfigDlg::PrintLanguageInfo(int id)
{
    selected_language = id;
wxStaticText* txt_FileTypes = XRCCTRL(*this, "txt_FileTypes", wxStaticText);
wxString ext_string = _T("");
for (unsigned int i=0; i<languages[id].ext.GetCount(); ++i)
{
   ext_string = ext_string + _T(" ") + languages[id].ext[i];
}
txt_FileTypes->SetLabel(ext_string);
wxStaticText* txt_SingleComment = XRCCTRL(*this, "txt_SingleComment", wxStaticText);
txt_SingleComment->SetLabel(languages[id].single_line_comment);
wxStaticText* txt_MultiLineCommentBegin = XRCCTRL(*this, "txt_MultiLineCommentBegin", wxStaticText);
txt_MultiLineCommentBegin->SetLabel(languages[id].multiple_line_comment[0]);
wxStaticText* txt_MultiLineCommentEnd = XRCCTRL(*this, "txt_MultiLineCommentEnd", wxStaticText);
txt_MultiLineCommentEnd->SetLabel(languages[id].multiple_line_comment[1]);
}


All the above wxStaticText's are defined in the CodeStat XRC as wxTextCtrl's
So I've changed the code accordingly.

Please find attached the source for the fixed CodeStat.

thanks
pecan


[attachment deleted by admin]
« Last Edit: April 21, 2006, 09:43:26 pm by Pecan »

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: C::B crash (Settings-->Editor)
« Reply #67 on: April 21, 2006, 09:36:07 pm »
Success! Both in windows and in Linux. Whew...!

It seems that there are a lot of evils one can perform under
wxMSW that bites you in the @ss when performed under
wxGTK.

For example, under wxMSW you can allocate a wxStaticText
in code, but define it as  a wxTextCtrl in XRC, then use SetLabel() on it when there is NO SetLabel() routine defined for wxTextCtrl.

This doesn't work under Linux.

And... this sort of thing will often case a segfault when running under the
debug version of wxWidgets.

Code: [Select]
void CodeStatConfigDlg::PrintLanguageInfo(int id)
{
    selected_language = id;
wxStaticText* txt_FileTypes = XRCCTRL(*this, "txt_FileTypes", wxStaticText);
wxString ext_string = _T("");
for (unsigned int i=0; i<languages[id].ext.GetCount(); ++i)
{
   ext_string = ext_string + _T(" ") + languages[id].ext[i];
}
txt_FileTypes->SetLabel(ext_string);
wxStaticText* txt_SingleComment = XRCCTRL(*this, "txt_SingleComment", wxStaticText);
txt_SingleComment->SetLabel(languages[id].single_line_comment);
wxStaticText* txt_MultiLineCommentBegin = XRCCTRL(*this, "txt_MultiLineCommentBegin", wxStaticText);
txt_MultiLineCommentBegin->SetLabel(languages[id].multiple_line_comment[0]);
wxStaticText* txt_MultiLineCommentEnd = XRCCTRL(*this, "txt_MultiLineCommentEnd", wxStaticText);
txt_MultiLineCommentEnd->SetLabel(languages[id].multiple_line_comment[1]);
}


All the above wxStaticText's are defined in the CodeStat XRC as wxTextCtrl's
So I've changed the code accordingly.

Please find attached the source for the fixed CodeStat.

Thank you very much. That was great work :).

Would it possible to add it to the SVN sources?

May be the problem with Settings-->Environment is similar as the Settings-->Editor one.

Now I have just to understand why the deb package generation does not work :).

Best wishes,
Michael

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2186
Re: C::B crash (Settings-->Editor)
« Reply #68 on: April 21, 2006, 09:47:41 pm »
Would it possible to add it to the SVN sources?

um.. who is responsible for CodeStat? If no one is,
I'll ask Yiannis for permission to update it, but I don't
want to step on anyones toes.

thanks
pecan

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: C::B crash (Settings-->Editor)
« Reply #69 on: April 21, 2006, 09:55:15 pm »
Would it possible to add it to the SVN sources?

um.. who is responsible for CodeStat? If no one is,
I'll ask Yiannis for permission to update it, but I don't
want to step on anyones toes.

I understand. I am not sure too, but I think Zlika.

Best wishes,
Michael

Offline Zlika

  • Plugin developer
  • Multiple posting newcomer
  • ****
  • Posts: 59
Re: C::B crash (Settings-->Editor)
« Reply #70 on: April 21, 2006, 10:14:48 pm »
Thank you very much for your help.
I have commited the "wxTextCtrl's changes", but not the CSLanguageDef because killerbot changed its LanguageDef to SLanguageDef, so it should be ok now on this point.

But someone have made a change because when compiling I have:
codestat.cpp: In member function `virtual cbConfigurationPanel* CodeStat::GetConfigurationPanel(wxWindow*)':
codestat.cpp:80: error: cannot allocate an object of type `CodeStatConfigDlg'
codestat.cpp:80: error:   because the following virtual functions are abstract:
sdk/configurationpanel.h:19: error:  virtual wxString cbConfigurationPanel::GetTitle()
sdk/configurationpanel.h:21: error:  virtual wxString cbConfigurationPanel::GetBitmapBaseName()

Doctor C++, could you cure this too? :-)
« Last Edit: April 21, 2006, 10:30:13 pm by Zlika »

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: C::B crash (Settings-->Editor)
« Reply #71 on: April 21, 2006, 11:05:55 pm »
I have commited the "wxTextCtrl's changes", but not the CSLanguageDef because killerbot changed its LanguageDef to SLanguageDef, so it should be ok now on this point.

Thank you very much :).

Yes, I think so too. The CSLanguageDef should be not necessary now.

Best wishes,
Michael

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2186
Re: C::B crash (Settings-->Editor)
« Reply #72 on: April 21, 2006, 11:19:32 pm »
But someone have made a change because when compiling I have:
codestat.cpp: In member function `virtual cbConfigurationPanel* CodeStat::GetConfigurationPanel(wxWindow*)':
codestat.cpp:80: error: cannot allocate an object of type `CodeStatConfigDlg'
codestat.cpp:80: error:   because the following virtual functions are abstract:
sdk/configurationpanel.h:19: error:  virtual wxString cbConfigurationPanel::GetTitle()
sdk/configurationpanel.h:21: error:  virtual wxString cbConfigurationPanel::GetBitmapBaseName()

Doctor C++, could you cure this too? :-)

Yes.. I had that problem too. It seems the plugin interface
changed recently.

But if you'll just use the .zip I uploaded with the latest SVN,
(changing the CSLanguage back to Language), I think it'll
work fine with the latest SVN.

thanks
pecan


EDIT: the .zip I uploaded compiles fine with SVN 2366 on
both windows XP and Ubuntu 510

Someone added some const's to the declaration headers, making
the current definitions incompatible. But if you'll modify
the current (from SVN 2366) versions, all will compile.
 
« Last Edit: April 21, 2006, 11:31:40 pm by Pecan »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5209
Re: C::B crash (Settings-->Editor)
« Reply #73 on: April 21, 2006, 11:39:43 pm »
yes, some methods became const, but all plug-ins in svn have been updated.
So apply your changes on the latest in svn and all should be fine.

Offline Der Meister

  • Regular
  • ***
  • Posts: 307
Re: C::B crash (Settings-->Editor)
« Reply #74 on: May 12, 2006, 09:48:26 pm »
Anyway, I still had the problem that the textcontrols in the config-dialog were empty. I found out that the problem was the function that was used to set the value for the textcontrol. The function that was used was SetLabel. But this function is not even mentioned as member of wxTextCtrl. I don't know from which parent-class this member-function was inherited (I would gess wxWindow) but it was probably not intended to set the value for the textcontrol. After changing SetLabel to SetValue (that is the correct function, according to the documentation of wxTextCtrl) everything works fine. The values are displayed and the codestats plugin doesn't complain about an empty project any more.
Here is the patch for this:
Code: [Select]
Index: src/plugins/contrib/codestat/codestatconfig.cpp
===================================================================
--- src/plugins/contrib/codestat/codestatconfig.cpp     (revision 2448)
+++ src/plugins/contrib/codestat/codestatconfig.cpp     (working copy)
@@ -50,13 +50,13 @@
 {
     // Clear text fields and combobox
     wxTextCtrl* txt_FileTypes = XRCCTRL(*this, "txt_FileTypes", wxTextCtrl);
-    txt_FileTypes->SetLabel(_T(""));
+    txt_FileTypes->SetValue(_T(""));
     wxTextCtrl* txt_SingleComment = XRCCTRL(*this, "txt_SingleComment", wxTextCtrl);
-    txt_SingleComment->SetLabel(_T(""));
+    txt_SingleComment->SetValue(_T(""));
     wxTextCtrl* txt_MultiLineCommentBegin = XRCCTRL(*this, "txt_MultiLineCommentBegin", wxTextCtrl);
-    txt_MultiLineCommentBegin->SetLabel(_T(""));
+    txt_MultiLineCommentBegin->SetValue(_T(""));
     wxTextCtrl* txt_MultiLineCommentEnd = XRCCTRL(*this, "txt_MultiLineCommentEnd", wxTextCtrl);
-    txt_MultiLineCommentEnd->SetLabel(_T(""));
+    txt_MultiLineCommentEnd->SetValue(_T(""));
     wxComboBox* combo_Names = XRCCTRL(*this, "combo_Names", wxComboBox);
     combo_Names->Clear();
 
@@ -150,13 +150,13 @@
        {
           ext_string = ext_string + _T(" ") + languages[id].ext[i];
        }
-       txt_FileTypes->SetLabel(ext_string);
+       txt_FileTypes->SetValue(ext_string);
        wxTextCtrl* txt_SingleComment = XRCCTRL(*this, "txt_SingleComment", wxTextCtrl);
-       txt_SingleComment->SetLabel(languages[id].single_line_comment);
+       txt_SingleComment->SetValue(languages[id].single_line_comment);
        wxTextCtrl* txt_MultiLineCommentBegin = XRCCTRL(*this, "txt_MultiLineCommentBegin", wxTextCtrl);
-       txt_MultiLineCommentBegin->SetLabel(languages[id].multiple_line_comment[0]);
+       txt_MultiLineCommentBegin->SetValue(languages[id].multiple_line_comment[0]);
        wxTextCtrl* txt_MultiLineCommentEnd = XRCCTRL(*this, "txt_MultiLineCommentEnd", wxTextCtrl);
-       txt_MultiLineCommentEnd->SetLabel(languages[id].multiple_line_comment[1]);
+       txt_MultiLineCommentEnd->SetValue(languages[id].multiple_line_comment[1]);
 }
 
 /** Add configuration for a new language.
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand.
Real Programmers don't write in BASIC. Actually, no programmers write in BASIC, after the age of 12.