Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
4939468d
Commit
4939468d
authored
May 03, 2014
by
Hisham Muhammad
Browse files
Fix crash when scrolling in a filter view with no processes. Closes #76.
parent
7f92c589
Changes
1
Hide whitespace changes
Inline
Side-by-side
Panel.c
View file @
4939468d
...
...
@@ -234,7 +234,9 @@ int Panel_size(Panel* this) {
void
Panel_setSelected
(
Panel
*
this
,
int
selected
)
{
assert
(
this
!=
NULL
);
selected
=
MAX
(
0
,
MIN
(
Vector_size
(
this
->
items
)
-
1
,
selected
));
selected
=
MIN
(
Vector_size
(
this
->
items
)
-
1
,
selected
);
if
(
selected
<
0
)
selected
=
0
;
this
->
selected
=
selected
;
if
(
Panel_eventHandlerFn
(
this
))
{
Panel_eventHandler
(
this
,
EVENT_SETSELECTED
);
...
...
@@ -260,12 +262,14 @@ void Panel_draw(Panel* this, bool focus) {
}
if
(
this
->
selected
>=
last
)
{
last
=
MIN
(
itemCount
,
this
->
selected
+
1
);
first
=
MAX
(
0
,
last
-
this
->
h
)
;
first
=
last
-
this
->
h
;
this
->
scrollV
=
first
;
this
->
needsRedraw
=
true
;
}
assert
(
first
>=
0
);
assert
(
last
<=
itemCount
);
if
(
first
<
0
)
first
=
0
;
if
(
last
>
itemCount
)
last
=
itemCount
;
int
headerLen
=
RichString_sizeVal
(
this
->
header
);
if
(
headerLen
>
0
)
{
...
...
@@ -398,6 +402,8 @@ bool Panel_onKey(Panel* this, int key) {
case
KEY_NPAGE
:
this
->
selected
+=
(
this
->
h
-
1
);
int
size
=
Vector_size
(
this
->
items
);
if
(
this
->
selected
<
0
)
this
->
selected
=
0
;
if
(
this
->
selected
>=
size
)
this
->
selected
=
size
-
1
;
this
->
scrollV
+=
(
this
->
h
-
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment