Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#1154 Compilation broken on wxWidgets platform

Bug
closed-fixed
Neil Hodgson
Scintilla (788)
2
2011-06-20
2011-05-23
Morten MacFly
No

The compilaton and actualy the whole component is heavily broken if compiling under wxWidgets.
Style.cxx does not compile, if PLAT_WX is defined and if I comment the line then the component only shows white on white. The text can be copied/pasted, but you see nothing. :-(

Identifier: 1d1c06df8a2f
Date: 2011-05-21 19:37 +1000

Discussion

1 2 > >> (Page 1 of 2)
  • Neil Hodgson
    Neil Hodgson
    2011-05-23

    wxStyledTextCtrl is the wxWidgets port of Scintilla and is maintained by the wxWidgets team, not by us.

     
  • Neil Hodgson
    Neil Hodgson
    2011-05-23

    • assigned_to: nobody --> nyamatongwe
    • priority: 5 --> 2
    • status: open --> open-wont-fix
     
  • Morten MacFly
    Morten MacFly
    2011-05-23

    I am not using wxSTC at all. I have my own (wxScintilla based) solution.

    However, please notice where it fails - it's in the scintilla component, not the wrapper. If you define PLAT_WX to true (which is the case when you are embedding the "raw" scintilla component in any wx application) the compilation fails in Style.cxx here:

    void Style::Copy(Font &font_, const FontMeasurements &fm_) {
    font.MakeAlias(font_);
    (FontMeasurements &)(*this) = fm_;
    #if PLAT_WX
    ascent = surface.Ascent(font);
    #endif
    }
    ...as "surface" is not known to the class and neither a parameter.

    As I believe this is a compilation failure in the scintilla component, my report went here and not to the wx guys.

    Correct me if I am wrong though...

     
  • Neil Hodgson
    Neil Hodgson
    2011-05-23

    An optimization was introduced so that each style would not need its own platform font object but would instead alias a shared platform font object for each unique combination of font name, size and attributes.

    Unlike other platforms, wxWidgets stores the font ascent in the font object and does not calculate it as needed but only when Ascent is called. Thus each alias needs to call Ascent or drawing won't work. The failing code is a remnant of an attempt to do that.

     
  • Neil Hodgson
    Neil Hodgson
    2011-05-25

    That code is now removed. Because of the optimisation, wxWidgets will not work unless it is change to update the ascent in the font object as needed.

     
  • Morten MacFly
    Morten MacFly
    2011-05-26

    Hmmm. Not a very nice solution as it breaks not only wxSTC but also all other wx apps using this component, like Code::Blocks , CodeLite and so on. In addition I'm afraid the wx guys will likely not change a core (wxFont) object due to a change in a 3rd party library... However, I'll raise a bug report there and we will see...

    So hopefully the optimisation you are referring to is worth it. I'll stick with the old version for now as this just works. Thanks for your time! :-)

     
  • Neil Hodgson
    Neil Hodgson
    2011-05-26

    This is not wxFont as that probably works. This is the Font class defined in Scintilla's Platform.h. Uniquely amongst platforms, wxSTC adds an 'ascent' member which it then only fills in when its Ascent method is called. If text is drawn without calling Ascent first then ascent remains 0 and the text is drawn in an unexpected location.

    Scintilla is often used with only a single font (but differing colours) for all styles. This may be 128 or 256 (or more) styles so Scintilla called Ascent (and Descent and AverageCharWidth, ...) for every one of those styles even though it already had these values from the first style. The optimisation allows Scintilla to call these methods just once in this case.

     
  • Marko Njezic
    Marko Njezic
    2011-06-03

    I don't use wxWidgets so I don't know if this would work or not, but instead of removing attempted workaround code, maybe it could be made to work by passing surface as parameter.

    I created a patch that does this: http://pastebin.com/cnHMrAPt

    Morten, you can try it to see if this would work.

    --
    Marko Njezic

     
  • Morten MacFly
    Morten MacFly
    2011-06-04

    Thanks a lot for the patch, we had done it meanwhile in a similar way: Adding the methods "Get/SetAscent" to the Font class and using it accordingly.

    However, now we face a more serious error: Every time we open a scintilla based editor it leaks ~ 16 GDI handles. This leads to the app behaving strangely after some time (when the limit of 10.000 GDI handling on Windows has been reached). :-(

     
1 2 > >> (Page 1 of 2)