Author Topic: problem with creating new console project  (Read 5671 times)

Offline clyfish

  • Multiple posting newcomer
  • *
  • Posts: 26
problem with creating new console project
« on: December 24, 2007, 07:11:02 am »
When I create a console project, the dialog "Please set the language you want to use" disappeared in the last nightly builds(rev 4749).

Now I can only create a c++ project.
How to create a c project?

rev 4592 is OK.

Thanks.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: problem with creating new console project
« Reply #1 on: December 24, 2007, 09:55:57 am »
It works as intended. Please check again. :)
Be a part of the solution, not a part of the problem.

Offline clyfish

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: problem with creating new console project
« Reply #2 on: December 24, 2007, 11:49:11 am »
It works as intended. Please check again. :)
After checking again, I found that rev4592 had the same wrong behaviour.

It can be reproduced by:
1. create a "Win32 GUI project" project
2. create a "Console application" project
In step 2 the dialog to select language disappeared.

Offline clyfish

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: problem with creating new console project
« Reply #3 on: December 24, 2007, 03:23:34 pm »
I have filed a bug report.
[ Bug #12780 ]

The problem is in the win32 gui project wizard script.
[CB path]\share\CodeBlocks\templates\wizard\win32gui\wizard.script [line 60-66]
Code
function OnGetNextPage_CompilerPage()
{
    if (GetCompilerFactory().CompilerInheritsFrom(Wizard.GetCompilerID(), _T("msvc*")))
        return _T("PsdkPath");
    else
        return _T("");
}

All CompilerPanel's m_PageName is "CompilerPage".
/src/plugins/scriptedwizard/wizpage.cpp [line 447-449]
Code
WizCompilerPanel::WizCompilerPanel(const wxString& compilerID, const wxString& validCompilerIDs, wxWizard* parent, const wxBitmap& bitmap,
                                    bool allowCompilerChange, bool allowConfigChange)
    : WizPageBase(_T("CompilerPage"), parent, bitmap),

So "OnGetNextPage_CompilerPage" is called.
/src/plugins/scriptedwizard/wizpage.cpp [line 93-111]
Code
wxWizardPage* WizPageBase::GetNext() const
{
    try
    {
        wxString sig = _T("OnGetNextPage_") + m_PageName;
        SqPlus::SquirrelFunction<wxString&> cb(cbU2C(sig));
        if (cb.func.IsNull())
            return wxWizardPageSimple::GetNext();
        wxString next = cb();
        if (next.IsEmpty())
            return 0;
        return s_PagesByName[next];
    }
    catch (SquirrelError& e)
    {
        Manager::Get()->GetScriptingManager()->DisplayErrors(&e);
    }
    return wxWizardPageSimple::GetNext();
}

So if you has create a win32 gui project, all other project wizard will finish at CompilerPage.(because OnGetNextPage_CompilerPage() return _T("")?)

I don't know how to solve this bug.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: problem with creating new console project
« Reply #4 on: December 24, 2007, 04:19:36 pm »
I have filed a bug report.
[ Bug #12780 ]
....

I don't know how to solve this bug.

I can confirm this bug. Thanks for the investigation and the bug report. I'll look into it. :)
Be a part of the solution, not a part of the problem.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: problem with creating new console project
« Reply #5 on: December 25, 2007, 12:47:10 am »
Here is a quick and dirty patch that make wizard work again.
There is surely a better way to do it, but I could not investigate if it's possible to remove a compiled SquirrelFunction from memory.
So this is an easy way and should not be dangerous (as long as no compiler page is called "function_cleared" or whatever string is used as dummy).

Code
Index: src/plugins/scriptedwizard/wiz.cpp
===================================================================
--- src/plugins/scriptedwizard/wiz.cpp (revision 4750)
+++ src/plugins/scriptedwizard/wiz.cpp (working copy)
@@ -214,7 +214,8 @@
                                                     "function SetupTarget(target,is_debug){return false;};\n"
                                                     "function SetupCustom(){return false;};\n"
                                                     "function CreateFiles(){return _T(\"\");};\n"
-                                                    "function GetFilesDir(){return _T(\"\");};\n"
+                                                    "function GetFilesDir(){return _T(\"\");};\n"
+                                                    "function OnGetNextPage_CompilerPage(){return _T(\"function_cleared\");};\n"
                                                     "function GetGeneratedFile(index){return _T(\"\");};\n");
     Manager::Get()->GetScriptingManager()->LoadBuffer(clearout_wizscripts, _T("ClearWizState"));
 
Index: src/plugins/scriptedwizard/wizpage.cpp
===================================================================
--- src/plugins/scriptedwizard/wizpage.cpp (revision 4750)
+++ src/plugins/scriptedwizard/wizpage.cpp (working copy)
@@ -99,6 +99,8 @@
         if (cb.func.IsNull())
             return wxWizardPageSimple::GetNext();
         wxString next = cb();
+        if (next == _T("function_cleared"))
+            return wxWizardPageSimple::GetNext();
         if (next.IsEmpty())
             return 0;
         return s_PagesByName[next];

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: problem with creating new console project
« Reply #6 on: December 25, 2007, 05:26:23 am »
This is a quite serious bug. It not only affects Console wizard; it also affects other wizards (e.g., wxWidgets project wizard) which has one or more pages beyond the Compiler selection page.

Here is a quick and dirty patch that make wizard work again.
There is surely a better way to do it, but I could not investigate if it's possible to remove a compiled SquirrelFunction from memory.
So this is an easy way and should not be dangerous (as long as no compiler page is called "function_cleared" or whatever string is used as dummy).

The quick patch is ok. But it doesn't fix the issue completely. This issue may resurface with other wizards. :)


@Yiannis,

Is it possible to delete the Squirrel compiled function from the memory after it has been executed? I tried to remove it in the following way. But it didn't work. :(
Code
Index: src/plugins/scriptedwizard/wizpage.cpp
===================================================================
--- src/plugins/scriptedwizard/wizpage.cpp (revision 4750)
+++ src/plugins/scriptedwizard/wizpage.cpp (working copy)
@@ -98,7 +98,8 @@
         SqPlus::SquirrelFunction<wxString&> cb(cbU2C(sig));
         if (cb.func.IsNull())
             return wxWizardPageSimple::GetNext();
-        wxString next = cb();
+        wxString next = cb();
+        cb.reset();
         if (next.IsEmpty())
             return 0;
         return s_PagesByName[next];

Best regards,

Biplab
Be a part of the solution, not a part of the problem.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: problem with creating new console project
« Reply #7 on: December 25, 2007, 11:35:11 am »
Another question I have:
To clear the functions of a formerly run wizardscript, new functions with the same name, but default return-values are compiled.
What happens to the "old" function-pointers and the content of the functions, are they still on the stack (and somewhere in the memory) or are they removed by the SquirrelVM .

If they reside in memory this might be potential dangerous.