Kaydet (Commit) 474ad6b0 authored tarafından Luboš Luňák's avatar Luboš Luňák

make sure KFileDialog does not leave the SolarMutex released

Change-Id: I806bf5fe1cd1871de499ceeeadf36de539e9d637
üst 2cd8a1e0
...@@ -256,19 +256,17 @@ sal_Int16 SAL_CALL KDE4FilePicker::execute() ...@@ -256,19 +256,17 @@ sal_Int16 SAL_CALL KDE4FilePicker::execute()
_dialog->setFilter(_filter); _dialog->setFilter(_filter);
_dialog->filterWidget()->setEditable(false); _dialog->filterWidget()->setEditable(false);
// At this point, SolarMutex is held. Opening the KDE file dialog here // KFileDialog intergration requires using event loop with QClipboard.
// can lead to QClipboard asking for clipboard contents. If LO core // Opening the KDE file dialog here can lead to QClipboard
// is the owner of the clipboard content, this will block for 5 seconds // asking for clipboard contents. If LO core is the owner of the clipboard
// and timeout, since the clipboard thread will not be able to acquire // content, without event loop use this will block for 5 seconds and timeout,
// SolarMutex and thus won't be able to respond. If the event loops // since the clipboard thread will not be able to acquire SolarMutex
// and thus won't be able to respond. If the event loops
// are properly integrated and QClipboard can use a nested event loop // are properly integrated and QClipboard can use a nested event loop
// (see the KDE VCL plug), then this won't happen, but otherwise // (see the KDE VCL plug), then this won't happen.
// simply release the SolarMutex here. The KDE file dialog does not // We cannot simply release SolarMutex here, because the event loop started
// call back to the core, so this should be safe (and if it does, // by the file dialog would also call back to LO code.
// SolarMutex will need to be re-acquired). assert( qApp->clipboard()->property( "useEventLoopWhenWaiting" ).toBool() == true );
long mutexrelease = 0;
if( !qApp->clipboard()->property( "useEventLoopWhenWaiting" ).toBool())
mutexrelease = Application::ReleaseSolarMutex();
//block and wait for user input //block and wait for user input
int result = _dialog->exec(); int result = _dialog->exec();
// HACK: KFileDialog uses KConfig("kdeglobals") for saving some settings // HACK: KFileDialog uses KConfig("kdeglobals") for saving some settings
...@@ -276,8 +274,6 @@ sal_Int16 SAL_CALL KDE4FilePicker::execute() ...@@ -276,8 +274,6 @@ sal_Int16 SAL_CALL KDE4FilePicker::execute()
// (which is probably a KDE bug), so force reading the new configuration, // (which is probably a KDE bug), so force reading the new configuration,
// otherwise the next opening of the dialog would use the old settings. // otherwise the next opening of the dialog would use the old settings.
KGlobal::config()->reparseConfiguration(); KGlobal::config()->reparseConfiguration();
if( !qApp->clipboard()->property( "useEventLoopWhenWaiting" ).toBool())
Application::AcquireSolarMutex( mutexrelease );
if( result == KFileDialog::Accepted) if( result == KFileDialog::Accepted)
return ExecutableDialogResults::OK; return ExecutableDialogResults::OK;
......
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