Fixing badly sent parent pid.
This commit is contained in:
parent
cd46914add
commit
1dcfe0788e
|
@ -97,12 +97,12 @@ has _last_script_run_device => ( is => 'rw', );
|
||||||
has _last_script_run_verbose => ( is => 'rw', );
|
has _last_script_run_verbose => ( is => 'rw', );
|
||||||
has _safe_to_exit => ( is => 'rw', default => sub { 1 } );
|
has _safe_to_exit => ( is => 'rw', default => sub { 1 } );
|
||||||
|
|
||||||
has _save_path => ( is => 'rw' );
|
has _save_path => ( is => 'rw' );
|
||||||
has _want_to_close => ( is => 'rw' );
|
has _want_to_close => ( is => 'rw' );
|
||||||
has _last_save_pid => ( is => 'rw' );
|
has _last_save_pid => ( is => 'rw' );
|
||||||
has _last_save_dest_file => ( is => 'rw' );
|
has _last_save_dest_file => ( is => 'rw' );
|
||||||
has _can_open_printer_configure => ( is => 'rw', default => sub { 1 } );
|
has _can_open_printer_configure => ( is => 'rw', default => sub { 1 } );
|
||||||
has parent_pid => ( is => 'rw' );
|
has parent_pid => ( is => 'rw' );
|
||||||
|
|
||||||
sub _tempdir_previews($self) {
|
sub _tempdir_previews($self) {
|
||||||
if ( !defined $self->_tempdir_previews_guts ) {
|
if ( !defined $self->_tempdir_previews_guts ) {
|
||||||
|
@ -122,7 +122,8 @@ sub _tempdir_previews($self) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub start($self, $exd_file = undef) {
|
sub start( $self, $exd_file = undef ) {
|
||||||
|
$self->_daemon_script_runner;
|
||||||
my $app = Gtk4::Application->new( 'me.sergiotarxz.Exd', 'default-flags' );
|
my $app = Gtk4::Application->new( 'me.sergiotarxz.Exd', 'default-flags' );
|
||||||
$self->_app($app);
|
$self->_app($app);
|
||||||
$app->signal_connect(
|
$app->signal_connect(
|
||||||
|
@ -236,13 +237,12 @@ sub _open_action($self) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _open_file($self, $file) {
|
sub _open_file( $self, $file ) {
|
||||||
$self->_save_path($file);
|
$self->_save_path($file);
|
||||||
my $window = $self->window;
|
my $window = $self->window;
|
||||||
$window->set_title( "Exd (Thermal Printer) "
|
$window->set_title(
|
||||||
. path( $self->_save_path )->basename );
|
"Exd (Thermal Printer) " . path( $self->_save_path )->basename );
|
||||||
$self->_file_format(
|
$self->_file_format( Exd::FileFormat->from_zip_file($file) );
|
||||||
Exd::FileFormat->from_zip_file($file) );
|
|
||||||
$self->_update_editor_buffer;
|
$self->_update_editor_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,9 +333,9 @@ sub _daemon_script_runner($self) {
|
||||||
close $read_from_script;
|
close $read_from_script;
|
||||||
close $write_to_script;
|
close $write_to_script;
|
||||||
while (1) {
|
while (1) {
|
||||||
my $fh = $self->_read_from_parent;
|
my $fh = $self->_read_from_parent;
|
||||||
my $line = <$fh>;
|
my $line = <$fh>;
|
||||||
if (!kill 0, $self->parent_pid) {
|
if ( defined $self->parent_pid && !kill 0, $self->parent_pid ) {
|
||||||
say 'Parent died at main fork loop, exiting...';
|
say 'Parent died at main fork loop, exiting...';
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
@ -348,6 +348,11 @@ sub _daemon_script_runner($self) {
|
||||||
$self->_on_save_packet( $packet->{data} );
|
$self->_on_save_packet( $packet->{data} );
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
if ( $packet->{type} eq 'parent-pid' ) {
|
||||||
|
$self->parent_pid($packet->{data});
|
||||||
|
say 'Got parent pid ' . $self->parent_pid;
|
||||||
|
next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -472,7 +477,7 @@ sub _monitor_run($self) {
|
||||||
my $data = $packet->{data};
|
my $data = $packet->{data};
|
||||||
$data =~ s/\s+$//;
|
$data =~ s/\s+$//;
|
||||||
$data =~ s/^\s+//;
|
$data =~ s/^\s+//;
|
||||||
if ($data =~ /^\s*$/) {
|
if ( $data =~ /^\s*$/ ) {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
$data .= "\n";
|
$data .= "\n";
|
||||||
|
@ -635,7 +640,7 @@ sub _open_gallery($self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _log( $self, $message ) {
|
sub _log( $self, $message ) {
|
||||||
if ($message =~ /Fontconfig error: No writable cache directories/) {
|
if ( $message =~ /Fontconfig error: No writable cache directories/ ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$self->_write_to_parent->say(
|
$self->_write_to_parent->say(
|
||||||
|
@ -750,14 +755,25 @@ sub _create_gallery_image( $self, $hash ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _open_fonts_gallery($self) {
|
sub _open_fonts_gallery($self) {
|
||||||
my $font_gallery = Exd::Gui::FontGallery->new(app => $self);
|
my $font_gallery = Exd::Gui::FontGallery->new( app => $self );
|
||||||
$font_gallery->start;
|
$font_gallery->start;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _activate($self, $exd_file = undef) {
|
sub _send_parent_pid($self) {
|
||||||
|
$self->_write_to_script->say(
|
||||||
|
JSON::to_json(
|
||||||
|
{
|
||||||
|
type => 'parent-pid',
|
||||||
|
data => $self->parent_pid,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub _activate( $self, $exd_file = undef ) {
|
||||||
say "My pid is $$.";
|
say "My pid is $$.";
|
||||||
$self->parent_pid($$);
|
$self->parent_pid($$);
|
||||||
$self->_daemon_script_runner;
|
$self->_send_parent_pid;
|
||||||
Glib::Timeout->add(
|
Glib::Timeout->add(
|
||||||
1000,
|
1000,
|
||||||
sub {
|
sub {
|
||||||
|
@ -785,7 +801,7 @@ sub _activate($self, $exd_file = undef) {
|
||||||
my $preview_button = Gtk4::Button->new_with_label('Preview');
|
my $preview_button = Gtk4::Button->new_with_label('Preview');
|
||||||
my $select_printer = Gtk4::Button->new_with_label('Select Printer');
|
my $select_printer = Gtk4::Button->new_with_label('Select Printer');
|
||||||
my $open_gallery = Gtk4::Button->new_with_label('Open image gallery');
|
my $open_gallery = Gtk4::Button->new_with_label('Open image gallery');
|
||||||
my $edit_fonts = Gtk4::Button->new_with_label('Open font gallery');
|
my $edit_fonts = Gtk4::Button->new_with_label('Open font gallery');
|
||||||
$open_gallery->signal_connect(
|
$open_gallery->signal_connect(
|
||||||
'clicked',
|
'clicked',
|
||||||
sub {
|
sub {
|
||||||
|
@ -800,11 +816,14 @@ sub _activate($self, $exd_file = undef) {
|
||||||
$select_printer->signal_connect(
|
$select_printer->signal_connect(
|
||||||
'clicked',
|
'clicked',
|
||||||
sub {
|
sub {
|
||||||
if ($self->_can_open_printer_configure) {
|
if ( $self->_can_open_printer_configure ) {
|
||||||
$self->_can_open_printer_configure(0);
|
$self->_can_open_printer_configure(0);
|
||||||
Exd::Gui::PrinterConfigure->new( app => $self, on_close => sub {
|
Exd::Gui::PrinterConfigure->new(
|
||||||
$self->_can_open_printer_configure(1);
|
app => $self,
|
||||||
})->start;
|
on_close => sub {
|
||||||
|
$self->_can_open_printer_configure(1);
|
||||||
|
}
|
||||||
|
)->start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -860,7 +879,7 @@ sub _activate($self, $exd_file = undef) {
|
||||||
$execute_log_window->set_child($execute_log);
|
$execute_log_window->set_child($execute_log);
|
||||||
$box_vertical->append($execute_log_window);
|
$box_vertical->append($execute_log_window);
|
||||||
$win->set_child($box_vertical);
|
$win->set_child($box_vertical);
|
||||||
if (defined $exd_file) {
|
if ( defined $exd_file ) {
|
||||||
$self->_open_file($exd_file);
|
$self->_open_file($exd_file);
|
||||||
}
|
}
|
||||||
$win->present;
|
$win->present;
|
||||||
|
|
Loading…
Reference in New Issue