[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - 3 commits - vcl/unx
Caolán McNamara
caolanm at redhat.com
Thu Jan 21 03:59:11 PST 2016
vcl/unx/gtk3/gtk3gtkinst.cxx | 47 ++++++++++++++++++++++++++++++++-----------
1 file changed, 36 insertions(+), 11 deletions(-)
New commits:
commit 3819b97da3cddb463948c37300c47e804bd66464
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Jan 21 11:28:50 2016 +0000
Resolves: rhbz#1240591 gtk3: store clipboard when LibreOffice is closed
now contents copied to clipboard persist after LibreOffice exits
Change-Id: I4433543944fb9664f87ade43da1198dcdd4e2a7c
(cherry picked from commit f1358edf469e70df1fb044bb58cd888fea15173c)
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index f1a9ddc..a3f3068 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -13,12 +13,12 @@
#include "com/sun/star/lang/XServiceInfo.hpp"
#include "com/sun/star/lang/XSingleServiceFactory.hpp"
#include "com/sun/star/lang/XInitialization.hpp"
-#include "com/sun/star/lang/DisposedException.hpp"
#include "com/sun/star/datatransfer/XTransferable.hpp"
#include "com/sun/star/datatransfer/clipboard/XClipboard.hpp"
#include "com/sun/star/datatransfer/clipboard/XClipboardEx.hpp"
#include "com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp"
#include "com/sun/star/datatransfer/clipboard/XClipboardListener.hpp"
+#include "com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp"
#include "com/sun/star/datatransfer/clipboard/XSystemClipboard.hpp"
#include "com/sun/star/datatransfer/dnd/XDragSource.hpp"
#include "com/sun/star/datatransfer/dnd/XDropTarget.hpp"
@@ -275,6 +275,7 @@ static void clipboard_owner_init(ClipboardOwner *)
class VclGtkClipboard :
public cppu::WeakComponentImplHelper<
datatransfer::clipboard::XSystemClipboard,
+ datatransfer::clipboard::XFlushableClipboard,
XServiceInfo>
{
GdkAtom m_nSelection;
@@ -326,6 +327,12 @@ public:
throw(RuntimeException, std::exception) override;
/*
+ * XFlushableClipboard
+ */
+ virtual void SAL_CALL flushClipboard()
+ throw(RuntimeException, std::exception) override;
+
+ /*
* XClipboardNotifier
*/
virtual void SAL_CALL addClipboardListener(
@@ -502,7 +509,8 @@ namespace
}
VclGtkClipboard::VclGtkClipboard(GdkAtom nSelection)
- : cppu::WeakComponentImplHelper<datatransfer::clipboard::XSystemClipboard, XServiceInfo>
+ : cppu::WeakComponentImplHelper<datatransfer::clipboard::XSystemClipboard,
+ datatransfer::clipboard::XFlushableClipboard, XServiceInfo>
(m_aMutex)
, m_nSelection(nSelection)
{
@@ -513,6 +521,16 @@ VclGtkClipboard::VclGtkClipboard(GdkAtom nSelection)
m_pOwner->m_pThis = this;
}
+void VclGtkClipboard::flushClipboard()
+ throw (RuntimeException, std::exception)
+{
+ if (GDK_SELECTION_CLIPBOARD != m_nSelection)
+ return;
+
+ GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection);
+ gtk_clipboard_store(clipboard);
+}
+
VclGtkClipboard::~VclGtkClipboard()
{
GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection);
@@ -524,7 +542,7 @@ VclGtkClipboard::~VclGtkClipboard()
void VclGtkClipboard::setContents(
const Reference< css::datatransfer::XTransferable >& xTrans,
const Reference< css::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
- throw( RuntimeException, std::exception )
+ throw(RuntimeException, std::exception)
{
osl::ClearableMutexGuard aGuard( m_aMutex );
Reference< datatransfer::clipboard::XClipboardOwner > xOldOwner( m_aOwner );
@@ -584,6 +602,7 @@ void VclGtkClipboard::setContents(
//if we have gained or lost ownership of the clipboard
gtk_clipboard_set_with_owner(clipboard, aGtkTargets.data(), aGtkTargets.size(),
ClipboardGetFunc, ClipboardClearFunc, G_OBJECT(m_pOwner));
+ gtk_clipboard_set_can_store(clipboard, aGtkTargets.data(), aGtkTargets.size());
}
m_aGtkTargets = aGtkTargets;
}
commit b88646fc68cfc1c3840024fe3a59727c9eb9f95d
Author: Dennis Francis <dennisfrancis.in at gmail.com>
Date: Fri Dec 11 09:19:22 2015 +0530
Fix memleak of strings allocated in VclGtkClipboard::makeGtkTargetEntry
This leak is produced when copy and paste of text/numbers
is done in Calc/Writer.
Following is the trace produced by valgrind (trimmed)
malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
g_malloc (in /usr/lib64/libglib-2.0.so.0.4600.2)
g_strdup (in /usr/lib64/libglib-2.0.so.0.4600.2)
VclGtkClipboard::makeGtkTargetEntry(...) (gtk3gtkinst.cxx:467)
VclGtkClipboard::setContents(...) (gtk3gtkinst.cxx:557)
TransferableHelper::CopyToSelection(vcl::Window*) const (transfer.cxx:1019)
ScTabView::CheckSelectionTransfer() (tabview3.cxx:319)
ScTabView::UpdateAutoFillMark() (tabview3.cxx:144)
ScTabView::SelectionChanged() (tabview3.cxx:365)
ScViewFunc::PostPasteFromClip(ScRangeList const&, ScMarkData const&) (viewfun3.cxx:1753)
ScViewFunc::PasteFromClip(...) (viewfun3.cxx:1415)
ScClipUtil::PasteFromClipboard(ScViewData*, ScTabViewShell*, bool) (cliputil.cxx:69)
ScCellShell::ExecuteEdit(SfxRequest&) (cellsh1.cxx:1285)
SfxStubScCellShellExecuteEdit(SfxShell*, SfxRequest&) (scslots.hxx:7135)
SfxShell::CallExec(void (*)(SfxShell*, SfxRequest&), SfxRequest&) (shell.hxx:206)
SfxDispatcher::Call_Impl(SfxShell&, SfxSlot const&, SfxRequest&, bool) (dispatch.cxx:258)...
...
Change-Id: I12468e746f33a64e2b5f05e9ac1c6814c702ffd7
Reviewed-on: https://gerrit.libreoffice.org/20646
Reviewed-by: jan iversen <jani at documentfoundation.org>
Tested-by: jan iversen <jani at documentfoundation.org>
(cherry picked from commit 97df0e601a0d76664b4207d075fa6e2a5a51625c)
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index e9210d0..f1a9ddc 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -456,7 +456,7 @@ void VclGtkClipboard::OwnerChanged(GtkClipboard* clipboard, GdkEvent* /*event*/)
void VclGtkClipboard::ClipboardClear(GtkClipboard * /*clipboard*/)
{
for (auto &a : m_aGtkTargets)
- free(a.target);
+ g_free(a.target);
m_aGtkTargets.clear();
}
@@ -518,6 +518,7 @@ VclGtkClipboard::~VclGtkClipboard()
GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection);
g_signal_handler_disconnect(clipboard, m_nOwnerChangedSignalId);
g_object_unref(m_pOwner);
+ ClipboardClear(nullptr);
}
void VclGtkClipboard::setContents(
@@ -577,6 +578,8 @@ void VclGtkClipboard::setContents(
//if there was a previous gtk_clipboard_set_with_data call then
//ClipboardClearFunc will be called now
GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection);
+ if(G_OBJECT(m_pOwner) == gtk_clipboard_get_owner(clipboard))
+ gtk_clipboard_clear(clipboard);
//use with_owner with m_pOwner so we can distinguish in handle_owner_change
//if we have gained or lost ownership of the clipboard
gtk_clipboard_set_with_owner(clipboard, aGtkTargets.data(), aGtkTargets.size(),
commit 7b422cce4ebc291d5eff723dc0fd4497ab412ed5
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Dec 4 14:11:24 2015 +0000
gtk3: avoid empty target clipboard warning
Change-Id: Ic6b46eb2c81398f0ab2e7539e5cdb27a508c8893
(cherry picked from commit 66fedc0966ad0c732cada974ea910d7a98beca15)
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 9f15db0..e9210d0 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -572,13 +572,16 @@ void VclGtkClipboard::setContents(
aGtkTargets.push_back(makeGtkTargetEntry(aFlavor));
}
- //if there was a previous gtk_clipboard_set_with_data call then
- //ClipboardClearFunc will be called now
- GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection);
- //use with_owner with m_pOwner so we can distinguish in handle_owner_change
- //if we have gained or lost ownership of the clipboard
- gtk_clipboard_set_with_owner(clipboard, aGtkTargets.data(), aGtkTargets.size(),
- ClipboardGetFunc, ClipboardClearFunc, G_OBJECT(m_pOwner));
+ if (!aGtkTargets.empty())
+ {
+ //if there was a previous gtk_clipboard_set_with_data call then
+ //ClipboardClearFunc will be called now
+ GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection);
+ //use with_owner with m_pOwner so we can distinguish in handle_owner_change
+ //if we have gained or lost ownership of the clipboard
+ gtk_clipboard_set_with_owner(clipboard, aGtkTargets.data(), aGtkTargets.size(),
+ ClipboardGetFunc, ClipboardClearFunc, G_OBJECT(m_pOwner));
+ }
m_aGtkTargets = aGtkTargets;
}
More information about the Libreoffice-commits
mailing list