Only allocate printing resources for the period of time we need them.

This commit is contained in:
Chris Young 2014-02-07 17:45:00 +00:00
parent 665f724a36
commit f5f7dc9931
2 changed files with 11 additions and 12 deletions

View File

@ -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);

View File

@ -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)