From f5f7dc99319179dcce9e13b2b13cf7da7eb643ae Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 7 Feb 2014 17:45:00 +0000 Subject: [PATCH] Only allocate printing resources for the period of time we need them. --- amiga/gui.c | 16 ++++++---------- amiga/print.c | 7 +++++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/amiga/gui.c b/amiga/gui.c index b8fb0100b..9483fd4e3 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -699,7 +699,6 @@ void gui_init(int argc, char** argv) BPTR lock = 0; ami_open_resources(); /* alloc ports/asl reqs, open libraries/devices */ - ami_print_init(); ami_clipboard_init(); ami_openurl_open(); @@ -2562,13 +2561,12 @@ void ami_get_msg(void) ULONG signal; struct TimerRequest *timermsg = NULL; struct MsgPort *printmsgport = ami_print_get_msgport(); - ULONG printsig = 1L << printmsgport->mp_SigBit; - ULONG signalmask = winsignal | appsig | schedulesig | rxsig | printsig | applibsig | ctrlcsig; + ULONG printsig = 0; + if(printmsgport) printsig = 1L << printmsgport->mp_SigBit; + ULONG signalmask = winsignal | appsig | schedulesig | rxsig | printsig | applibsig | ctrlcsig; + + signal = Wait(signalmask); - signal = Wait(signalmask); -/* -printf("sig recvd %ld (%ld %ld %ld %ld %ld %ld)\n", signal, winsignal , appsig , schedulesig , rxsig , printsig , applibsig); -*/ if(signal & winsignal) ami_handle_msg(); @@ -2837,8 +2835,6 @@ static void gui_quit(void) LOG(("Freeing clipboard")); ami_clipboard_free(); - ami_print_free(); - FreeSysObject(ASOT_PORT,appport); FreeSysObject(ASOT_PORT,sport); @@ -2846,7 +2842,7 @@ static void gui_quit(void) ami_file_req_free(); ami_openurl_close(); - FreeStringClass(urlStringClass); + FreeStringClass(urlStringClass); if(IApplication) DropInterface((struct Interface *)IApplication); if(ApplicationBase) CloseLibrary(ApplicationBase); diff --git a/amiga/print.c b/amiga/print.c index 4bfce139b..93dde35f7 100644 --- a/amiga/print.c +++ b/amiga/print.c @@ -378,7 +378,8 @@ void ami_print(struct hlcache_handle *c, int copies) double height, print_height; float scale = nsoption_int(print_scale) / 100.0; - if(!ami_print_info.msgport) return; + if(ami_print_info.msgport == NULL) + ami_print_init(); if(!(ami_print_info.PReq = (struct IODRPTagsReq *)AllocSysObjectTags(ASOT_IOREQUEST, @@ -450,7 +451,8 @@ struct MsgPort *ami_print_init(void) void ami_print_free(void) { - FreeSysObject(ASOT_PORT,ami_print_info.msgport); + FreeSysObject(ASOT_PORT, ami_print_info.msgport); + ami_print_info.msgport = NULL; } struct MsgPort *ami_print_get_msgport(void) @@ -491,6 +493,7 @@ void ami_print_end(void) glob = &browserglob; ami_print_close_device(); + ami_print_free(); } void ami_print_close_device(void)