Menu

#1959 Directly emit signals from Qt's WatcherHelper class (w/ patch)

Bug
closed-fixed
5
2017-08-16
2017-07-14
No

Currently there's an extra layer of calls into the ScintillaDocument to emit its own signal. This patch has the WatcherHelper directly emit the owner's signal.

1 Attachments

Discussion

  • Neil Hodgson

    Neil Hodgson - 2017-07-18
    • labels: --> scintilla, qt
    • status: open --> open-fixed
    • assigned_to: Neil Hodgson
     
  • Neil Hodgson

    Neil Hodgson - 2017-07-18

    Committed as [f8c75a].
    Reindented with astyle as it was a little inconsistent.

     

    Related

    Commit: [f8c75a]

  • Neil Hodgson

    Neil Hodgson - 2017-07-21

    There are compilation failures on Fedora 26, GCC 7.1, Qt 5.7.1 with this change.

    ScintillaDocument.cpp: In member function virtual void WatcherHelper::NotifyModifyAttempt(Document*, void*):
    ScintillaDocument.cpp:61:32: error: void ScintillaDocument::modify_attempt() is protected within this context
         emit owner->modify_attempt();
                                    ^
    In file included from ScintillaDocument.cpp:10:0:
    ScintillaDocument.h:84:10: note: declared protected here
         void modify_attempt();
              ^~~~~~~~~~~~~~
    ScintillaDocument.cpp: In member function virtual void WatcherHelper::NotifySavePoint(Document*, void*, bool):
    ScintillaDocument.cpp:65:39: error: void ScintillaDocument::save_point(bool) is protected within this context
         emit owner->save_point(atSavePoint);
                                           ^
    In file included from ScintillaDocument.cpp:10:0:
    ScintillaDocument.h:85:10: note: declared protected here
         void save_point(bool atSavePoint);
              ^~~~~~~~~~
    ScintillaDocument.cpp: In member function virtual void WatcherHelper::NotifyModified(Document*, DocModification, void*):
    ScintillaDocument.cpp:74:83: error: void ScintillaDocument::modified(int, int, const QByteArray&, int, int, int, int, int) is protected within this context
                              mh.linesAdded, mh.line, mh.foldLevelNow, mh.foldLevelPrev);
                                                                                       ^
    In file included from ScintillaDocument.cpp:10:0:
    ScintillaDocument.h:86:10: note: declared protected here
         void modified(int position, int modification_type, const QByteArray &text, int length,
              ^~~~~~~~
    ScintillaDocument.cpp: In member function virtual void WatcherHelper::NotifyStyleNeeded(Document*, void*, Sci::Position):
    ScintillaDocument.cpp:81:36: error: void ScintillaDocument::style_needed(int) is protected within this context
         emit owner->style_needed(endPos);
                                        ^
    In file included from ScintillaDocument.cpp:10:0:
    ScintillaDocument.h:88:10: note: declared protected here
         void style_needed(int pos);
              ^~~~~~~~~~~~
    ScintillaDocument.cpp: In member function virtual void WatcherHelper::NotifyLexerChanged(Document*, void*):
    ScintillaDocument.cpp:85:31: error: void ScintillaDocument::lexer_changed() is protected within this context
         emit owner->lexer_changed();
                                   ^
    In file included from ScintillaDocument.cpp:10:0:
    ScintillaDocument.h:89:10: note: declared protected here
         void lexer_changed();
              ^~~~~~~~~~~~~
    ScintillaDocument.cpp: In member function virtual void WatcherHelper::NotifyErrorOccurred(Document*, void*, int):
    ScintillaDocument.cpp:89:38: error: void ScintillaDocument::error_occurred(int) is protected within this context
         emit owner->error_occurred(status);
                                          ^
    In file included from ScintillaDocument.cpp:10:0:
    ScintillaDocument.h:90:10: note: declared protected here
         void error_occurred(int status);
              ^~~~~~~~~~~~~~
    make: *** [Makefile:561: ScintillaDocument.o] Error 1
    
     
  • Neil Hodgson

    Neil Hodgson - 2017-07-21
    • status: open-fixed --> open
     
  • Justin Dailey

    Justin Dailey - 2017-07-21

    I'm no Qt expert :) but I did some digging in the documentation and in Qt4 it seems signals are protected, in Qt5+ signals are public. Not sure why this is showing up in Qt5.7.1 however and do not have any way of testing it currently.

    The documentation for Qt5 states:

    Signals are public access functions and can be emitted from anywhere, but we recommend to only emit them from the class that defines the signal and its subclasses.

    Some possible solutions:

    1. Err on the side of caution by adhearing to the documentation and revert the commit.
    2. Adding the friend class ::WatcherHelper; line back into ScintillaDocument should solve the compilation failures.
    3. Have the ScintillaDocument inherit and implement the DocWatcher interface itself instead of having a separate WatcherHelper class.
     
  • Neil Hodgson

    Neil Hodgson - 2017-07-23
    • status: open --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2017-07-23

    The problem was that Fedora 26 has both qmake-qt5 and qmake-qt4. qmake-qt5 should be used for correct building of ScintillaEdit when it is available. However, PySide needs Qt 4. Went with (2) friend class ::WatcherHelper;

    Changes in [fce43d] and [3d780a].

     

    Related

    Commit: [3d780a]
    Commit: [fce43d]

  • Neil Hodgson

    Neil Hodgson - 2017-08-16
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB