From 56eaeca01cc71df32947cfa65b3987f15339d207 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 12 Jul 2017 18:47:50 +0200 Subject: [PATCH] Limit number of open editors on Windows depending on available gdi handles to avoid crashes. Fixes #3937 --- rtdata/languages/default | 1 + rtgui/filepanel.cc | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index 9eea6dc17..51024db25 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -783,6 +783,7 @@ MAIN_MSG_OPERATIONCANCELLED;Operation cancelled MAIN_MSG_PATHDOESNTEXIST;The path\n\n%1\n\ndoes not exist. Please set a correct path in Preferences. MAIN_MSG_QOVERWRITE;Do you want to overwrite it? MAIN_MSG_SETPATHFIRST;You first have to set a target path in Preferences in order to use this function! +MAIN_MSG_TOOMANYOPENEDITORS;Too many open editors.\nPlease close an editor to continue. MAIN_MSG_WRITEFAILED;Failed to write\n"%1"\n\nMake sure that the folder exists and that you have write permission to it. MAIN_TAB_COLOR;Color MAIN_TAB_COLOR_TOOLTIP;Shortcut: Alt-c diff --git a/rtgui/filepanel.cc b/rtgui/filepanel.cc index 7d0f9013b..b3e3668c5 100644 --- a/rtgui/filepanel.cc +++ b/rtgui/filepanel.cc @@ -279,9 +279,23 @@ bool FilePanel::imageLoaded( Thumbnail* thm, ProgressConnector 0 && winGdiHandles <= 8500) // 0 means we don't have the rights to access the function, 8500 because the limit is 10000 and we need about 1500 free handles +#endif + { GThreadLock lock; // Acquiring the GUI... not sure that it's necessary, but it shouldn't harm epanel = Gtk::manage (new EditorPanel ()); parent->addEditorPanel (epanel, pl->thm->getFileName()); + } +#ifdef WIN32 + else { + Glib::ustring msg_ = Glib::ustring("") + M("MAIN_MSG_CANNOTLOAD") + " \"" + thm->getFileName() + "\" .\n" + M("MAIN_MSG_TOOMANYOPENEDITORS") + ""; + Gtk::MessageDialog msgd (msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); + msgd.run (); + goto MAXGDIHANDLESREACHED; + } +#endif } epanel->open(pl->thm, pl->pc->returnValue() ); @@ -301,7 +315,9 @@ bool FilePanel::imageLoaded( Thumbnail* thm, ProgressConnectorpc; {