After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 779846 - Printers panel crashes in callback of details/options dialog
Printers panel crashes in callback of details/options dialog
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Printers
git master
Other Linux
: Normal normal
: ---
Assigned To: Felipe Borges
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-03-10 11:54 UTC by Marek Kašík
Modified: 2017-03-13 11:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
printers: Allow reseting of PpPrinterEntry children (3.33 KB, patch)
2017-03-10 15:11 UTC, Felipe Borges
rejected Details | Review
printers: Update printer entries individually (2.11 KB, patch)
2017-03-10 15:11 UTC, Felipe Borges
rejected Details | Review
printers: Make the dialogs independent of the PpPrinterEntry lifetime (7.11 KB, patch)
2017-03-13 08:20 UTC, Felipe Borges
committed Details | Review

Description Marek Kašík 2017-03-10 11:54:57 UTC
If there is a change which needs actualization of printers list during showing of Options or Details dialog, the panel crashes due to already released PpPrinterEntry which opened it.

To reproduce:
1) open a details dialog of a printer
2) run cupsdisable a-printer-name
3) run cupsenable a-printer-name
4) close the dialog

The same happens when you add or remove a printer during the showing of the dialog.
Comment 1 Felipe Borges 2017-03-10 15:11:36 UTC
Created attachment 347652 [details] [review]
printers: Allow reseting of PpPrinterEntry children

By introducing pp_printer_entry_setup () we allow PpPrinterEntry
to be reset multiple times, allowing us to apply printer changes
without having to destroy the PpPrinterEntry widgets.
Comment 2 Felipe Borges 2017-03-10 15:11:43 UTC
Created attachment 347653 [details] [review]
printers: Update printer entries individually

Instead of actualizing the whole printers list on cups' PrinterAdded,
PrinterDeleted event, reset the changed PrinterEntry individually.
Comment 3 Felipe Borges 2017-03-10 15:15:31 UTC
I consider this to be a corner case, assuming it is not expected that a driver would touch the car engine while driving. :-)

The proposed solution covers this case, BUT I don't consider it to be optimal in terms of code legibility.

I would rather transform the PpPrinterEntry widgets which correspond to printer information to real GObject properties, so we could directly bind changes to a specific widget (for instance, changing ONLY a PpPrinterEntry->location_label when it changes).

This is definitely feasible but I would rather not do such big structural changes so close to the release/code freeze.
Comment 4 Marek Kašík 2017-03-10 17:15:44 UTC
I still get the crash with the patches. I think that we should focus on making the dialogs (options dialog, details dialog and jobs dialog) immune against releasing of the underlying printer entry.

My proposal is to change callbacks of the dialogs once we are destroying the PpPrinterEntry. For this you will need 2 simple functions pp_jobs_dialog_set_callback() and pp_options_dialog_set_callback. For the details dialog it is enough to change it using g_signal_handlers_disconnect_by_data() and g_signal_connect().
The new callbacks would just free the structures given in user_data.
Comment 5 Felipe Borges 2017-03-13 08:20:28 UTC
Created attachment 347806 [details] [review]
printers: Make the dialogs independent of the PpPrinterEntry lifetime
Comment 6 Marek Kašík 2017-03-13 11:21:29 UTC
Review of attachment 347806 [details] [review]:

Thanks. Push it to master branch please.
Comment 7 Felipe Borges 2017-03-13 11:30:55 UTC
Attachment 347806 [details] pushed as 909eb2a - printers: Make the dialogs independent of the PpPrinterEntry lifetime
Comment 8 Felipe Borges 2017-03-13 11:33:02 UTC
(In reply to Marek Kašík from comment #6)
> Review of attachment 347806 [details] [review] [review]:
> 
> Thanks. Push it to master branch please.

Should we chery-pick it to gnome-3-24 as well?
Comment 9 Marek Kašík 2017-03-13 11:36:59 UTC
(In reply to Felipe Borges from comment #8)
> (In reply to Marek Kašík from comment #6)
> > Review of attachment 347806 [details] [review] [review] [review]:
> > 
> > Thanks. Push it to master branch please.
> 
> Should we chery-pick it to gnome-3-24 as well?

Yes please, I didn't know that there is already gnome-3-24.
Comment 10 Felipe Borges 2017-03-13 11:49:06 UTC
Attachment 347806 [details] pushed as 58270a2 (gnome-3-24) - printers: Make the dialogs independent of the PpPrinterEntry lifetime