Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

SVNInside : development of another SVN plugin for CodeBlocks

<< < (5/31) > >>

stahta01:
Patch to Fix compiling under Windows without using Precompiled Headers.
Also, fixes some rules that killerbot has passed on to me.

killerbot inspired ones.
1. If possible, headers should use forward declarations instead of includes.
2. Headers should never include pre-compiled headers like [sdk.h] or [wxprec.h].
    Do not include sdk.h in headers
    Do not include wxprec.h in headers
    Do not use WX_PRECOMP in headers
    Do not use CB_PRECOMP in headers

Ones I decided on by myself.
3. Used system includes in plugins for C::B SDK and wxWidgets includes.
   In plugins, use [#include <sdk.h>] instead of [#include "sdk.h"]

4. Do not use [#include <wx/wx.h>] in either production headers or source code.


--- Code: ---Index: src/Dialogs/wxSVNTreeCtrl.h
===================================================================
--- src/Dialogs/wxSVNTreeCtrl.h (revision 7)
+++ src/Dialogs/wxSVNTreeCtrl.h (working copy)
@@ -1,13 +1,7 @@
 #ifndef WXSVNTREECTRL_H
 #define WXSVNTREECTRL_H
 
-// For compilers that support precompilation, includes <wx/wx.h>
-#include <wx/wxprec.h>
 
-#ifndef WX_PRECOMP
-    #include <wx/wx.h>
-#endif
-
 #include <cbplugin.h>
 #include <wx/treectrl.h>
 
Index: src/Dialogs/ConfigDialog.cpp
===================================================================
--- src/Dialogs/ConfigDialog.cpp (revision 7)
+++ src/Dialogs/ConfigDialog.cpp (working copy)
@@ -21,7 +21,13 @@
 #endif
 
 #ifndef WX_PRECOMP
-#include "wx/wx.h"
+#include <wx/checkbox.h>
+#include <wx/dialog.h>
+#include <wx/dirdlg.h>
+#include <wx/filedlg.h>
+#include <wx/log.h>
+#include <wx/stattext.h>
+#include <wx/window.h>
 #endif
 
 ////@begin includes
@@ -30,6 +36,7 @@
 #include "ConfigDialog.h"
 #include "wx/file.h"
 #include "wx/dir.h"
+#include <wx/sizer.h>
 #include "wx/textctrl.h"
 #include "SVNInside_globals.h"
 
Index: src/Dialogs/SVNFileSelect.cpp
===================================================================
--- src/Dialogs/SVNFileSelect.cpp (revision 7)
+++ src/Dialogs/SVNFileSelect.cpp (working copy)
@@ -1,7 +1,7 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        SVNFileSelect.cpp
 // Purpose:
-// Author:      Aurélien Rainone
+// Author:      Aurélien Rainone
 // Modified by:
 // Created:     02/10/2007 22:45:30
 // RCS-ID:
@@ -21,7 +21,12 @@
 #endif
 
 #ifndef WX_PRECOMP
-#include "wx/wx.h"
+#include <wx/button.h>
+#include <wx/checklst.h>
+#include <wx/log.h>
+#include <wx/sizer.h>
+#include <wx/stattext.h>
+#include <wx/textctrl.h>
 #endif
 
 ////@begin includes
Index: src/Dialogs/ConfigDialog.h
===================================================================
--- src/Dialogs/ConfigDialog.h (revision 7)
+++ src/Dialogs/ConfigDialog.h (working copy)
@@ -32,7 +32,10 @@
  */
 
 ////@begin forward declarations
+class wxStaticText;
 class wxToggleButton;
+class wxTextCtrl;
+class wxCheckBox;
 ////@end forward declarations
 
 /*!
Index: src/Dialogs/wxSVNTreeCtrl.cpp
===================================================================
--- src/Dialogs/wxSVNTreeCtrl.cpp (revision 7)
+++ src/Dialogs/wxSVNTreeCtrl.cpp (working copy)
@@ -1,4 +1,8 @@
 #include <sdk.h> // Code::Blocks SDK
+#ifndef CB_PRECOMP
+    #include <configmanager.h>
+    #include <cbproject.h>
+#endif
 #include <wx/menu.h>
 #include <wx/imaglist.h>
 
Index: src/Dialogs/SVNFileSelect.h
===================================================================
--- src/Dialogs/SVNFileSelect.h (revision 7)
+++ src/Dialogs/SVNFileSelect.h (working copy)
@@ -22,6 +22,7 @@
 
 ////@begin includes
 #include "wx/xrc/xmlres.h"
+#include <wx/dialog.h>
 #include "SVNInside_globals.h"
 ////@end includes
 
@@ -30,6 +31,10 @@
  */
 
 ////@begin forward declarations
+class wxButton;
+class wxCheckListBox;
+class wxStaticText;
+class wxTextCtrl;
 ////@end forward declarations
 
 /*!
Index: src/SVNInside.cpp
===================================================================
--- src/SVNInside.cpp (revision 7)
+++ src/SVNInside.cpp (working copy)
@@ -1,4 +1,9 @@
 #include <sdk.h> // Code::Blocks SDK
+#ifndef CB_PRECOMP
+    #include <projectmanager.h>
+    #include <cbproject.h>
+#endif
+
 #include <configurationpanel.h>
 
 #include "SVNInside.h"
Index: src/SVNCommand/CSVNcommand.h
===================================================================
--- src/SVNCommand/CSVNcommand.h (revision 7)
+++ src/SVNCommand/CSVNcommand.h (working copy)
@@ -1,13 +1,8 @@
 #ifndef CSVNCOMMAND_H
 #define CSVNCOMMAND_H
 
-// For compilers that support precompilation, includes <wx/wx.h>
-#include <wx/wxprec.h>
+#include <wx/string.h>
 
-#ifndef WX_PRECOMP
-    #include <wx/wx.h>
-#endif
-
 #include <string>
 
 #include "ConsoleProc.h"
Index: src/SVNInside.h
===================================================================
--- src/SVNInside.h (revision 7)
+++ src/SVNInside.h (working copy)
@@ -10,13 +10,8 @@
 #ifndef SVNINSIDE_H_INCLUDED
 #define SVNINSIDE_H_INCLUDED
 
-// For compilers that support precompilation, includes <wx/wx.h>
-#include <wx/wxprec.h>
+#include <wx/process.h>     // for "class wxProcess"
 
-#ifndef WX_PRECOMP
-    #include <wx/wx.h>
-#endif
-
 #include <cbplugin.h>       // for "class cbPlugin"
 #include <tinyxml.h>        // for "tinyxml API"
 #include <string>

--- End code ---

MortenMacFly:
There is a loigical issue in wxSVNTreeCtrl.cpp which leads to a crash:

--- Code: ---    SVNTreeItemData * pdata = 0; wxTreeItemData * ptr = this->GetItemData(id);
    if (ptr)
    {
        pdata = static_cast<SVNTreeItemData*>(ptr); if (!pdata) return 0;
    }
    [...]
    if (pdata->m_bIsFile)

--- End code ---
At the last line pdata can still be "0" (and in fact it is if you right-click in svninside on the message "project not under version control". If it is the case the plugin crashes C::B. I suggest adding a null pointer check or changing the logic in the code above that "if" construct.
With regards, Morten.

Edit:
I have changed the code to the foillowing which works OK:

--- Code: ---    // get item data
    SVNTreeItemData * pdata = 0; wxTreeItemData * ptr = this->GetItemData(id);
    if (ptr)
    {
        pdata = static_cast<SVNTreeItemData*>(ptr);
    }
    if (!pdata) return 0;
    [...]

--- End code ---
This may make sense, too:

--- Code: ---    // get item data
    SVNTreeItemData * pdata = 0; wxTreeItemData * ptr = this->GetItemData(id);
    if (!ptr) return 0;
    else
    {
        pdata = static_cast<SVNTreeItemData*>(ptr);
    }
    if (!pdata) return 0;
    [...]

--- End code ---

Jan van den Borst:

--- Quote from: killerbot on October 09, 2007, 09:22:31 pm ---Once CB 1.0 is out, we gonna try to create a common interface for version control system in CB (like M$ does).

--- End quote ---
Is there something like a preliminary source control interface description?

Jan

thomas:

--- Quote from: JGM on October 10, 2007, 03:57:16 am ---I use it on windows and linux and it works fine. I don't know what could go wrong since for me is working. :?
[...]
thats a function to retrieve the svn revision using wxExecute and it works pretty well on both platforms.
--- End quote ---
Yes, and that is a function that will make the GUI unresponsive for as long as Subversion is running. It is also a function that can have 500 other problems, including lock-up and stale processes, and crashes on exit, if a subprocess is still running. wxExecute is one big pile of crap. In particular, you'll be having a lot of fun if you try to get it to work asynchronously, and if you want to process the events. Apart from the abysmal performance, pointers being held in int variables are a lot of fun, especially if you run your code on a 64 bit platform for the first time. Let's not talk about reading data from a pipe in a tight spinloop and making 3-4 data copies...  :)

I had implemented a Subversion plugin for RC2 that worked exactly the way Orel described (except for using the project file tree, instead of its own, and running asynchronously). It was due for a rewrite, but I never did it, mostly because it's so frustrating to work with wxExecute.
I've written a replacement class with a Windows implementation, and Jonas Thedering contributed the POSIX implementation. Somehow, nobody was really interested in it, and no one would even wager to look at it, so... that thing is still in the attic (for nearly 2 years now).

killerbot:
I must say I have seen a ClearCase command not returning in the wxExecute call, and indeed then the GUI of CB is locked. But overall I found it working ok.

@Thomas : so what are you still doing in the basement, get up there on that attic ;-)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version