[gnote] Safer cast to Gtk::TextView
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Safer cast to Gtk::TextView
- Date: Sun, 23 May 2021 18:35:46 +0000 (UTC)
commit 0131da175dad17c40b2f489ad910e9853eab7676
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun May 23 20:51:10 2021 +0300
Safer cast to Gtk::TextView
src/notetag.cpp | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/notetag.cpp b/src/notetag.cpp
index 259a461c..f91399c6 100644
--- a/src/notetag.cpp
+++ b/src/notetag.cpp
@@ -162,7 +162,7 @@ namespace gnote {
bool NoteTag::on_event(const Glib::RefPtr<Glib::Object> & sender, GdkEvent *ev, const Gtk::TextIter & iter)
{
- NoteEditor::Ptr editor = NoteEditor::Ptr::cast_dynamic(sender);
+ auto editor = dynamic_cast<NoteEditor*>(sender.get());
Gtk::TextIter start, end;
if (!can_activate())
@@ -197,7 +197,7 @@ namespace gnote {
return false;
// Prevent activation when selecting links with the mouse
- if (editor->get_buffer()->get_has_selection()) {
+ if(editor && editor->get_buffer()->get_has_selection()) {
return false;
}
@@ -211,7 +211,9 @@ namespace gnote {
}
get_extents (iter, start, end);
- on_activate (*(editor.operator->()), start, end);
+ if(editor) {
+ on_activate(*editor, start, end);
+ }
return false;
}
case GDK_KEY_PRESS:
@@ -229,7 +231,9 @@ namespace gnote {
return false;
get_extents (iter, start, end);
- return on_activate (*(editor.operator->()), start, end);
+ if(editor) {
+ return on_activate(*editor, start, end);
+ }
}
default:
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]