Re: Please help (core dump)

2020-07-26 Thread aitor

Hi Carlo,

On 25/7/20 15:35, Carlo Wood wrote:

Hi Aitor,

is this gtkmm3? For example, Gtk::VBox is deprecated,
I'm using Gtk::Grid.



Yes, it is. Have a look at the "pkg_check_modules" in the configuration 
of CMake. I'm using the deprecated VBox because this
code is taken froma network manager project, which i'd like to be 
compatible with goth gtkmm-2.24 and gtkmm-3.24.




Currently my application just core dumps:(.
The backtrace is:

Thread 1 "tstcpp" received signal SIGSEGV, Segmentation fault.
0x76bc29c6 in g_action_map_add_action () from /usr/lib/libgio-2.0.so.0
(gdb) bt
#0  0x76bc29c6 in g_action_map_add_action () at /usr/lib/libgio-2.0.so.0
#1  0x778cc541 in Gio::ActionMap::add_action(Glib::ustring const&) () 
at /usr/lib/libgiomm-2.4.so.1
#2  0x778cc65e in Gio::ActionMap::add_action(Glib::ustring const&, 
sigc::slot const&) ()
 at /usr/lib/libgiomm-2.4.so.1
#3  0x55573871 in LinuxChessboardWidget::LinuxChessboardWidget(Gtk::Window*, 
Glib::RefPtr) (this=
 0x563bd928, drawable=0x563bd8a0, promotion=..., __in_chrg=, __vtt_parm=)
 at 
/home/carlo/projects/cwchessboard/cwchessboard/LinuxChessboardWidget.cxx:164
#4  0x5557b68b in LinuxChessWindow::LinuxChessWindow() (this=0x563bd8a0, 
__in_chrg=, __vtt_parm=)
 at /home/carlo/projects/cwchessboard/cwchessboard/LinuxChessWindow.cxx:4
#5  0x5556e473 in LinuxChessApplication::create_window() 
(this=0x555f6230) at 
/home/carlo/projects/cwchessboard/cwchessboard/LinuxChessApplication.cxx:160
#6  0x5556e3ed in LinuxChessApplication::on_activate() 
(this=0x555f6230) at 
/home/carlo/projects/cwchessboard/cwchessboard/LinuxChessApplication.cxx:155
#7  0x778bbc2c in 
Gio::Application_Class::activate_callback(_GApplication*) () at 
/usr/lib/libgiomm-2.4.so.1
#8  0x7694480a in g_signal_emit_valist () at 
/usr/lib/libgobject-2.0.so.0
#9  0x76944980 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#10 0x76bbea89 in  () at /usr/lib/libgio-2.0.so.0
#11 0x778bba8a in Gio::Application::local_command_line_vfunc(char**&, 
int&) () at /usr/lib/libgiomm-2.4.so.1
#12 0x778bbe51 in 
Gio::Application_Class::local_command_line_vfunc_callback(_GApplication*, 
char***, int*) () at /usr/lib/libgiomm-2.4.so.1
#13 0x76bbec0a in g_application_run () at /usr/lib/libgio-2.0.so.0
#14 0x5557a928 in main(int, char**) (argc=1, argv=0x7fffd448) at 
/home/carlo/projects/cwchessboard/cwchessboard/LinuxChess.cxx:14

Frame #3 (the first that is my code) is:

#3  0x55573871 in LinuxChessboardWidget::LinuxChessboardWidget(this=0x563bd928, 
drawable=0x563bd8a0, promotion=...,__in_chrg=, 
__vtt_parm=)
 at 
/home/carlo/projects/cwchessboard/cwchessboard/LinuxChessboardWidget.cxx:164
164   add_action("ModeShowCandidates", sigc::mem_fun(*this, 
::on_menu_mode_showcandidates));


Why would this core dump??

LinuxChessboardWidget is defined as:

class LinuxChessboardWidget : public cwmm::ChessPositionWidget, public 
Gio::ActionMap
{
   ...

I have to derive from Gio::ActionMap because its constructor is protected.
The call to `add_action` above is to that class.

Can someone tell me what I'm doing wrong?



Mmm..., i don't know, but this issue might be related with some missing 
arguments in your defined signal/slot.


BTW, i uploaded my third examples including an icon factory for the 
customized icons of the second part of the menu bar:


https://www.gnuinos.org/Gtkmm Examples/Example_3/screenshot.png 



Cheers,

Aitor.


___
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list


Re: Please help (core dump)

2020-07-26 Thread Kjell Ahlstedt via gtkmm-list

On 2020-07-25 17:35, Carlo Wood wrote:

Why would this core dump??

LinuxChessboardWidget is defined as:

class LinuxChessboardWidget : public cwmm::ChessPositionWidget, public 
Gio::ActionMap
{
   ...

I have to derive from Gio::ActionMap because its constructor is protected.
The call to `add_action` above is to that class.

Can someone tell me what I'm doing wrong?

Carlo

Gio::ActionMap is an interface. That's why its constructor is protected. 
An interface can't be instantiated by itself. It must be implemented by 
a class which can be instantiated. If you really must implement 
Gio::ActionMap in your class (which I doubt), there is one or (probably) 
two errors.


First, interfaces must come before the widget class in the list of base 
classes.


class LinuxChessboardWidget : public Gio::ActionMap, public 
cwmm::ChessPositionWidget

This is opposite to what's done in gtkmm's classes that wrap gtk classes.

Second, your constructor must call a special Glib::ObjectBase constructor that 
registers your class with its own GType in glib's GType system. For instance

LinuxChessboardWidget(..) : Glib::ObjectBase("myWidgetClass") . // Or 
whatever you want to call it.

This is an unusual way of using Gio::ActionMap. I don't know if these are the 
only necessary changes. Much more common is to use one of the classes that 
already implement Gio::ActionMap: Gio::SimpleActionGroup, Gtk::Application (via 
Gio::Application) or Gtk::ApplicationWindow.

___
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list


Re: Please help (core dump)

2020-07-26 Thread Daniel Boles via gtkmm-list
On Sun, 26 Jul 2020, 20:21 Carlo Wood,  wrote:

>
> I'm not sure what you mean with doing
>
> LinuxChessboardWidget(..) : Glib::ObjectBase("myWidgetClass")
>
> since Glib::ObjectBase is a base class of Gio::ActionMap,
> I can't call that from LinuxChessboardWidget no?
>

yes, you can: research "virtual base classes"
___
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list


Re: Please help (core dump)

2020-07-26 Thread Carlo Wood
Hi Kjell,

thank you so much for helping me out!

I'm not sure what you mean with doing

LinuxChessboardWidget(..) : Glib::ObjectBase("myWidgetClass")

since Glib::ObjectBase is a base class of Gio::ActionMap,
I can't call that from LinuxChessboardWidget no?

What I have is the following:

class LinuxChessApplication : public Gtk::Application
{
...
  void on_menu_file_exit();

Where 'Exit' is not related to a single window, but is application
wide (it closes all windows and exits the application).
I add this with add_action to Gtk::Application.

Then I have:

class LinuxChessWindow : public Gtk::ApplicationWindow
{
...
  void on_menu_file_load();
  void on_menu_file_save();
  void on_menu_game_new();
  void on_menu_game_clear();
  void on_menu_game_export();
  void on_menu_game_undo();
  void on_menu_game_flip();
  void on_menu_mode_editposition();
  void on_menu_mode_editgame();

These are added, using add_action, to Gtk::ApplicationWindow.

So, I am using what you said. But, then I have:

class LinuxChessboardWidget : public cwmm::ChessPositionWidget
{
...
  void on_menu_mode_showcandidates();
  void on_menu_mode_showreachables();
  void on_menu_mode_showattacked();
  void on_menu_mode_showdefendables();
  void on_menu_mode_showdefended_black();
  void on_menu_mode_showdefended_white();
  void on_menu_mode_showmoves();
  void on_menu_mode_placepieces();

It is possible, though silly imho, to add those member funtions to
LinuxChessWindow (all those would do is call the member functions of
its LinuxChessboardWidget). So, I rather register these directly.

I couldn't think of another way than to derive LinuxChessboardWidget
from Gio::ActionMap, like Gtk::Application and Gtk::ApplicationWindow.

Should I add a Gio::SimpleActionGroup to LinuxChessboardWidget instead
and add them to that? If I do that, then how can get this
Gio::SimpleActionGroup to be used for my menu? And under what name
would do I have to refer to them in the `ui_info` xml string that
I use for my Gtk::Builder? Or should I use a separate Gtk::Builder?

With 'name' I mean that the menu entries that are added to
Gtk::Application are refered to as "app.*" and those that are
added to Gtk::ApplicationWindow are refered to as "win.*".
I'd like it when the methods of LinuxChessboardWidget can be
refered to as -say- "chessboard.*".


On Sun, 26 Jul 2020 11:06:53 +0200
Kjell Ahlstedt  wrote:

> Gio::ActionMap is an interface. That's why its constructor is
> protected. An interface can't be instantiated by itself. It must be
> implemented by a class which can be instantiated. If you really must
> implement Gio::ActionMap in your class (which I doubt), there is one
> or (probably) two errors.
> 
> First, interfaces must come before the widget class in the list of
> base classes.
> 
> class LinuxChessboardWidget : public Gio::ActionMap, public
> cwmm::ChessPositionWidget
> 
> This is opposite to what's done in gtkmm's classes that wrap gtk
> classes.
> 
> Second, your constructor must call a special Glib::ObjectBase
> constructor that registers your class with its own GType in glib's
> GType system. For instance
> 
> LinuxChessboardWidget(..) : Glib::ObjectBase("myWidgetClass")
> . // Or whatever you want to call it.
> 
> This is an unusual way of using Gio::ActionMap. I don't know if these
> are the only necessary changes. Much more common is to use one of the
> classes that already implement Gio::ActionMap:
> Gio::SimpleActionGroup, Gtk::Application (via Gio::Application) or
> Gtk::ApplicationWindow.
> 

___
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list


Re: Please help

2020-07-26 Thread aitor

Hi again,

On 26/7/20 14:00, aitor_czr  wrote:

In the next examples i'll explain how to add an icon factory for your
custom stock icons and how to add the toolbar to

the project. They'll be uploaded to the following link:

https://www.gnuinos.org/Gtkmm%20Examples/

Hope this helps,


Finally, I added the toolbar with the custom icons:

https://www.gnuinos.org/Gtkmm%20Examples/Example_4/

Quote.- The SeparatorToolItem at the left of the last item is missing in 
Gtkmm3:


https://www.gnuinos.org/Gtkmm%20Examples/Example_4/screenshot.png

This separator only appears in Gtkmm-2.4 ...

Cheers,

Aitor.


___
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list