Commit a33baff1 authored by Michael Gerbracht's avatar Michael Gerbracht Committed by ROOL

Don't rely on potentially stale handle

Detail:
  GetObjectState is now calling Wimp_GetWindowState using the Wimp handle instead of relying on ScaleInternal_IsShowing whose status may be delayed. ScaleInternal_IsShowing is only set if ToolboxShowObject was successful.

Version 0.17. Tagged as 'Scale-0_17'
parent d5c9dc88
/* (0.16) /* (0.17)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
* *
*/ */
#define Module_MajorVersion_CMHG 0.16 #define Module_MajorVersion_CMHG 0.17
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 18 Aug 2015 #define Module_Date_CMHG 13 Feb 2021
#define Module_MajorVersion "0.16" #define Module_MajorVersion "0.17"
#define Module_Version 16 #define Module_Version 17
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "18 Aug 2015" #define Module_Date "13 Feb 2021"
#define Module_ApplicationDate "18-Aug-15" #define Module_ApplicationDate "13-Feb-21"
#define Module_ComponentName "Scale" #define Module_ComponentName "Scale"
#define Module_ComponentPath "castle/RiscOS/Sources/Toolbox/Scale"
#define Module_FullVersion "0.16" #define Module_FullVersion "0.17"
#define Module_HelpVersion "0.16 (18 Aug 2015)" #define Module_HelpVersion "0.17 (13 Feb 2021)"
#define Module_LibraryVersionInfo "0:16" #define Module_LibraryVersionInfo "0:17"
...@@ -183,15 +183,17 @@ _kernel_oserror *show_actual (void) { ...@@ -183,15 +183,17 @@ _kernel_oserror *show_actual (void) {
debug_output ("a","\n"); debug_output ("a","\n");
} }
} }
global_next->flags |= ScaleInternal_IsShowing;
e = _kernel_swi (Toolbox_ShowObject, &regs, &regs); e = _kernel_swi (Toolbox_ShowObject, &regs, &regs);
if (e == NULL) {
global_next->flags |= ScaleInternal_IsShowing;
}
if (show_info) { if (show_info) {
mem_freek (show_info); mem_freek (show_info);
global_next->show_info = NULL; global_next->show_info = NULL;
} }
global_next = NULL; global_next = NULL;
return e; return e;
} }
......
...@@ -76,6 +76,7 @@ extern _kernel_oserror *create_object (_kernel_swi_regs *r, TaskDescriptor *t) ...@@ -76,6 +76,7 @@ extern _kernel_oserror *create_object (_kernel_swi_regs *r, TaskDescriptor *t)
_kernel_oserror *e; _kernel_oserror *e;
_kernel_swi_regs regs, _kernel_swi_regs regs,
win_regs,
*user_regs = (_kernel_swi_regs *) r->r[4]; *user_regs = (_kernel_swi_regs *) r->r[4];
ObjectTemplateHeader *obj_temp_hdr = (ObjectTemplateHeader *) user_regs->r[1]; ObjectTemplateHeader *obj_temp_hdr = (ObjectTemplateHeader *) user_regs->r[1];
ScaleTemplate *template = (ScaleTemplate *) obj_temp_hdr->body; ScaleTemplate *template = (ScaleTemplate *) obj_temp_hdr->body;
...@@ -144,6 +145,12 @@ extern _kernel_oserror *create_object (_kernel_swi_regs *r, TaskDescriptor *t) ...@@ -144,6 +145,12 @@ extern _kernel_oserror *create_object (_kernel_swi_regs *r, TaskDescriptor *t)
= ((template->flags & Scale_GenerateShowEvent) ? ScaleInternal_GenerateShowEvent : 0) = ((template->flags & Scale_GenerateShowEvent) ? ScaleInternal_GenerateShowEvent : 0)
| ((template->flags & Scale_GenerateHideEvent) ? ScaleInternal_GenerateHideEvent : 0); | ((template->flags & Scale_GenerateHideEvent) ? ScaleInternal_GenerateHideEvent : 0);
win_regs.r[0] = 0;
win_regs.r[1] = internal->sub_object_id;
win_regs.r[2] = internal->wimp_handle;
if ((e = _kernel_swi (Window_GetWimpHandle, &regs, &regs)) != NULL)
return e;
if (t->object_list) { /* If there are already fileinfos attached to the task ... */ if (t->object_list) { /* If there are already fileinfos attached to the task ... */
internal->forward = t->object_list; internal->forward = t->object_list;
......
...@@ -59,9 +59,22 @@ extern _kernel_oserror *getstate_object (_kernel_swi_regs *r, TaskDescriptor *t) ...@@ -59,9 +59,22 @@ extern _kernel_oserror *getstate_object (_kernel_swi_regs *r, TaskDescriptor *t)
* *
*/ */
ScaleInternal *internal = (ScaleInternal *) r->r[2];
r->r[0] = (internal->flags & ScaleInternal_IsShowing) ? Toolbox_GetObjectState_Showing : 0; _kernel_oserror *e;
_kernel_swi_regs regs;
wimp_GetWindowState state;
ScaleInternal *internal = (ScaleInternal *) r->r[2];
if (internal->wimp_handle) {
state.open.window_handle = internal->wimp_handle;
regs.r[1] = (int) &state;
if ((e = _kernel_swi (Wimp_GetWindowState, &regs, &regs)) != NULL)
return e;
r->r[0] = (state.flags & wimp_WINDOWFLAGS_OPEN) ? Toolbox_GetObjectState_Showing : 0;
} else {
r->r[0] = (internal->flags & ScaleInternal_IsShowing) ? Toolbox_GetObjectState_Showing : 0;
}
IGNORE(t); IGNORE(t);
......
...@@ -44,6 +44,7 @@ typedef struct _scale_internal { ...@@ -44,6 +44,7 @@ typedef struct _scale_internal {
int show_type; int show_type;
ShowInfo *show_info; ShowInfo *show_info;
ObjectID object_id, sub_object_id; ObjectID object_id, sub_object_id;
int wimp_handle;
int std_value[4]; int std_value[4];
int ini_value; /* contains value when scale was opened */ int ini_value; /* contains value when scale was opened */
} ScaleInternal; } ScaleInternal;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment