Closed quozl closed 1 year ago
Fixing the above tracebacks;
From 5f21a0772492be2f8cc138c2fd1b82768008bd91 Mon Sep 17 00:00:00 2001
From: James Cameron <quozl@laptop.org>
Date: Wed, 4 Sep 2019 16:29:03 +1000
Subject: [PATCH] Work in progress - Fix text clipping cannot be removed from Frame
---
src/jarabe/frame/clipboardicon.py | 7 ++++---
src/jarabe/frame/clipboardtray.py | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/jarabe/frame/clipboardicon.py b/src/jarabe/frame/clipboardicon.py
index 6a4c3275e..dfdc6d419 100644
--- a/src/jarabe/frame/clipboardicon.py
+++ b/src/jarabe/frame/clipboardicon.py
@@ -48,7 +48,7 @@ class ClipboardIcon(RadioToolButton):
self.props.sensitive = False
self.props.active = False
self._notif_icon = None
- self._current_percent = None
+ self._current_percent = 0
self._icon = Icon()
color = profile.get_color()
@@ -152,11 +152,12 @@ class ClipboardIcon(RadioToolButton):
self.props.sensitive = True
# Clipboard object became complete. Make it the active one.
- if self._current_percent < 100 and cb_object.get_percent() == 100:
+ percent = cb_object.get_percent()
+ if self._current_percent < 100 and percent == 100:
self.props.active = True
self.show_notification()
- self._current_percent = cb_object.get_percent()
+ self._current_percent = percent
def _object_selected_cb(self, cb_service, object_id):
if object_id != self._cb_object.get_id():
diff --git a/src/jarabe/frame/clipboardtray.py b/src/jarabe/frame/clipboardtray.py
index 3a5b3df01..247dead3b 100644
--- a/src/jarabe/frame/clipboardtray.py
+++ b/src/jarabe/frame/clipboardtray.py
@@ -58,7 +58,7 @@ class _ContextMap(object):
class ClipboardTray(tray.VTray):
- MAX_ITEMS = Gdk.Screen.height() / style.GRID_CELL_SIZE - 2
+ MAX_ITEMS = Gdk.Screen.height() // style.GRID_CELL_SIZE - 2
def __init__(self):
tray.VTray.__init__(self, align=tray.ALIGN_TO_END)
--
2.17.1
However, reveals next tracebacks;
Traceback (most recent call last):
File "/usr/lib/python3.7/dist-packages/jarabe/frame/clipboardmenu.py", line 173, in _remove_item_activate_cb
cb_service.delete_object(self._cb_object.get_id())
File "/usr/lib/python3.7/dist-packages/jarabe/frame/clipboard.py", line 104, in delete_object
self.emit('object-deleted', object_id)
TypeError: could not convert type int to gint required for parameter 0
Traceback (most recent call last):
File "/usr/lib/python3.7/dist-packages/jarabe/frame/clipboardmenu.py", line 173, in _remove_item_activate_cb
cb_service.delete_object(self._cb_object.get_id())
File "/usr/lib/python3.7/dist-packages/jarabe/frame/clipboard.py", line 99, in delete_object
cb_object = self._objects.pop(object_id)
KeyError: -1075609965700169033
Also, the palette display of the clipping text has a b'' wrapper.
the palette display of the clipping text has a b'' wrapper.
Still happens.
Still happens. I just ran across this error on a Fedora 34 SoaS nightly build, which has Sugar 0.118, sugar-toolkit-gtk3 0.118, and terminal version 47.
Agreed.
I would like to work on this. I am trying to reproduce this error. can you explain "open the frame"? what do you mean by this?
@shivamrai1904 When you move your mouse to the left most corner (in sugar desktop, (if you are running a VM, you might need to expand the corner sensitivity and area)), a frame appears around the desktop. Triggering the hotcorner, "opens the frame".
This issue may be because no action has been appointed to remove option In its code.
For keep option it also do nothing there. What is the use of keep. The clip is to be already kept unless someone chooses to remove it.
Is there any other use of keep option.
In case needed, https://help.sugarlabs.org/en/frame.html is the documentation for the Sugar clipboard feature.
For a clip when first time remove is performed it shows type error and when again remove is performed it shows key error. Key error is raised when something being focussed is removed or not present. This means that remove operation has been performed to some extent that is the key assigned to that clip is withdrawn . But before the operation would complete type error aroses. This means solving the type error may solve the whole issue.
Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/jarabe/frame/clipboardmenu.py", line 173, in _remove_item_activate_cb cb_service.delete_object(self._cb_object.get_id()) File "/usr/lib/python3.8/site-packages/jarabe/frame/clipboard.py", line 104, in delete_object self.emit('object-deleted', object_id) TypeError: could not convert type int to gint required for parameter 0 Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/jarabe/frame/clipboardmenu.py", line 173, in _remove_item_activate_cb cb_service.delete_object(self._cb_object.get_id()) File "/usr/lib/python3.8/site-packages/jarabe/frame/clipboard.py", line 99, in delete_object cb_object = self._objects.pop(object_id) KeyError: -8477668653183881997
@shivamrai1904 could you paste the error instead of attaching a screenshot, it makes it easier to view.
What's the error? Screenshots don't show in my mail client, for security reasons, and I haven't logged into GitHub today. ;-)
Hi Team, I have investigated this bug
Root Cause :- Initially, an integer "object_id" was sent, which was a 32-bit number. However, at a later point, the object_id being sent was not in the required range -2,147,483,648 to 2,147,483,647, which meant it could not fit in a 32-bit number.
When the initial input was received, emit function assumed that it was a 32-bit integer and assigned the data type of "gint" to that parameter. But when the larger 64-bit integer was passed later, It raised a type error TypeError: could not convert type int to gint required for parameter 0
because it had already assumed the data type to be a 32-bit "gint."
File "/usr/lib/python3.8/site-packages/jarabe/frame/clipboard.py", line 104, in delete_object self.emit('object-deleted', object_id) TypeError: could not convert type int to gint required for parameter 0
Also, before this error came it has already deleted object_id from _objects(dictionary)
Due to which in Next iteration of code it's giving key error..
File "/usr/lib/python3.8/site-packages/jarabe/frame/clipboard.py", line 99, in delete_object cb_object = self._objects.pop(object_id) KeyError: -8477668653183881997
One way to handle the issue of the object_id being larger than the 32-bit limit is to convert the object_id into a 64-bit integer using the NumPy library. This can be done with just one line of code, which will convert the data type of the integer from 32-bit to 64-bit.
Another solution is to change the data type of the object_id to a string while sending the emit signal. This would avoid any issues related to integer overflow, as the object_id would no longer be treated as a numerical value.
Please Advice @quozl and @chimosky.
Fixing the above tracebacks;
From 5f21a0772492be2f8cc138c2fd1b82768008bd91 Mon Sep 17 00:00:00 2001 From: James Cameron <quozl@laptop.org> Date: Wed, 4 Sep 2019 16:29:03 +1000 Subject: [PATCH] Work in progress - Fix text clipping cannot be removed from Frame --- src/jarabe/frame/clipboardicon.py | 7 ++++--- src/jarabe/frame/clipboardtray.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/jarabe/frame/clipboardicon.py b/src/jarabe/frame/clipboardicon.py index 6a4c3275e..dfdc6d419 100644 --- a/src/jarabe/frame/clipboardicon.py +++ b/src/jarabe/frame/clipboardicon.py @@ -48,7 +48,7 @@ class ClipboardIcon(RadioToolButton): self.props.sensitive = False self.props.active = False self._notif_icon = None - self._current_percent = None + self._current_percent = 0 self._icon = Icon() color = profile.get_color() @@ -152,11 +152,12 @@ class ClipboardIcon(RadioToolButton): self.props.sensitive = True # Clipboard object became complete. Make it the active one. - if self._current_percent < 100 and cb_object.get_percent() == 100: + percent = cb_object.get_percent() + if self._current_percent < 100 and percent == 100: self.props.active = True self.show_notification() - self._current_percent = cb_object.get_percent() + self._current_percent = percent def _object_selected_cb(self, cb_service, object_id): if object_id != self._cb_object.get_id(): diff --git a/src/jarabe/frame/clipboardtray.py b/src/jarabe/frame/clipboardtray.py index 3a5b3df01..247dead3b 100644 --- a/src/jarabe/frame/clipboardtray.py +++ b/src/jarabe/frame/clipboardtray.py @@ -58,7 +58,7 @@ class _ContextMap(object): class ClipboardTray(tray.VTray): - MAX_ITEMS = Gdk.Screen.height() / style.GRID_CELL_SIZE - 2 + MAX_ITEMS = Gdk.Screen.height() // style.GRID_CELL_SIZE - 2 def __init__(self): tray.VTray.__init__(self, align=tray.ALIGN_TO_END) -- 2.17.1
However, reveals next tracebacks;
Traceback (most recent call last): File "/usr/lib/python3.7/dist-packages/jarabe/frame/clipboardmenu.py", line 173, in _remove_item_activate_cb cb_service.delete_object(self._cb_object.get_id()) File "/usr/lib/python3.7/dist-packages/jarabe/frame/clipboard.py", line 104, in delete_object self.emit('object-deleted', object_id) TypeError: could not convert type int to gint required for parameter 0 Traceback (most recent call last): File "/usr/lib/python3.7/dist-packages/jarabe/frame/clipboardmenu.py", line 173, in _remove_item_activate_cb cb_service.delete_object(self._cb_object.get_id()) File "/usr/lib/python3.7/dist-packages/jarabe/frame/clipboard.py", line 99, in delete_object cb_object = self._objects.pop(object_id) KeyError: -1075609965700169033
Also, the palette display of the clipping text has a b'' wrapper.
Thanks. Can we just use the data type as it arrives from the underlying library?
Yes @quozl , We can change the datatype for the parameter of the emit function to GObject.TYPE_INT64 during object deletion signal. I have tested it locally by creating same scenario and it's working fine. References :- http://library.isr.ist.utl.pt/docs/pygtk2reference/gobject-constants.html
Closing as it's been fixed in b898aef2.
Reproducer: start Terminal activity, select an area of text, use ctrl+shift+c shortcut to copy text, open the Frame, right click on the clipping, select Remove.
Expected result: text clipping is removed.
Observed result: text clipping remains.
shell.log contains;