Skip to content

Commit

Permalink
disable mouse handler before executing ext cmd
Browse files Browse the repository at this point in the history
Otherwise we get crashes.
  • Loading branch information
stsp committed Mar 28, 2024
1 parent 06cacf9 commit e83113c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -2987,7 +2987,7 @@ static void perform_external_cmd(int call, int lh, char *ext_cmd)
char *lh_d;

if (mouse_en)
mouse_hide();
mouse_disable();
#if SYNC_ENV
/* the below is disabled because it seems we don't need
* to update our copy of env. djgpp creates the env segment
Expand Down Expand Up @@ -3095,10 +3095,7 @@ static void perform_external_cmd(int call, int lh, char *ext_cmd)
reset_text_attrs();
gppconio_init(); /* video mode could change */
if (mouse_en)
{
mouse_reset();
mouse_show();
}
mouse_enable();

sprintf(el, "%d", error_level);
setenv("ERRORLEVEL", el, 1);
Expand Down
11 changes: 9 additions & 2 deletions src/ms.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ int mouse_init(void)
return 1;
}

void mouse_reset(void)
void mouse_enable(void)
{
__dpmi_regs r = { };

Expand All @@ -212,9 +212,11 @@ void mouse_reset(void)
r.x.es = newm.segment;
r.x.dx = newm.offset16;
__dpmi_int(0x33, &r);

mouse_show();
}

void mouse_done(void)
void mouse_disable(void)
{
__dpmi_regs r = { };

Expand All @@ -225,6 +227,11 @@ void mouse_done(void)
r.x.es = oldm.segment;
r.x.dx = oldm.offset16;
__dpmi_int(0x33, &r);
}

void mouse_done(void)
{
mouse_disable();
__dpmi_free_real_mode_callback(&newm);
__dpmi_free_memory(mregs.handle);
}
Expand Down
3 changes: 2 additions & 1 deletion src/ms.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#define MS_H

int mouse_init(void);
void mouse_reset(void);
void mouse_enable(void);
void mouse_disable(void);
void mouse_done(void);
void mouse_show(void);
void mouse_hide(void);
Expand Down

0 comments on commit e83113c

Please sign in to comment.