Mercurial > octave
changeset 33379:675d794e23b9 bytecode-interpreter
maint: Merge default to bytecode-interpreter.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Fri, 12 Apr 2024 17:01:12 +0200 |
parents | 463c1f9bfadc (current diff) 7e7d52c1e03a (diff) |
children | e6806f30226a |
files | .github/workflows/make.yaml |
diffstat | 9 files changed, 69 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/graphics/Figure.cc Tue Apr 09 19:49:51 2024 +0200 +++ b/libgui/graphics/Figure.cc Fri Apr 12 17:01:12 2024 +0200 @@ -130,6 +130,8 @@ figure::properties& fp = properties<figure> (); + fp.set___device_pixel_ratio__ (win->devicePixelRatio ()); + // Adjust figure position m_innerRect = boundingBoxToRect (fp.get_boundingbox (true)); m_outerRect = boundingBoxToRect (fp.get_boundingbox (false));
--- a/libgui/src/gui-settings.h Tue Apr 09 19:49:51 2024 +0200 +++ b/libgui/src/gui-settings.h Fri Apr 12 17:01:12 2024 +0200 @@ -221,6 +221,9 @@ // Some constants used in the preferences of several widgets and therefore // defined globally here +// Constants for distinguishing between full GUI and dockwidgets initiated +// from the command line +const QString settings_no_mainwin ("__no_mainwin"); // Constants for handling different color schemes const QColor settings_color_no_change (255, 0, 255); const QStringList settings_color_modes_ext (QStringList () << "" << "_2");
--- a/libgui/src/octave-dock-widget.cc Tue Apr 09 19:49:51 2024 +0200 +++ b/libgui/src/octave-dock-widget.cc Fri Apr 12 17:01:12 2024 +0200 @@ -513,6 +513,7 @@ QRect default_floating_size = QRect (x+16, y+32, w/3, h/2); QRect default_dock_size; + QString key_ext; if (m_main_window) { // We have a main window, dock size depends on size of main window @@ -523,10 +524,11 @@ { // No main window, default dock size should never be used default_dock_size = QRect (0, 0, w/10, h/10); + key_ext = settings_no_mainwin; } m_recent_float_geom - = settings.value (dw_float_geometry.settings_key ().arg (objectName ()), + = settings.value (dw_float_geometry.settings_key ().arg (objectName ()) + key_ext, default_floating_size).toRect (); adjust_to_screen (m_recent_float_geom, default_floating_size); @@ -535,7 +537,7 @@ // saveGeomety to new QRect setting (see comment for restoring size // of docked widgets) QVariant dock_geom - = settings.value (dw_dock_geometry.settings_key ().arg (objectName ()), + = settings.value (dw_dock_geometry.settings_key ().arg (objectName ()) + key_ext, default_dock_size); #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) if (dock_geom.canConvert (QMetaType (QMetaType::QRect))) @@ -588,15 +590,19 @@ store_geometry (); + QString key_ext; + if (! m_main_window) + key_ext = settings_no_mainwin; + // conditional needed? if (! m_recent_float_geom.isNull ()) - settings.setValue (dw_float_geometry.settings_key ().arg (name), m_recent_float_geom); + settings.setValue (dw_float_geometry.settings_key ().arg (name) + key_ext, m_recent_float_geom); if (! m_recent_dock_geom.isEmpty ()) - settings.setValue (dw_dock_geometry.settings_key ().arg (name), m_recent_dock_geom); - settings.setValue (dw_is_visible.settings_key ().arg (name), isVisible ()); // store visibility - settings.setValue (dw_is_floating.settings_key ().arg (name), isFloating ()); // store floating - settings.setValue (dw_is_minimized.settings_key ().arg (name), isMinimized ()); // store minimized + settings.setValue (dw_dock_geometry.settings_key ().arg (name) + key_ext, m_recent_dock_geom); + settings.setValue (dw_is_visible.settings_key ().arg (name) + key_ext, isVisible ()); // store visibility + settings.setValue (dw_is_floating.settings_key ().arg (name) + key_ext, isFloating ()); // store floating + settings.setValue (dw_is_minimized.settings_key ().arg (name) + key_ext, isMinimized ()); // store minimized settings.sync (); }
--- a/libinterp/corefcn/__magick_read__.cc Tue Apr 09 19:49:51 2024 +0200 +++ b/libinterp/corefcn/__magick_read__.cc Fri Apr 12 17:01:12 2024 +0200 @@ -1876,7 +1876,9 @@ octave_idx_type n = 0; while (std::getline (sstream, sub, char (','))) { - sscanf (sub.c_str (), "%f", &number); + if (sscanf (sub.c_str (), "%f", &number) != 1) + error ("fill_exif_ints: failed to read EXIF value as float"); + values(n++) = number; } map.setfield (key, octave_value (values)); @@ -1900,7 +1902,9 @@ octave_idx_type n = 0; while (std::getline (sstream, sub, ',')) { - sscanf (sub.c_str (), "%i/%i", &numerator, &denominator); + if (sscanf (sub.c_str (), "%i/%i", &numerator, &denominator) != 2) + error ("fill_exif_floats: failed to read EXIF numerator/demoninator pair"); + values(n++) = double (numerator) / double (denominator); } map.setfield (key, octave_value (values));
--- a/libinterp/corefcn/graphics.cc Tue Apr 09 19:49:51 2024 +0200 +++ b/libinterp/corefcn/graphics.cc Fri Apr 12 17:01:12 2024 +0200 @@ -4110,6 +4110,22 @@ Matrix figure::properties::get_boundingbox (bool internal, const Matrix&) const { +#if defined (__APPLE__) && defined (__MACH__) + // On macOS with Retina display, it looks like we'd need to divide the + // "__device_pixel_ratio__" (reported by Qt) by the "backingScaleFactor": + // https://developer.apple.com/documentation/appkit/nswindow/1419459-backingscalefactor + // It might also be that we'd need to multiply the screensize (in pixels) by + // the "backingScaleFactor" instead. + // Afaict, that factor is only available via an Objective-C-API. + // FIXME: Check how to get that from C++. + // As a workaround, assume that we are either on a display prior to Retina + // scaling where "__device_pixel_ratio__" and "backingScaleFactor" are both + // 1, or we are on a Retina display where both are probably 2. The latter + // might not always be the case. + double dpr = 1.0; +#else + double dpr = get___device_pixel_ratio__ (); +#endif Matrix screen_size = screen_size_pixels (); Matrix pos = (internal ? get_position ().matrix_value () : @@ -4119,7 +4135,7 @@ pos(0)--; pos(1)--; - pos(1) = screen_size(1) - pos(1) - pos(3); + pos(1) = screen_size(1) / dpr - pos(1) - pos(3); return pos; } @@ -4127,10 +4143,16 @@ Matrix figure::properties::bbox2position (const Matrix& bb) const { +#if defined (__APPLE__) && defined (__MACH__) + // FIXME: See comment in figure::properties::get_boundingbox. + double dpr = 1.0; +#else + double dpr = get___device_pixel_ratio__ (); +#endif Matrix screen_size = screen_size_pixels (); Matrix pos = bb; - pos(1) = screen_size(1) - pos(1) - pos(3); + pos(1) = screen_size(1) - (pos(1) + pos(3)) * dpr; pos(1)++; pos(0)++; pos = convert_position (pos, "pixels", get_units (), screen_size); @@ -4141,7 +4163,6 @@ figure::properties::set_boundingbox (const Matrix& bb, bool internal, bool do_notify_toolkit) { - Matrix screen_size = screen_size_pixels (); Matrix pos = bbox2position (bb); if (internal)
--- a/libinterp/parse-tree/lex.ll Tue Apr 09 19:49:51 2024 +0200 +++ b/libinterp/parse-tree/lex.ll Fri Apr 12 17:01:12 2024 +0200 @@ -1005,7 +1005,8 @@ curr_lexer->update_token_positions (yyleng); unsigned int result; - sscanf (yytext+1, "%o", &result); + if (sscanf (yytext+1, "%o", &result) != 1) + curr_lexer->fatal_error ("scanf failed in lexer rule <DQ_STRING_START>\\\\[0-7]{1,3} - please report this bug"); if (result > 0xff) { @@ -1023,7 +1024,8 @@ curr_lexer->m_filepos.increment_column (yyleng); unsigned int result; - sscanf (yytext+2, "%x", &result); + if (sscanf (yytext+2, "%x", &result) != 1) + curr_lexer->fatal_error ("scanf failed in lexer rule <DQ_STRING_START>\\\\x[0-9a-fA-F]+ - please report this bug"); // Truncate the value silently instead of checking the range like // we do for octal above. This is to match C/C++ where any number @@ -3112,10 +3114,8 @@ *p = '\0'; double value = 0.0; - int nread = sscanf (tmptxt, "%lf", &value); - - if (nread != 1) - error ("unexpected: nread != 1 in base_lexer::handle_number<10> - please report this bug"); + if (sscanf (tmptxt, "%lf", &value) != 1) + fatal_error ("scanf failed in base_lexer::handle_number<10> - please report this bug"); octave_value ov_value; @@ -3220,16 +3220,11 @@ return syntax_error (msg); } - // If yytext doesn't contain a valid number, we are in deep doo doo. - uintmax_t long_int_val; - int status = sscanf (yytxt.c_str (), "%jx", &long_int_val); - - if (status == 0) - error ("unexpected: sscanf failed in base_lexer::handle_number<16> - please report this bug"); - - octave_value ov_value - = make_integer_value (long_int_val, unsigned_val, bytes); + if (sscanf (yytxt.c_str (), "%jx", &long_int_val) != 1) + fatal_error ("sscanf failed in base_lexer::handle_number<16> - please report this bug"); + + octave_value ov_value = make_integer_value (long_int_val, unsigned_val, bytes); m_looking_for_object_index = false; m_at_beginning_of_statement = false;
--- a/libinterp/parse-tree/oct-parse.yy Tue Apr 09 19:49:51 2024 +0200 +++ b/libinterp/parse-tree/oct-parse.yy Fri Apr 12 17:01:12 2024 +0200 @@ -3986,12 +3986,14 @@ if (short_name != cls_name) { + filepos f_pos = id->beg_pos (); + delete a; delete id; delete sc; delete body; - bison_error ("invalid classdef definition, the class name must match the filename", id->beg_pos ()); + bison_error ("invalid classdef definition, the class name must match the filename", f_pos); } else
--- a/libinterp/parse-tree/pt-idx.h Tue Apr 09 19:49:51 2024 +0200 +++ b/libinterp/parse-tree/pt-idx.h Fri Apr 12 17:01:12 2024 +0200 @@ -73,6 +73,8 @@ std::string name () const; + comment_list leading_comments () const { return m_expr->leading_comments (); } + filepos beg_pos () const { return m_expr->beg_pos (); } filepos end_pos () const;
--- a/src/main-gui.cc Tue Apr 09 19:49:51 2024 +0200 +++ b/src/main-gui.cc Fri Apr 12 17:01:12 2024 +0200 @@ -144,7 +144,12 @@ octave::sys::env::set_program_name (argv[0]); - octave::qt_application app ("octave", "octave-gui", OCTAVE_VERSION, + std::string app_name ("octave-gui"); + std::string settings_file = octave::sys::env::getenv ("OCTAVE_GUI_SETTINGS"); + if (! settings_file.empty ()) + app_name = settings_file; + + octave::qt_application app ("octave", app_name, OCTAVE_VERSION, argc, argv); int ret = app.execute ();