Skip to content

Comments

Fix various bugs and errors#13

Merged
buggins merged 3 commits intobuggins:masterfrom
EXL:upstream_patches
May 4, 2018
Merged

Fix various bugs and errors#13
buggins merged 3 commits intobuggins:masterfrom
EXL:upstream_patches

Conversation

@EXL
Copy link
Contributor

@EXL EXL commented May 3, 2018

  1. Fix bug with wrong value in the "Page Skin" combo box ("Settings => Style" dialog).
    Steps to reproduce:
    1.1. Run new and clear instance of the Cool Reader, go to the "Settings => Style => Page Skin".
    1.2. It shows bg_paperX (instead of [NONE]).
    1.3. Choose second (after [NONE]) page skin, click "OK".
    1.4. Nothing will change.

  2. Fix compilation error on the new GCC versions:

/home/exl/Projects/GIT/coolreader/cr3qt/src/cr3widget.cpp: In constructor ‘CR3View::CR3View(QWidget*)’:
/home/exl/Projects/GIT/coolreader/cr3qt/src/cr3widget.cpp:325:47: error: cannot bind non-const lvalue reference of type ‘LVRefVec<LVImageSource>&’ to an rvalue of type ‘LVRefVec<LVImageSource>’
     _docview->setBatteryIcons( getBatteryIcons(0x000000) );
                                ~~~~~~~~~~~~~~~^~~~~~~~~~
In file included from /home/exl/Projects/GIT/coolreader/cr3qt/src/cr3widget.cpp:1:0:
/home/exl/Projects/GIT/coolreader/tinydict/../crengine/include/lvdocview.h:608:10: note:   initializing argument 1 of ‘void LVDocView::setBatteryIcons(LVRefVec<LVImageSource>&)’
     void setBatteryIcons( LVRefVec<LVImageSource> & icons );
          ^~~~~~~~~~~~~~~
  1. Fix Segmentation fault in the Release build:
$ gdb ./cr3 
GNU gdb (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./cr3...(no debugging symbols found)...done.
(gdb) r
Starting program: /home/exl/Projects/GIT/coolreader/qtbuild/cr3qt/cr3 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
2018/05/03 11:32:41.5931 WARN Changing log level from 3 to 1
642 fonts loaded.
2018/05/03 11:32:41.8991 ERROR Canot load translation file cr3_en_US from dir /usr/share/cr3/i18n/
2018/05/03 11:32:41.9328 ERROR Loading settings from file /home/exl/.cr3/cr3.ini

Program received signal SIGSEGV, Segmentation fault.
0x000055555567bc28 in LVStyleSheet::apply(ldomNode const*, css_style_rec_tag*) ()
(gdb) bt full
#0  0x000055555567bc28 in LVStyleSheet::apply(ldomNode const*, css_style_rec_tag*) ()
#1  0x00005555556d2d23 in setNodeStyle(ldomNode*, LVFastRef<css_style_rec_tag>, LVProtectedFastRef<LVFont>) ()
#2  0x0000555555640954 in ldomNode::initNodeStyle() ()
#3  0x0000555555640e50 in updateStyleDataRecursive(ldomNode*) ()
#4  0x0000555555640ef0 in updateStyleDataRecursive(ldomNode*) ()
#5  0x0000555555640ef0 in updateStyleDataRecursive(ldomNode*) ()
#6  0x0000555555640ef0 in updateStyleDataRecursive(ldomNode*) ()
#7  0x0000555555646771 in ldomDocument::render(LVRendPageList*, LVDocViewCallback*, int, int, bool, int, LVProtectedFastRef<LVFont>, int, LVFastRef<CRPropAccessor>) ()
#8  0x00005555556ae862 in LVDocView::Render(int, int, LVRendPageList*) ()
#9  0x00005555556aea50 in LVDocView::checkRender() ()
#10 0x00005555556b2fa6 in LVDocView::updateBookMarksRanges() ()
#11 0x00005555556c7815 in LVDocView::propsApply(LVFastRef<CRPropAccessor>) ()
#12 0x00005555555ce64e in CR3View::loadSettings(QString) ()
#13 0x00005555555da585 in MainWindow::MainWindow(QWidget*) ()
#14 0x00005555555b928c in main ()

EXL added 3 commits May 3, 2018 10:34
Ignore CMakeLists.txt.user file
Backtrace:
    LVStyleSheet::apply(ldomNode const *, css_style_rec_tag *)                                                                                     0x55555567bc28
    setNodeStyle(ldomNode *, LVFastRef<css_style_rec_tag>, LVProtectedFastRef<LVFont>)                                                             0x5555556d2d23
    ldomNode::initNodeStyle()                                                                                                                      0x555555640954
    updateStyleDataRecursive(ldomNode *)                                                                                                           0x555555640e50
    updateStyleDataRecursive(ldomNode *)                                                                                                           0x555555640ef0
    updateStyleDataRecursive(ldomNode *)                                                                                                           0x555555640ef0
    updateStyleDataRecursive(ldomNode *)                                                                                                           0x555555640ef0
    ldomDocument::render(LVRendPageList *, LVDocViewCallback *, int, int, bool, int, LVProtectedFastRef<LVFont>, int, LVFastRef<CRPropAccessor>)   0x555555646771
    LVDocView::Render(int, int, LVRendPageList *)                                                                                                  0x5555556ae862
    LVDocView::checkRender()                                                                                                                       0x5555556aea50
    LVDocView::updateBookMarksRanges()                                                                                                             0x5555556b2fa6
    LVDocView::propsApply(LVFastRef<CRPropAccessor>)                                                                                               0x5555556c7815
    CR3View::loadSettings(QString)                                                                                                                 0x5555555ce64e
    MainWindow::MainWindow(QWidget *)                                                                                                              0x5555555da585
    main                                                                                                                                           0x5555555b928c
@Frenzie
Copy link

Frenzie commented May 3, 2018

Also see koreader/crengine#90 (comment)

Just my 2 cents on it. @poire-z You shouldn't compare this with NULL/nullptr. It's invalid C++ with undefined behavior. It means it might work with one compiler version but won't with another compiler/version (can be optimized out as noop).
So all null reference checks should be done on instance and not inside instance method.

You can read more about this in the following discussion:
https://www.reddit.com/r/cpp_questions/comments/3roy3e/this_nullptr_can_this_ever_be_true/

[…]

if (!node) Yeah. It's a C style which still works. But it's not very welcome now in cpp. It's better to distinguish null checks from bool checks and use: if(node == NULL)
Though it doesn't really matter at least for now.

@buggins buggins merged commit 4f4aae6 into buggins:master May 4, 2018
@EXL EXL deleted the upstream_patches branch May 4, 2018 23:04
@EXL EXL mentioned this pull request May 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants