rgleason / watchdog_pi

watchdog plugin for opencpn
GNU General Public License v3.0
1 stars 10 forks source link

Watchdog v2.4.31.0 in some environments does not work "setfont" undefined error #19

Closed rgleason closed 3 years ago

rgleason commented 3 years ago

In Ubuntu 18.04 the Icon does not appear in toolbar when enabled The plugin appears to install properly. The log shows that the plugin is compatible. The plugin seems to install to the following locations in Ubuntu 18.04

Watchdog v 2.4.31.0 Installation into Ubuntu

  1. Home / .opencpn / plugins / cache / tarballs / watchdog_pi-[version]-ubuntu-x86_64_18.04-bionic.tar.gz
  2. Home / .local / lib / opencpn / libwatchdog_pi.so
  3. Home / .local / share / opencpn / plugins / watchdog_pi / data / Warnings dir and *.svg files
  4. Home / .local / share / locale/ various MO language files
  5. Home / .opencpn / plugins / watchdog / WatchdogConfiguration.xml

However the plugin is not available when "enable" is selected. The svg icons are available for use, but something is not working right also why isn't the _img file being used as backup?

I do not believe we changed any of the file locations for svg, but perhaps we did and the program is looking in the wrong place?

After removing all traces of watchdog, the plugin installs and works properly in Windows. Any suggestions?

jongough commented 3 years ago

I have just done an install on Ubuntu 20.1 running OCPN in portable mode and it works. The icon is different, a circular dot with a dog inside it, compared to the previous square with a dog.

jongough commented 3 years ago

I have now done and install on a native Ubuntu 18.04 virtual machine running in normal mode and there is an error in the opencpn.log

20:14:47.202 MESSAGE pluginmanager.cpp:2287 PlugInManager: Loading PlugIn: /home/jon/.local/lib/opencpn/libwatchdog_pi.so
20:14:47.214   ERROR dlunix.cpp:162 /home/jon/.local/lib/opencpn/libwatchdog_pi.so: undefined symbol: _ZN9wxControl7SetFontERK6wxFont
20:14:47.214 MESSAGE pluginmanager.cpp:2348    PlugInManager: Cannot load library: /home/jon/.local/lib/opencpn/libwatchdog_pi.so 

So it looks like there is a function, SetFont, something missing in the linked module.

Just tried it on Ubuntu 20.04 and it works OK.

rgleason commented 3 years ago

Thank you Jon. I expect it affects some earlier Ubuntu too.. I wonder if the plugin is using a deprecated function for fonts. Search in files by Notepad++

Search "setfont" (8 hits in 3 files of 12 searched)
  C:\Users\Rick\Documents\GitHub\watchdog_pi\src\ConfigurationDialog.cpp (3 hits)
    Line 49:     m_font->SetFont(font);
    Line 50:     m_watchdog_pi.m_WatchdogDialog->m_lStatus->SetFont(font);
    Line 74:     m_watchdog_pi.m_WatchdogDialog->m_lStatus->SetFont(font);
  C:\Users\Rick\Documents\GitHub\watchdog_pi\src\WatchdogUI.cpp (2 hits)
    Line 24:    m_lStatus->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("Sans") ) );
    Line 277:   this->SetFont( wxFont( 14, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("Sans") ) );
  C:\Users\Rick\Documents\GitHub\watchdog_pi\src\wddc.cpp (3 hits)
    Line 159: void wdDC::SetFont( const wxFont& font )
    Line 161:     if( dc ) dc->SetFont( font );
    Line 964:             temp_dc.SetFont( m_font );
rgleason commented 3 years ago

Note: I moved all header files into a separate directory. Maybe there needs to be a flag or something to the setfont definition?

For example, ConfigurationDialog.cpp has

#include "watchdog_pi.h"
#include "WatchdogDialog.h"
#include "ConfigurationDialog.h"
#include "NewAlarmDialog.h"
#include "EditAlarmDialog.h"

Should it have #include WatchdogUI.cpp because of lines 24 and 277? Later: I mean #include WatchdogUI.h

Later yet: This is what I tried and it didn't fix anything.

rgleason commented 3 years ago

Maybe we need

include <wx/font.h>

at the head of some of these files?

LATER: I see watchdogUI.h already has this.

rgleason commented 3 years ago
Search "wxFont" (22 hits in 3 files of 12 searched)
  C:\Users\Rick\Documents\GitHub\watchdog_pi\src\ConfigurationDialog.cpp (7 hits)
    Line 48:     wxFont font(pConf->Read ( _T ( "Font" ), wxFont(14, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL).GetNativeFontInfoDesc()));
               Multiple times
    Line 71: void ConfigurationDialog::OnFont( wxFontPickerEvent& event )
    Line 73:     wxFont font = event.GetFont();
  C:\Users\Rick\Documents\GitHub\watchdog_pi\src\WatchdogUI.cpp (11 hits)
    Line 24:    m_lStatus->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("Sans") ) );
                Multiple times
    Line 234:   m_font = new wxFontPickerCtrl( this, wxID_ANY, wxNullFont, wxDefaultPosition, wxDefaultSize, wxFNTP_DEFAULT_STYLE );
    Line 260:   m_font->Connect( wxEVT_COMMAND_FONTPICKER_CHANGED, wxFontPickerEventHandler( ConfigurationDialogBase::OnFont ), NULL, this );
    Line 270:   m_font->Disconnect( wxEVT_COMMAND_FONTPICKER_CHANGED, wxFontPickerEventHandler( ConfigurationDialogBase::OnFont ), NULL, this );
    Line 277:   this->SetFont( wxFont( 14, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("Sans") ) );
                Multiple times
  C:\Users\Rick\Documents\GitHub\watchdog_pi\src\wddc.cpp (4 hits)
    Line 159: void wdDC::SetFont( const wxFont& font )
    Line 178: const wxFont& wdDC::GetFont() const
    Line 1002:         wxCoord *externalLeading, wxFont *font ) const
    Line 1010:         wxFont f = m_font;
rgleason commented 3 years ago

Watchdog-Flatpak-opencpn.log In flatpak opencpn.log

21:08:08.236 MESSAGE OCPNPlatform.cpp:1026 Using flatpak locales at /home/rgleason/.var/app/org.opencpn.OpenCPN/data/locale
21:08:08.274 MESSAGE OCPNPlatform.cpp:1068 ChangeLocale: Locale Init OK for:  
21:08:08.274 MESSAGE OCPNPlatform.cpp:1081 Loading catalog for:  opencpn-watchdog_pi
21:08:08.293 MESSAGE OCPNPlatform.cpp:1087 Loading catalog for opencpn core.
21:08:08.314 MESSAGE OCPNPlatform.cpp:931 Getting DefaultSystemLocale...
21:08:19.428 MESSAGE pluginmanager.cpp:1487 PlugInManager: Initializing PlugIn: /home/rgleason/.var/app/org.opencpn.OpenCPN/lib/opencpn/libwatchdog_pi.so
21:08:19.440 MESSAGE Alarm.cpp:742 Watchdog: invalid Wind type: Wind
21:08:22.648 MESSAGE chcanv.cpp:2350 Metrics:  m_display_size_mm: 508     g_Platform->getDisplaySize():  1920:985   
21:08:22.648 MESSAGE chcanv.cpp:2355 wxDisplaySize(): 1920 985
21:08:22.764 MESSAGE glChartCanvas.cpp:693 BuildFBO 3
21:08:22.777 MESSAGE glChartCanvas.cpp:1177 OpenGL Framebuffer OK, size = 1295
21:08:22.809 MESSAGE glChartCanvas.cpp:693 BuildFBO 3
21:08:22.820 MESSAGE glChartCanvas.cpp:1177 OpenGL Framebuffer OK, size = 1295
21:08:22.829 MESSAGE glChartCanvas.cpp:693 BuildFBO 3
21:08:22.840 MESSAGE glChartCanvas.cpp:1177 OpenGL Framebuffer OK, size = 1295
21:08:22.873 MESSAGE glChartCanvas.cpp:693 BuildFBO 3
21:08:22.875 MESSAGE glChartCanvas.cpp:1177 OpenGL Framebuffer OK, size = 1295
21:08:23.443 WARNING SndfileSoundLoader.cpp:36 Cannot open file /usr/local/share/opencpn/sounds/2bells.wav: System error : No such file or directory.
21:08:23.443 WARNING PortAudioSound.cpp:229 Cannot load sound file /usr/local/share/opencpn/sounds/2bells.wav
21:08:23.443 WARNING pluginmanager.cpp:8301 Cannot load sound file: /usr/local/share/opencpn/sounds/2bells.wav
21:08:33.512 MESSAGE pluginmanager.cpp:1703 PlugInManager: Deactivating PlugIn: /home/rgleason/.var/app/org.opencpn.OpenCPN/lib/opencpn/libwatchdog_pi.so
21:08:33.527 MESSAGE chart1.cpp:3880 opencpn::MyFrame exiting cleanly.
rgleason commented 3 years ago

