Limit number of open editors on Windows depending on available gdi handles to avoid crashes. Fixes #3937
This commit is contained in:
@@ -783,6 +783,7 @@ MAIN_MSG_OPERATIONCANCELLED;Operation cancelled
|
|||||||
MAIN_MSG_PATHDOESNTEXIST;The path\n\n<b>%1</b>\n\ndoes not exist. Please set a correct path in Preferences.
|
MAIN_MSG_PATHDOESNTEXIST;The path\n\n<b>%1</b>\n\ndoes not exist. Please set a correct path in Preferences.
|
||||||
MAIN_MSG_QOVERWRITE;Do you want to overwrite it?
|
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_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<b>"%1"</b>\n\nMake sure that the folder exists and that you have write permission to it.
|
MAIN_MSG_WRITEFAILED;Failed to write\n<b>"%1"</b>\n\nMake sure that the folder exists and that you have write permission to it.
|
||||||
MAIN_TAB_COLOR;Color
|
MAIN_TAB_COLOR;Color
|
||||||
MAIN_TAB_COLOR_TOOLTIP;Shortcut: <b>Alt-c</b>
|
MAIN_TAB_COLOR_TOOLTIP;Shortcut: <b>Alt-c</b>
|
||||||
|
@@ -279,9 +279,23 @@ bool FilePanel::imageLoaded( Thumbnail* thm, ProgressConnector<rtengine::Initial
|
|||||||
if (options.tabbedUI) {
|
if (options.tabbedUI) {
|
||||||
EditorPanel* epanel;
|
EditorPanel* epanel;
|
||||||
{
|
{
|
||||||
|
#ifdef WIN32
|
||||||
|
int winGdiHandles = GetGuiResources( GetCurrentProcess(), GR_GDIOBJECTS);
|
||||||
|
if(winGdiHandles > 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
|
GThreadLock lock; // Acquiring the GUI... not sure that it's necessary, but it shouldn't harm
|
||||||
epanel = Gtk::manage (new EditorPanel ());
|
epanel = Gtk::manage (new EditorPanel ());
|
||||||
parent->addEditorPanel (epanel, pl->thm->getFileName());
|
parent->addEditorPanel (epanel, pl->thm->getFileName());
|
||||||
|
}
|
||||||
|
#ifdef WIN32
|
||||||
|
else {
|
||||||
|
Glib::ustring msg_ = Glib::ustring("<b>") + M("MAIN_MSG_CANNOTLOAD") + " \"" + thm->getFileName() + "\" .\n" + M("MAIN_MSG_TOOMANYOPENEDITORS") + "</b>";
|
||||||
|
Gtk::MessageDialog msgd (msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||||
|
msgd.run ();
|
||||||
|
goto MAXGDIHANDLESREACHED;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
epanel->open(pl->thm, pl->pc->returnValue() );
|
epanel->open(pl->thm, pl->pc->returnValue() );
|
||||||
|
|
||||||
@@ -301,7 +315,9 @@ bool FilePanel::imageLoaded( Thumbnail* thm, ProgressConnector<rtengine::Initial
|
|||||||
Gtk::MessageDialog msgd (msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
Gtk::MessageDialog msgd (msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||||
msgd.run ();
|
msgd.run ();
|
||||||
}
|
}
|
||||||
|
#ifdef WIN32
|
||||||
|
MAXGDIHANDLESREACHED:
|
||||||
|
#endif
|
||||||
delete pl->pc;
|
delete pl->pc;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user