watchdog-ubuntu1804-opencpn.log In ubuntu 18.04 using Options > Plugins > Import got "Incompatible plugin format detected." using a v2.4.31.1 tarball from circleci deployment.

Tried installing v2.4.31.0 again and it downloaded and installed but no icon again and it failed.

Getting the same error

13:51:19.596 MESSAGE pluginmanager.cpp:1174 Checking plugin candidate: /home/rgleason/.local/lib/opencpn/libwatchdog_pi.so
13:51:19.596 MESSAGE pluginmanager.cpp:2171 Plugin is compatible by elf library scan: true
13:51:19.596 MESSAGE pluginmanager.cpp:2288 PlugInManager: Loading PlugIn: /home/rgleason/.local/lib/opencpn/libwatchdog_pi.so
13:51:19.604   ERROR dlunix.cpp:162 /home/rgleason/.local/lib/opencpn/libwatchdog_pi.so: undefined symbol: _ZN9wxControl7SetFontERK6wxFont

Also

07:12:45.281 MESSAGE pluginmanager.cpp:1174 Checking plugin candidate: /home/rgleason/.local/lib/opencpn/libwatchdog_pi.so
07:12:45.281 MESSAGE pluginmanager.cpp:2171 Plugin is compatible by elf library scan: true
07:12:45.281 MESSAGE pluginmanager.cpp:2288 PlugInManager: Loading PlugIn: /home/rgleason/.local/lib/opencpn/libwatchdog_pi.so
07:12:45.292 MESSAGE pluginmanager.cpp:558 PlugInManager: Using data dirs from: /home/rgleason/.local/share/opencpn/plugins;/usr/share/ubuntu/opencpn/plugins;/home/rgleason/.local/share/flatpak/exports/share/opencpn/plugins;/var/lib/flatpak/exports/share/opencpn/plugins;/usr/local/share/opencpn/plugins;/usr/share/opencpn/plugins;/var/lib/snapd/desktop/opencpn/plugins;/usr/local/lib/opencpn
07:12:45.292 MESSAGE pluginmanager.cpp:571 PlugInManager: using data dir: /home/rgleason/.local/share/opencpn/plugins/watchdog_pi
07:12:45.292 MESSAGE icons.cpp:42 Loading toolbar icon: /home/rgleason/.local/share/opencpn/plugins/watchdog_pi/data/watchdog_pi.svg
07:12:45.292 MESSAGE icons.cpp:46 Loading toolbar icon: /home/rgleason/.local/share/opencpn/plugins/watchdog_pi/data/watchdog_pi_toggled.svg
07:12:45.292    INFO pluginmanager.cpp:2457 PlugInManager:  /home/rgleason/.local/lib/opencpn/libwatchdog_pi.so
07:12:45.292    INFO pluginmanager.cpp:2458         Plugin common name: Watchdog
07:12:45.292    INFO pluginmanager.cpp:2460         API Version detected: 116
07:12:45.292    INFO pluginmanager.cpp:2461         PlugIn Version detected: 2.4
07:12:45.345 MESSAGE Alarm.cpp:742 Watchdog: invalid Wind type: Wind
07:12:45.414 MESSAGE pluginmanager.cpp:1269 PlugInManager: Watchdog has loaded very slowly: 121 ms
rgleason commented 3 years ago

My stab in the dark idea to fix this did not work. It is pretty clear that the flatpak version does not find sound files and this dependency needs to be added for flatpak. It is also clear that there is some setfont problem.

However I am not going to be able to fix these issues, so I am afraid someone else will need to do it.

rgleason commented 3 years ago

See this PR from Jon fixes it.

https://github.com/rgleason/watchdog_pi/pull/22